summaryrefslogtreecommitdiffstats
path: root/player/loadfile.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-25 02:05:48 +0100
committerwm4 <wm4@nowhere>2014-03-25 02:05:48 +0100
commit92d7dc9e88a1ec94f048f5d4c0edd077a7d9dd7a (patch)
tree71edd74fc0c502d3e50394fc4dca9aa56d291505 /player/loadfile.c
parent2c693a47328a4faa9581a792c24448407629279b (diff)
downloadmpv-92d7dc9e88a1ec94f048f5d4c0edd077a7d9dd7a.tar.bz2
mpv-92d7dc9e88a1ec94f048f5d4c0edd077a7d9dd7a.tar.xz
player: remove demuxer chapoter API wrappers
Instead, always use the mpctx->chapters array. Before this commit, this array was used only for ordered chapters and such, but now it's always populated if there are chapters.
Diffstat (limited to 'player/loadfile.c')
-rw-r--r--player/loadfile.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index bdea43b352..ea33e46aee 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1002,6 +1002,24 @@ static void print_timeline(struct MPContext *mpctx)
}
}
+static void load_chapters(struct MPContext *mpctx)
+{
+ if (!mpctx->chapters && mpctx->master_demuxer &&
+ mpctx->master_demuxer->num_chapters)
+ {
+ int count = mpctx->master_demuxer->num_chapters;
+ mpctx->chapters = talloc_array(NULL, struct chapter, count);
+ mpctx->num_chapters = count;
+ for (int n = 0; n < count; n++) {
+ struct demux_chapter *dchapter = &mpctx->master_demuxer->chapters[n];
+ mpctx->chapters[n] = (struct chapter){
+ .start = dchapter->start / 1e9,
+ .name = talloc_strdup(mpctx->chapters, dchapter->name),
+ };
+ }
+ }
+}
+
/* When demux performs a blocking operation (network connection or
* cache filling) if the operation fails we use this function to check
* if it was interrupted by the user.
@@ -1189,6 +1207,7 @@ goto_reopen_demuxer: ;
build_cue_timeline(mpctx);
print_timeline(mpctx);
+ load_chapters(mpctx);
if (mpctx->timeline) {
// With Matroska, the "master" file usually dictates track layout etc.