diff options
author | wm4 <wm4@nowhere> | 2016-08-06 15:50:46 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-08-06 17:48:45 +0200 |
commit | 7fd3dbcd526b22e6487b885d07498d7c80302c29 (patch) | |
tree | 5cf31a1969a4c89e4505d45a6cf42e6a679fc230 | |
parent | d41f0a54b07d855227b63a6b2c4e92794ff7b86f (diff) | |
download | mpv-7fd3dbcd526b22e6487b885d07498d7c80302c29.tar.bz2 mpv-7fd3dbcd526b22e6487b885d07498d7c80302c29.tar.xz |
demux: fix a minor race condition
If the packet read function returns, and EOF was detected, and a seek
was issued in the meantime, then don't use the EOF result. The seek will
be processed later, and reset the EOF state anyway.
The main effect is probably that we don't return EOF to the decoders
(which the playback core resets before issuing the seek), and that we
won't log an EOF message.
Not important, but slightly more correct.
-rw-r--r-- | demux/demux.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/demux/demux.c b/demux/demux.c index 29a653a5c0..9e5d6b2f7e 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -573,18 +573,20 @@ static bool read_packet(struct demux_internal *in) pthread_mutex_lock(&in->lock); - if (eof) { - for (int n = 0; n < in->num_streams; n++) - in->streams[n]->ds->eof = true; - // If we had EOF previously, then don't wakeup (avoids wakeup loop) - if (!in->last_eof) { - if (in->wakeup_cb) - in->wakeup_cb(in->wakeup_cb_ctx); - pthread_cond_signal(&in->wakeup); - MP_VERBOSE(in, "EOF reached.\n"); + if (!in->seeking) { + if (eof) { + for (int n = 0; n < in->num_streams; n++) + in->streams[n]->ds->eof = true; + // If we had EOF previously, then don't wakeup (avoids wakeup loop) + if (!in->last_eof) { + if (in->wakeup_cb) + in->wakeup_cb(in->wakeup_cb_ctx); + pthread_cond_signal(&in->wakeup); + MP_VERBOSE(in, "EOF reached.\n"); + } } + in->eof = in->last_eof = eof; } - in->eof = in->last_eof = eof; return true; } |