From 50808bab8db030acd07433e58465d1e71bca2269 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 8 Jul 2013 01:02:45 +0200 Subject: [PATCH] demux: merge functions --- demux/demux.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/demux/demux.c b/demux/demux.c index 6506677275..4068f616cf 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -267,22 +267,25 @@ static demuxer_t *new_demuxer(struct MPOpts *opts, stream_t *stream, int type, return d; } -static struct sh_stream *new_sh_stream_id(demuxer_t *demuxer, - enum stream_type type, - int stream_index, - int demuxer_id) +struct sh_stream *new_sh_stream(demuxer_t *demuxer, enum stream_type type) { - if (demuxer->num_streams > MAX_SH_STREAMS || stream_index > MAX_SH_STREAMS) { + if (demuxer->num_streams > MAX_SH_STREAMS) { mp_msg(MSGT_DEMUXER, MSGL_WARN, "Too many streams."); return NULL; } + int demuxer_id = 0; + for (int n = 0; n < demuxer->num_streams; n++) { + if (demuxer->streams[n]->type == type) + demuxer_id++; + } + struct sh_stream *sh = talloc_struct(demuxer, struct sh_stream, { .type = type, .demuxer = demuxer, .index = demuxer->num_streams, .demuxer_id = demuxer_id, // may be overwritten by demuxer - .stream_index = stream_index, + .stream_index = demuxer->num_streams, .opts = demuxer->opts, }); MP_TARRAY_APPEND(demuxer, demuxer->streams, demuxer->num_streams, sh); @@ -321,17 +324,6 @@ static struct sh_stream *new_sh_stream_id(demuxer_t *demuxer, return sh; } -// This is what "modern" demuxers are supposed to use. -struct sh_stream *new_sh_stream(demuxer_t *demuxer, enum stream_type type) -{ - int num = 0; - for (int n = 0; n < demuxer->num_streams; n++) { - if (demuxer->streams[n]->type == type) - num++; - } - return new_sh_stream_id(demuxer, type, demuxer->num_streams, num); -} - static void free_sh_stream(struct sh_stream *sh) { }