From 69258b2c7113d380e3baf4717aac71dc71872394 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 14 Apr 2013 06:20:31 +0200 Subject: demux: simpler way to notify demuxers about track switches This interfaces assumes track switching is always successful. --- demux/demux.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'demux/demux.c') diff --git a/demux/demux.c b/demux/demux.c index cb3d3a5efe..c8da399f43 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -1224,6 +1224,10 @@ void demuxer_switch_track(struct demuxer *demuxer, enum stream_type type, struct sh_stream *stream) { assert(!stream || stream->type == type); + + int old_id = demuxer->ds[type]->id; + + // legacy int index = stream ? stream->tid : -2; if (type == STREAM_AUDIO) { if (demux_control(demuxer, DEMUXER_CTRL_SWITCH_AUDIO, &index) @@ -1235,8 +1239,6 @@ void demuxer_switch_track(struct demuxer *demuxer, enum stream_type type, demuxer->video->id = index; } else if (type == STREAM_SUB) { int index2 = stream ? stream->stream_index : -2; - if (demuxer->ds[type]->id != index2) - ds_free_packs(demuxer->ds[type]); demuxer->ds[type]->id = index2; } else { abort(); @@ -1252,6 +1254,11 @@ void demuxer_switch_track(struct demuxer *demuxer, enum stream_type type, } } demuxer->ds[type]->sh = new; + + if (old_id != new_id) { + ds_free_packs(demuxer->ds[type]); + demux_control(demuxer, DEMUXER_CTRL_SWITCHED_TRACKS, NULL); + } } int demuxer_add_attachment(demuxer_t *demuxer, struct bstr name, -- cgit v1.2.3