summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-08 01:02:45 +0200
committerwm4 <wm4@nowhere>2013-07-08 01:02:45 +0200
commit50808bab8db030acd07433e58465d1e71bca2269 (patch)
tree9411d5afde2e50c3424deb59d318f4813d00644b
parent8a46d4c49f0f06cae4ccd027816b5fff915a9c44 (diff)
downloadmpv-50808bab8db030acd07433e58465d1e71bca2269.tar.bz2
mpv-50808bab8db030acd07433e58465d1e71bca2269.tar.xz
demux: merge functions
-rw-r--r--demux/demux.c26
1 files 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)
{
}