summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-25 02:10:24 +0100
committerwm4 <wm4@nowhere>2014-03-25 02:10:24 +0100
commit5cae4a807ca3d3c04932490f0b6f72ce1bf57a53 (patch)
treed3b156e26151aae124101bfd31dcaca058ff6cd4 /player
parent92d7dc9e88a1ec94f048f5d4c0edd077a7d9dd7a (diff)
downloadmpv-5cae4a807ca3d3c04932490f0b6f72ce1bf57a53.tar.bz2
mpv-5cae4a807ca3d3c04932490f0b6f72ce1bf57a53.tar.xz
player: remove weird separation between no chapters and 0 chapters
For some reason, it mattered whether mpctx->chapters was NULL or not, even if mpctx->num_chapters was 0. Remove this separation; it serves no purpose.
Diffstat (limited to 'player')
-rw-r--r--player/core.h2
-rw-r--r--player/playloop.c26
2 files changed, 11 insertions, 17 deletions
diff --git a/player/core.h b/player/core.h
index 5927091233..bda0309f9d 100644
--- a/player/core.h
+++ b/player/core.h
@@ -194,8 +194,6 @@ typedef struct MPContext {
struct timeline_part *timeline;
int num_timeline_parts;
int timeline_part;
- // NOTE: even if num_chapters==0, chapters being not NULL signifies presence
- // of chapter metadata
struct chapter *chapters;
int num_chapters;
double video_offset;
diff --git a/player/playloop.c b/player/playloop.c
index 790aeaa3ee..fa014d7397 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -501,15 +501,14 @@ int get_percent_pos(struct MPContext *mpctx)
// -2 is no chapters, -1 is before first chapter
int get_current_chapter(struct MPContext *mpctx)
{
+ if (!mpctx->num_chapters)
+ return -2;
double current_pts = get_current_time(mpctx);
- if (mpctx->chapters) {
- int i;
- for (i = 1; i < mpctx->num_chapters; i++)
- if (current_pts < mpctx->chapters[i].start)
- break;
- return MPMAX(mpctx->last_chapter_seek, i - 1);
- }
- return -2;
+ int i;
+ for (i = 1; i < mpctx->num_chapters; i++)
+ if (current_pts < mpctx->chapters[i].start)
+ break;
+ return MPMAX(mpctx->last_chapter_seek, i - 1);
}
char *chapter_display_name(struct MPContext *mpctx, int chapter)
@@ -536,12 +535,9 @@ char *chapter_display_name(struct MPContext *mpctx, int chapter)
// returns NULL if chapter name unavailable
char *chapter_name(struct MPContext *mpctx, int chapter)
{
- if (mpctx->chapters) {
- if (chapter < 0 || chapter >= mpctx->num_chapters)
- return NULL;
- return talloc_strdup(NULL, mpctx->chapters[chapter].name);
- }
- return NULL;
+ if (chapter < 0 || chapter >= mpctx->num_chapters)
+ return NULL;
+ return talloc_strdup(NULL, mpctx->chapters[chapter].name);
}
// returns the start of the chapter in seconds (-1 if unavailable)
@@ -549,7 +545,7 @@ double chapter_start_time(struct MPContext *mpctx, int chapter)
{
if (chapter == -1)
return get_start_time(mpctx);
- if (mpctx->chapters && chapter < mpctx->num_chapters)
+ if (chapter >= 0 && chapter < mpctx->num_chapters)
return mpctx->chapters[chapter].start;
return -1.0;
}