summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2013-10-08 00:33:42 -0400
committerBen Boeckel <mathstuf@gmail.com>2013-10-08 22:00:23 -0400
commit47345219a342eeec822583110553ae41884b7f8f (patch)
treef73c7de35f77fb51a353c167c214eda78de0ec88 /mpvcore
parentf72a900892aa8371a16b844b89f7e2369b45b449 (diff)
downloadmpv-47345219a342eeec822583110553ae41884b7f8f.tar.bz2
mpv-47345219a342eeec822583110553ae41884b7f8f.tar.xz
matroska: avoid requesting the same source multiple times
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/timeline/tl_matroska.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/mpvcore/timeline/tl_matroska.c b/mpvcore/timeline/tl_matroska.c
index b4af848fa9..8ff5ae2074 100644
--- a/mpvcore/timeline/tl_matroska.c
+++ b/mpvcore/timeline/tl_matroska.c
@@ -148,6 +148,18 @@ static int enable_cache(struct MPContext *mpctx, struct stream **stream,
return 1;
}
+static bool has_source_request(struct matroska_segment_uid *uids,
+ int num_sources,
+ struct matroska_segment_uid *new_uid)
+{
+ for (int i = 0; i < num_sources; ++i) {
+ if (demux_matroska_uid_cmp(uids + i, new_uid))
+ return true;
+ }
+
+ return false;
+}
+
// segment = get Nth segment of a multi-segment file
static bool check_file_seg(struct MPContext *mpctx, struct demuxer ***sources,
int *num_sources, struct matroska_segment_uid **uids,
@@ -192,6 +204,9 @@ static bool check_file_seg(struct MPContext *mpctx, struct demuxer ***sources,
if (!c->has_segment_uid)
continue;
+ if (has_source_request(*uids, *num_sources, &c->uid))
+ continue;
+
/* Set the requested segment. */
MP_TARRAY_GROW(NULL, *uids, *num_sources);
memcpy((*uids) + *num_sources, &c->uid, sizeof(c->uid));
@@ -446,6 +461,9 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx)
if (!c->has_segment_uid || demux_matroska_uid_cmp(&c->uid, &m->uid))
continue;
+ if (has_source_request(uids, num_sources, &c->uid))
+ continue;
+
memcpy(uids + num_sources, &c->uid, sizeof(c->uid));
sources[num_sources] = NULL;
num_sources++;