From 969757baa0af99d905a9b8c99f0c92efa4e0fb33 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 2 Nov 2014 17:20:04 +0100 Subject: player: always use demux_chapter Instead of defining a separate data structure in the core. For some odd reason, demux_chapter exported the chapter time in nano-seconds. Change that to the usual timestamps (rename the field to make any code relying on this to fail compilation), and also remove the unused chapter end time. --- demux/demux.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'demux/demux.c') diff --git a/demux/demux.c b/demux/demux.c index 48b1babe35..d4206228d5 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -1076,9 +1076,9 @@ static int chapter_compare(const void *p1, const void *p2) struct demux_chapter *c1 = (void *)p1; struct demux_chapter *c2 = (void *)p2; - if (c1->start > c2->start) + if (c1->pts > c2->pts) return 1; - else if (c1->start < c2->start) + else if (c1->pts < c2->pts) return -1; return c1->original_index > c2->original_index ? 1 :-1; // never equal } @@ -1090,12 +1090,11 @@ static void demuxer_sort_chapters(demuxer_t *demuxer) } int demuxer_add_chapter(demuxer_t *demuxer, struct bstr name, - uint64_t start, uint64_t end, uint64_t demuxer_id) + double pts, uint64_t demuxer_id) { struct demux_chapter new = { .original_index = demuxer->num_chapters, - .start = start, - .end = end, + .pts = pts, .name = name.len ? bstrdup0(demuxer, name) : NULL, .metadata = talloc_zero(demuxer, struct mp_tags), .demuxer_id = demuxer_id, @@ -1309,3 +1308,14 @@ void demux_unpause(demuxer_t *demuxer) pthread_cond_signal(&in->wakeup); pthread_mutex_unlock(&in->lock); } + +struct demux_chapter *demux_copy_chapter_data(struct demux_chapter *c, int num) +{ + struct demux_chapter *new = talloc_array(NULL, struct demux_chapter, num); + for (int n = 0; n < num; n++) { + new[n] = c[n]; + new[n].name = talloc_strdup(new, new[n].name); + new[n].metadata = mp_tags_dup(new, new[n].metadata); + } + return new; +} -- cgit v1.2.3