From c9a740fccd1128e43542beeec6f50bc59c2bddb9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 10 Sep 2013 15:39:48 +0200 Subject: stream_bluray: return number of titles So that the "titles" property returns the number of titles. --- stream/stream_bluray.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'stream') diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index 69e47a0589..cde7267713 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -58,6 +58,7 @@ int bluray_angle = 0; struct bluray_priv_s { BLURAY *bd; + int num_titles; int current_angle; int current_title; @@ -146,6 +147,10 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg) *((unsigned int *) arg) = b->current_title; return 1; } + case STREAM_CTRL_GET_NUM_TITLES: { + *((unsigned int *)arg) = b->num_titles; + return 1; + } case STREAM_CTRL_GET_CURRENT_CHAPTER: { *((unsigned int *) arg) = bd_get_current_chapter(b->bd); @@ -287,7 +292,7 @@ static int bluray_stream_open(stream_t *s, int mode) BLURAY_TITLE_INFO *info = NULL; BLURAY *bd; - int title, title_guess, title_count; + int title, title_guess; uint64_t title_size; unsigned int angle = 0; @@ -317,9 +322,9 @@ static int bluray_stream_open(stream_t *s, int mode) } /* check for available titles on disc */ - title_count = bd_get_titles(bd, TITLES_RELEVANT, angle); - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BLURAY_TITLES=%d\n", title_count); - if (!title_count) { + b->num_titles = bd_get_titles(bd, TITLES_RELEVANT, angle); + mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BLURAY_TITLES=%d\n", b->num_titles); + if (!b->num_titles) { mp_msg(MSGT_OPEN, MSGL_ERR, "Can't find any Blu-ray-compatible title here.\n"); bd_close(bd); @@ -328,7 +333,7 @@ static int bluray_stream_open(stream_t *s, int mode) /* parse titles information */ title_guess = BLURAY_DEFAULT_TITLE; - for (i = 0; i < title_count; i++) { + for (i = 0; i < b->num_titles; i++) { BLURAY_TITLE_INFO *ti; int sec, msec; @@ -357,7 +362,7 @@ static int bluray_stream_open(stream_t *s, int mode) /* Select current title */ title = b->cfg_title ? b->cfg_title - 1: title_guess; - title = FFMIN(title, title_count - 1); + title = FFMIN(title, b->num_titles - 1); bd_select_title(bd, title); -- cgit v1.2.3