From 1483fd443a70150204bea3067749a94358f32c22 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 7 Aug 2014 00:34:14 +0200 Subject: demux: fix playback abort if --demuxer-thread is not used Switching tracks caused cached_demux_control() to catch the command to switch tracks, even if no thread was running. Thus, the tracks were never really switched, and EOF happened immediately on playback start. Fix it by not using the cache at all if the demuxer thread is disabled. The cache code still has to be called somewhere, though, because it handles stream metadata update. Regression from today. --- demux/demux.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/demux/demux.c b/demux/demux.c index 6af7976759..61fcb0d47b 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -373,7 +373,7 @@ static bool read_packet(struct demux_internal *in) ds->eof = true; ds->active = false; } - // If we had EOF previously, then donn't wakeup (avoids wakeup loop) + // 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); @@ -763,6 +763,8 @@ void demux_update(demuxer_t *demuxer) struct demux_internal *in = demuxer->in; pthread_mutex_lock(&in->lock); + if (!in->threading) + update_cache(in); demux_copy(demuxer, in->d_buffer); if (in->stream_metadata && (demuxer->events & DEMUX_EVENT_METADATA)) mp_tags_merge(demuxer->metadata, in->stream_metadata); @@ -1157,16 +1159,14 @@ int demux_control(demuxer_t *demuxer, int cmd, void *arg) { struct demux_internal *in = demuxer->in; - pthread_mutex_lock(&in->lock); - if (!in->threading) - update_cache(in); - pthread_cond_signal(&in->wakeup); - int cr = cached_demux_control(in, cmd, arg); - if (cr != DEMUXER_CTRL_DONTKNOW) { + if (in->threading) { + pthread_mutex_lock(&in->lock); + pthread_cond_signal(&in->wakeup); + int cr = cached_demux_control(in, cmd, arg); pthread_mutex_unlock(&in->lock); - return cr; + if (cr != DEMUXER_CTRL_DONTKNOW) + return cr; } - pthread_mutex_unlock(&in->lock); int r = DEMUXER_CTRL_NOTIMPL; demux_pause(demuxer); -- cgit v1.2.3