From 7fd3dbcd526b22e6487b885d07498d7c80302c29 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 6 Aug 2016 15:50:46 +0200 Subject: 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. --- demux/demux.c | 22 ++++++++++++---------- 1 file 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; } -- cgit v1.2.3