From b654aaea0abe907f60408534af6c7af23307028d Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 24 Feb 2016 22:04:18 +0100 Subject: demux: avoid lost wakeup on queue overflow If a stream is marked as EOF (due to no packets found in reach), then we need to wakeup the decoder. This is important especially if no packets are found at the start of the file, so the A/V sync logic actually starts playback, instead of waiting for packets that will never come. (It would randomly start playback when running the playback loop due to arbitrary external events like user input.) --- demux/demux.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'demux') diff --git a/demux/demux.c b/demux/demux.c index 6388ca3732..fe72d3ef4c 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -490,7 +490,12 @@ static bool read_packet(struct demux_internal *in) } for (int n = 0; n < in->num_streams; n++) { struct demux_stream *ds = in->streams[n]->ds; - ds->eof |= !ds->head; + bool eof = !ds->head; + if (eof && !ds->eof) { + if (in->wakeup_cb) + in->wakeup_cb(in->wakeup_cb_ctx); + } + ds->eof |= eof; } pthread_cond_signal(&in->wakeup); return false; -- cgit v1.2.3