@@ -2543,10 +2543,9 @@ int bd_play_playlist_at(BLURAY *bd, int playlist, int playitem, int playmark, in
2543
2543
// Select a title for playback
2544
2544
// The title index is an index into the list
2545
2545
// established by bd_get_titles()
2546
- int bd_select_title (BLURAY * bd , uint32_t title_idx )
2546
+ static int _select_title (BLURAY * bd , uint32_t title_idx )
2547
2547
{
2548
2548
const char * f_name ;
2549
- int result ;
2550
2549
2551
2550
// Open the playlist
2552
2551
if (bd -> title_list == NULL ) {
@@ -2558,13 +2557,18 @@ int bd_select_title(BLURAY *bd, uint32_t title_idx)
2558
2557
return 0 ;
2559
2558
}
2560
2559
2561
- bd_mutex_lock (& bd -> mutex );
2562
-
2563
2560
bd -> title_idx = title_idx ;
2564
2561
f_name = bd -> title_list -> title_info [title_idx ].name ;
2565
2562
2566
- result = _open_playlist (bd , f_name , 0 );
2563
+ return _open_playlist (bd , f_name , 0 );
2564
+ }
2565
+
2566
+ int bd_select_title (BLURAY * bd , uint32_t title_idx )
2567
+ {
2568
+ int result ;
2567
2569
2570
+ bd_mutex_lock (& bd -> mutex );
2571
+ result = _select_title (bd , title_idx );
2568
2572
bd_mutex_unlock (& bd -> mutex );
2569
2573
2570
2574
return result ;
@@ -2646,38 +2650,55 @@ void bd_seamless_angle_change(BLURAY *bd, unsigned angle)
2646
2650
2647
2651
uint32_t bd_get_titles (BLURAY * bd , uint8_t flags , uint32_t min_title_length )
2648
2652
{
2653
+ NAV_TITLE_LIST * title_list ;
2654
+ uint32_t count ;
2655
+
2649
2656
if (!bd ) {
2650
2657
return 0 ;
2651
2658
}
2652
2659
2653
- nav_free_title_list (& bd -> title_list );
2654
- bd -> title_list = nav_get_title_list (bd -> disc , flags , min_title_length );
2655
-
2656
- if (!bd -> title_list ) {
2660
+ title_list = nav_get_title_list (bd -> disc , flags , min_title_length );
2661
+ if (!title_list ) {
2657
2662
BD_DEBUG (DBG_BLURAY | DBG_CRIT , "nav_get_title_list(%s) failed\n" , disc_root (bd -> disc ));
2658
2663
return 0 ;
2659
2664
}
2660
2665
2666
+ bd_mutex_lock (& bd -> mutex );
2667
+
2668
+ nav_free_title_list (& bd -> title_list );
2669
+ bd -> title_list = title_list ;
2670
+
2661
2671
disc_event (bd -> disc , DISC_EVENT_START , bd -> disc_info .num_titles );
2672
+ count = bd -> title_list -> count ;
2673
+
2674
+ bd_mutex_unlock (& bd -> mutex );
2662
2675
2663
- return bd -> title_list -> count ;
2676
+ return count ;
2664
2677
}
2665
2678
2666
2679
int bd_get_main_title (BLURAY * bd )
2667
2680
{
2681
+ int main_title_idx = -1 ;
2682
+
2668
2683
if (!bd ) {
2669
2684
return -1 ;
2670
2685
}
2686
+
2687
+ bd_mutex_lock (& bd -> mutex );
2688
+
2671
2689
if (bd -> title_type != title_undef ) {
2672
2690
BD_DEBUG (DBG_CRIT | DBG_BLURAY , "bd_get_main_title() can't be used with BluRay menus\n" );
2673
2691
}
2674
2692
2675
2693
if (bd -> title_list == NULL ) {
2676
2694
BD_DEBUG (DBG_BLURAY | DBG_CRIT , "Title list not yet read!\n" );
2677
- return -1 ;
2695
+ } else {
2696
+ main_title_idx = bd -> title_list -> main_title_idx ;
2678
2697
}
2679
2698
2680
- return bd -> title_list -> main_title_idx ;
2699
+ bd_mutex_unlock (& bd -> mutex );
2700
+
2701
+ return main_title_idx ;
2681
2702
}
2682
2703
2683
2704
static int _copy_streams (const NAV_CLIP * clip , BLURAY_STREAM_INFO * * pstreams ,
@@ -2828,19 +2849,26 @@ static BLURAY_TITLE_INFO *_get_title_info(BLURAY *bd, uint32_t title_idx, uint32
2828
2849
2829
2850
BLURAY_TITLE_INFO * bd_get_title_info (BLURAY * bd , uint32_t title_idx , unsigned angle )
2830
2851
{
2852
+ char mpls_name [11 ] = "" ;
2853
+ int mpls_id = -1 ;
2854
+
2855
+ bd_mutex_lock (& bd -> mutex );
2856
+
2831
2857
if (bd -> title_list == NULL ) {
2832
2858
BD_DEBUG (DBG_BLURAY | DBG_CRIT , "Title list not yet read!\n" );
2833
- return NULL ;
2834
- }
2835
- if (bd -> title_list -> count <= title_idx ) {
2859
+ } else if (bd -> title_list -> count <= title_idx ) {
2836
2860
BD_DEBUG (DBG_BLURAY | DBG_CRIT , "Invalid title index %d!\n" , title_idx );
2837
- return NULL ;
2861
+ } else {
2862
+ mpls_id = bd -> title_list -> title_info [title_idx ].mpls_id ;
2863
+ memcpy (mpls_name , bd -> title_list -> title_info [title_idx ].name , 11 );
2838
2864
}
2839
2865
2840
- return _get_title_info (bd ,
2841
- title_idx , bd -> title_list -> title_info [title_idx ].mpls_id ,
2842
- bd -> title_list -> title_info [title_idx ].name ,
2843
- angle );
2866
+ bd_mutex_unlock (& bd -> mutex );
2867
+
2868
+ if (mpls_id < 0 )
2869
+ return NULL ;
2870
+
2871
+ return _get_title_info (bd , title_idx , mpls_id , mpls_name , angle );
2844
2872
}
2845
2873
2846
2874
BLURAY_TITLE_INFO * bd_get_playlist_info (BLURAY * bd , uint32_t playlist , unsigned angle )
0 commit comments