stream_bluray: return number of titles

So that the "titles" property returns the number of titles.
This commit is contained in:
wm4 2013-09-10 15:39:48 +02:00
parent 328b951019
commit c9a740fccd
1 changed files with 11 additions and 6 deletions

View File

@ -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);