diff options
Diffstat (limited to 'demux/demux.c')
-rw-r--r-- | demux/demux.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/demux/demux.c b/demux/demux.c index 72023ad14d..6af7976759 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -113,6 +113,8 @@ struct demux_internal { int min_packs; int min_bytes; + bool tracks_switched; // thread needs to inform demuxer of this + bool seeking; // there's a seek queued int seek_flags; // flags for next seek (if seeking==true) double seek_pts; @@ -404,6 +406,18 @@ static void ds_get_packets(struct demux_stream *ds) } } +static void execute_trackswitch(struct demux_internal *in) +{ + in->tracks_switched = false; + + pthread_mutex_unlock(&in->lock); + + if (in->d_thread->desc->control) + in->d_thread->desc->control(in->d_thread, DEMUXER_CTRL_SWITCHED_TRACKS, 0); + + pthread_mutex_lock(&in->lock); +} + static void execute_seek(struct demux_internal *in) { int flags = in->seek_flags; @@ -429,6 +443,10 @@ static void *demux_thread(void *pctx) pthread_cond_wait(&in->wakeup, &in->lock); continue; } + if (in->tracks_switched) { + execute_trackswitch(in); + continue; + } if (in->seeking) { execute_seek(in); continue; @@ -1128,6 +1146,9 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg) c->res = r; return DEMUXER_CTRL_OK; } + case DEMUXER_CTRL_SWITCHED_TRACKS: + in->tracks_switched = true; + return DEMUXER_CTRL_OK; } return DEMUXER_CTRL_DONTKNOW; } |