]> git.sesse.net Git - vlc/commitdiff
-Fixed the lock segfault bug with some compilers
authorStéphane Borel <stef@videolan.org>
Tue, 10 Apr 2001 17:47:05 +0000 (17:47 +0000)
committerStéphane Borel <stef@videolan.org>
Tue, 10 Apr 2001 17:47:05 +0000 (17:47 +0000)
-Quick kludge in ifo to avoid a bug with optims. The real fix is coming.

include/input_ext-intf.h
plugins/dvd/dvd_css.c
plugins/dvd/dvd_ifo.c
plugins/dvd/input_dvd.c
plugins/dvd/input_dvd.h
src/input/input.c
src/input/input_programs.c

index 9cf96aef7aa7549768a3d08a0ad3362aba72ea2d..2a086eba1ed5163c79c044bfc79c221eaaf896fe 100644 (file)
@@ -4,7 +4,7 @@
  * control the pace of reading. 
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ext-intf.h,v 1.30 2001/04/08 07:24:47 stef Exp $
+ * $Id: input_ext-intf.h,v 1.31 2001/04/10 17:47:05 stef Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -97,7 +97,7 @@ typedef struct es_descriptor_s
 #define LPCM_AUDIO_ES       0x83
 #define UNKNOWN_ES          0xFF
 
-/* ES Categories */
+/* ES Categories to be used by interface plugins */
 #define VIDEO_ES        0x00
 #define AUDIO_ES        0x01
 #define SPU_ES          0x02
index d999a8b5760b9c937ec63e82c94a5adb6823ddee..4b335ed33a0d534b340ce5388898cba65de6e822 100644 (file)
@@ -2,7 +2,7 @@
  * dvd_css.c: Functions for DVD authentification and unscrambling
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: dvd_css.c,v 1.22 2001/04/08 16:57:47 sam Exp $
+ * $Id: dvd_css.c,v 1.23 2001/04/10 17:47:05 stef Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -275,7 +275,8 @@ int CSSInit( css_t * p_css )
             return 0;
 
         case 0:
-            intf_WarnMsg( 3, "css info: no way to authenticate" );
+            intf_ErrMsg( "css error: no way to authenticate" );
+            return -1;
     }
 
 #else /* HAVE_CSS */
@@ -406,13 +407,13 @@ int CSSGetKey( css_t * p_css )
     if( !b_encrypted )
     {
         intf_WarnMsg( 3, "css warning: this file was _NOT_ encrypted!" );
-        return(0);
+        return 0;
     }
 
     if( b_encrypted && i_registered_keys == 0 )
     {
         intf_ErrMsg( "css error: unable to determine keys from file" );
-        return(1);
+        return -1;
     }
 
     for( i = 0 ; i < i_registered_keys - 1 ; i++ )
@@ -469,10 +470,12 @@ int CSSGetKey( css_t * p_css )
     memcpy( p_css->pi_title_key,
             p_title_key[i_highest].pi_key, KEY_SIZE );
 
+    intf_WarnMsg( 2, "css info: vts key initialized" );
     return 0;
 
 #else /* HAVE_CSS */
-    return 1;
+    intf_ErrMsg( "css error: css decryption unavailable" );
+    return -1;
 
 #endif /* HAVE_CSS */
 }
index 20833a426e0b32fb7aa9e422160dff199bec095a..8b1e0c6804506f39938673bf644132d017819777 100644 (file)
@@ -2,7 +2,7 @@
  * dvd_ifo.c: Functions for ifo parsing
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: dvd_ifo.c,v 1.17 2001/04/08 07:24:47 stef Exp $
+ * $Id: dvd_ifo.c,v 1.18 2001/04/10 17:47:05 stef Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -69,9 +69,9 @@ static int      FreeTitleSet    ( vts_t * );
 #define GET( p_field , i_len )                                              \
     {                                                                       \
         read( p_ifo->i_fd , (p_field) , (i_len) );                          \
-/*fprintf(stderr, "Pos : %lld Val : %llx\n",                                  \
+/* fprintf(stderr, "Pos : %lld Val : %llx\n",                                  \
                                 (long long)(p_ifo->i_pos - i_start),        \
-                                (long long)*(p_field) );    */                \
+                                (long long)*(p_field) );          */          \
         p_ifo->i_pos += i_len;                                              \
     }
 
@@ -80,7 +80,7 @@ static int      FreeTitleSet    ( vts_t * );
         read( p_ifo->i_fd , (p_field) , 1 );                                \
 /*fprintf(stderr, "Pos : %lld Value : %d\n",                                  \
                                 (long long)(p_ifo->i_pos - i_start),        \
-                                          *(p_field) );*/                     \
+                                          *(p_field) );             */        \
         p_ifo->i_pos += 1;                                                  \
     }
 
@@ -90,7 +90,7 @@ static int      FreeTitleSet    ( vts_t * );
         *(p_field) = ntohs( *(p_field) );                                   \
 /*fprintf(stderr, "Pos : %lld Value : %d\n",                                  \
                                 (long long)(p_ifo->i_pos - i_start),        \
-                                          *(p_field) );*/                     \
+                                          *(p_field) );               */      \
         p_ifo->i_pos += 2;                                                  \
     }
 
@@ -100,7 +100,7 @@ static int      FreeTitleSet    ( vts_t * );
         *(p_field) = ntohl( *(p_field) );                                   \
 /*fprintf(stderr, "Pos : %lld Value : %d\n",                                  \
                                 (long long)(p_ifo->i_pos - i_start),        \
-                                          *(p_field) );*/                     \
+                                          *(p_field) );                 */    \
         p_ifo->i_pos += 4;                                                  \
     }
 
@@ -110,7 +110,7 @@ static int      FreeTitleSet    ( vts_t * );
         *(p_field) = ntoh64( *(p_field) );                                  \
 /*fprintf(stderr, "Pos : %lld Value : %lld\n",                                \
                                 (long long)(p_ifo->i_pos - i_start),        \
-                                            *(p_field) );*/                   \
+                                            *(p_field) );                 */  \
         p_ifo->i_pos += 8;                                                  \
     }
 
@@ -126,38 +126,42 @@ static int      FreeTitleSet    ( vts_t * );
 /*
  * IFO Management.
  */
-
 /*****************************************************************************
- * IfoInit : Creates an ifo structure and prepares for parsing directly
- *           on DVD device. Then reads information from the management table.
+ * IfoCreate : Creates an ifo structure and prepares for parsing directly
+ *             on DVD device
  *****************************************************************************/
-int IfoInit( ifo_t ** pp_ifo, int i_fd )
+int IfoCreate( thread_dvd_data_t * p_dvd )
 {
-    ifo_t *             p_ifo;
-    u64                 i_temp;
-    u32                 i_lba;
-    int                 i, j, k;
-    off_t               i_start;
-
-    
-    p_ifo = malloc( sizeof(ifo_t) );
-    if( p_ifo == NULL )
+    p_dvd->p_ifo = malloc( sizeof(ifo_t) );
+    if( p_dvd->p_ifo == NULL )
     {
         intf_ErrMsg( "ifo error: unable to allocate memory. aborting" );
         return -1;
     }
 
-    *pp_ifo = p_ifo;
-
     /* if we are here the dvd device has already been opened */
-    p_ifo->i_fd = i_fd;
+    p_dvd->p_ifo->i_fd = p_dvd->i_fd;
+
+    return 0;
+}
+
+/*****************************************************************************
+ * IfoInit : Reads information from the management table.
+ *****************************************************************************/
+int IfoInit( ifo_t * p_ifo )
+{
+    u64                 i_temp;
+    u32                 i_lba;
+    int                 i, j, k;
+    off_t               i_start;
 
     /* find the start sector of video information on the dvd */
-    i_lba = UDFFindFile( i_fd, "/VIDEO_TS/VIDEO_TS.IFO");
+    i_lba = UDFFindFile( p_ifo->i_fd, "/VIDEO_TS/VIDEO_TS.IFO");
 
     p_ifo->i_off = (off_t)(i_lba) * DVD_LB_SIZE;
     p_ifo->i_pos = lseek( p_ifo->i_fd, p_ifo->i_off, SEEK_SET );
 
+//i_start = p_ifo->i_pos;
     /*
      * read the video manager information table
      */
@@ -203,7 +207,7 @@ int IfoInit( ifo_t ** pp_ifo, int i_fd )
     }
     FLUSH( 17 );
     GETC( &manager_inf.i_spu_nb );
-//fprintf( stderr, "vmgi subpic nb : %d\n", manager_inf.i_subpic_nb );
+//fprintf( stderr, "vmgi subpic nb : %d\n", manager_inf.i_spu_nb );
     for( i=0 ; i < manager_inf.i_spu_nb ; i++ )
     {
         GET( &i_temp, 6 );
@@ -254,7 +258,7 @@ int IfoInit( ifo_t ** pp_ifo, int i_fd )
             GETC( &title_inf.p_attr[i].i_title_set_num );
             GETC( &title_inf.p_attr[i].i_title_num );
             GETL( &title_inf.p_attr[i].i_start_sector );
-//fprintf( stderr, "title_inf: %d %d %d\n", ptr.p_tts[i].i_ptt_nb, ptr.p_tts[i].i_tts_nb,ptr.p_tts[i].i_vts_ttn );
+//fprintf( stderr, "title_inf: %d %d %d\n",title_inf.p_attr[i].i_chapter_nb ,title_inf.p_attr[i].i_title_set_num,title_inf.p_attr[i].i_title_num );
         }
     }
     else
@@ -391,14 +395,14 @@ int IfoInit( ifo_t ** pp_ifo, int i_fd )
             FLUSH(2);
             FLUSH( 1 );
             GETC( &vts_inf.p_vts_attr[i].i_vts_menu_audio_nb );
-//fprintf( stderr, "m audio nb : %d\n", vts_inf.p_vts_vts_inf[i].i_vtsm_audio_nb );
+//fprintf( stderr, "m audio nb : %d\n", vts_inf.p_vts_attr[i].i_vts_menu_audio_nb );
             for( j = 0 ; j < 8 ; j++ )
             {
                 GETLL( &i_temp );
             }
             FLUSH( 17 );
             GETC( &vts_inf.p_vts_attr[i].i_vts_menu_spu_nb );
-//fprintf( stderr, "m subp nb : %d\n", vts_inf.p_vts_vts_inf[i].i_vtsm_subpic_nb );
+//fprintf( stderr, "m subp nb : %d\n", vts_inf.p_vts_attr[i].i_vts_menu_spu_nb );
             for( j = 0 ; j < 28 ; j++ )
             {
                 GET( &i_temp, 6 );
@@ -409,14 +413,14 @@ int IfoInit( ifo_t ** pp_ifo, int i_fd )
             FLUSH(2);
             FLUSH( 1 );
             GETL( &vts_inf.p_vts_attr[i].i_vts_title_audio_nb );
-//fprintf( stderr, "tt audio nb : %d\n", vts_inf.p_vts_vts_inf[i].i_vtstt_audio_nb );
+//fprintf( stderr, "tt audio nb : %d\n", vts_inf.p_vts_attr[i].i_vts_title_audio_nb );
             for( j = 0 ; j < 8 ; j++ )
             {
                 GETLL( &i_temp );
             }
             FLUSH( 17 );
             GETC( &vts_inf.p_vts_attr[i].i_vts_title_spu_nb );
-//fprintf( stderr, "tt subp nb : %d\n", vts_inf.p_vts_vts_inf[i].i_vtstt_subpic_nb );
+//fprintf( stderr, "tt subp nb : %d\n", vts_inf.p_vts_attr[i].i_vts_title_spu_nb );
             for( j=0 ; j<28/*vts_inf.p_vts_vts_inf[i].i_vtstt_subpic_nb*/ ; j++ )
             {
                 GET( &i_temp, 6 );
@@ -482,8 +486,10 @@ int IfoTitleSet( ifo_t * p_ifo )
                    * DVD_LB_SIZE
                    + p_ifo->i_off;
 
-    p_ifo->i_pos = lseek( p_ifo->i_fd, i_off, SEEK_SET );
+//fprintf(stderr, "offset: %lld\n" , i_off );
 
+    p_ifo->i_pos = lseek( p_ifo->i_fd, i_off, SEEK_SET );
+//i_start = p_ifo->i_pos;
     p_ifo->vts.i_pos = p_ifo->i_pos;
 
 #define manager_inf p_ifo->vts.manager_inf
@@ -566,7 +572,7 @@ FLUSH(2);
     }
     FLUSH( 17 );
     GETC( &manager_inf.i_spu_nb );
-//fprintf( stderr, "vtsi subpic nb : %d\n", manager_inf.i_subpic_nb );
+//fprintf( stderr, "vtsi subpic nb : %d\n", manager_inf.i_spu_nb );
     for( i=0 ; i<manager_inf.i_spu_nb ; i++ )
     {
         GET( &i_temp, 6 );
@@ -759,12 +765,11 @@ FLUSH(2);
             return -1;
         }
     }
+#undef manager_inf
 
-    intf_WarnMsg( 2, "ifo info: VTS %d initialized",
+    intf_WarnMsg( 2, "ifo info: vts %d initialized",
          p_ifo->vmg.title_inf.p_attr[p_ifo->i_title-1].i_title_set_num );
 
-#undef manager_inf
-
     p_ifo->vts.b_initialized = 1;
 
     return 0;
@@ -918,15 +923,26 @@ static int ReadTitle( ifo_t * p_ifo, title_t * p_title )
 {
     off_t     i_start;
     int       i;
+    u16         i_temp;
 
     i_start = p_ifo->i_pos;
 
-//fprintf( stderr, "PGC\n" );
+    p_ifo->i_pos = lseek( p_ifo->i_fd, p_ifo->i_pos, SEEK_SET );
+//fprintf( stderr, "PGC @ %lld\n",p_ifo->i_pos  );
 
     FLUSH(2);
+#if 0
     GETC( &p_title->i_chapter_nb );
+fprintf( stderr, "title: prg %d\n", p_title->i_chapter_nb );
+    FLUSH(0);
     GETC( &p_title->i_cell_nb );
-//fprintf( stderr, "title: Prg: %d Cell: %d\n", pgc.i_prg_nb, pgc.i_cell_nb );
+fprintf( stderr, "title: cell %d\n", p_title->i_cell_nb );
+#endif
+    GETS( &i_temp );
+//fprintf(stderr, "title : temp = %x\n", i_temp );
+    p_title->i_chapter_nb = (i_temp & 0xFF );
+    p_title->i_cell_nb = (i_temp & 0xFF00 ) >> 8;
+//fprintf( stderr, "title: Prg: %d Cell: %d\n",p_title->i_chapter_nb,p_title->i_cell_nb  );
     GETL( &p_title->i_play_time );
     GETL( &p_title->i_prohibited_user_op );
     for( i=0 ; i<8 ; i++ )
@@ -1192,7 +1208,7 @@ static int ReadUnitInf( ifo_t * p_ifo, unit_inf_t * p_unit_inf )
         p_ifo->i_pos = lseek( p_ifo->i_fd, i_start +
                               p_unit_inf->p_title[i].i_title_start_byte,
                               SEEK_SET );
-//fprintf( stderr, "Unit: PGC %d\n", i );
+//fprintf( stderr, "Unit: PGC %d @ %lld\n", i, p_ifo->i_pos );
         ReadTitle( p_ifo, &p_unit_inf->p_title[i].title );
     }
 
@@ -1227,6 +1243,8 @@ static int ReadTitleUnit( ifo_t * p_ifo, title_unit_t * p_title_unit )
     FLUSH( 2 );
     GETL( &p_title_unit->i_end_byte );
 
+//fprintf(stderr, "Unit: nb %d end %d\n", p_title_unit->i_unit_nb, p_title_unit->i_end_byte );
+
     p_title_unit->p_unit = malloc( p_title_unit->i_unit_nb *sizeof(unit_t) );
     if( p_title_unit->p_unit == NULL )
     {
@@ -1300,6 +1318,8 @@ static int ReadCellInf( ifo_t * p_ifo, cell_inf_t * p_cell_inf )
         ( i_start + p_cell_inf->i_end_byte + 1 - p_ifo->i_pos )
         / sizeof(cell_map_t);
 
+//fprintf( stderr, "Cell inf: vob %d end %d cell %d\n", p_cell_inf->i_vob_nb, p_cell_inf->i_end_byte,  p_cell_inf->i_cell_nb );
+
     p_cell_inf->p_cell_map =
                 malloc( p_cell_inf->i_cell_nb *sizeof(cell_map_t) );
     if( p_cell_inf->p_cell_map == NULL )
index b2ba9aa5b8fad3f615f0e2f60910c317f5ac6c52..3a9a78996dae42090a1b98d5359f8912708f55fc 100644 (file)
@@ -10,7 +10,7 @@
  *  -dvd_udf to find files
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: input_dvd.c,v 1.40 2001/04/08 16:57:47 sam Exp $
+ * $Id: input_dvd.c,v 1.41 2001/04/10 17:47:05 stef Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -363,6 +363,12 @@ static int DVDFindCell( thread_dvd_data_t * p_dvd )
         i_cell++;
     }
 
+intf_WarnMsg( 1, "FindCell: i_cell %d i_index %d found %d nb %d",
+                    p_dvd->i_cell,
+                    p_dvd->i_prg_cell,
+                    i_cell,
+                    cell.i_cell_nb );
+
     if( i_cell == cell.i_cell_nb )
     {
         intf_ErrMsg( "dvd error: can't find cell" );
@@ -405,7 +411,14 @@ static int DVDFindSector( thread_dvd_data_t * p_dvd )
          p_dvd->p_ifo->vts.cell_inf.p_cell_map[p_dvd->i_cell].i_end_sector,
          title.p_cell_play[p_dvd->i_prg_cell].i_end_sector );
 
-//intf_WarnMsg( 3, "cell: %d sector1: 0x%x end1: 0x%x\nindex: %d sector2: 0x%x end2: 0x%x", p_dvd->i_cell, p_dvd->p_ifo->p_vts->c_adt.p_cell_inf[p_dvd->i_cell].i_ssector, p_dvd->p_ifo->p_vts->c_adt.p_cell_inf[p_dvd->i_cell].i_esector, p_dvd->i_prg_cell, p_pgc->p_cell_play_inf[p_dvd->i_prg_cell].i_entry_sector, p_pgc->p_cell_play_inf[p_dvd->i_prg_cell].i_lsector );
+    intf_WarnMsg( 1, "cell: %d sector1: 0x%x end1: 0x%x\n"
+                     "index: %d sector2: 0x%x end2: 0x%x", 
+        p_dvd->i_cell,
+        p_dvd->p_ifo->vts.cell_inf.p_cell_map[p_dvd->i_cell].i_start_sector,
+        p_dvd->p_ifo->vts.cell_inf.p_cell_map[p_dvd->i_cell].i_end_sector,
+        p_dvd->i_prg_cell,
+        title.p_cell_play[p_dvd->i_prg_cell].i_start_sector,
+        title.p_cell_play[p_dvd->i_prg_cell].i_end_sector );
 #undef title
 
     return 0;
@@ -460,6 +473,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
     u8                   i_mpeg;
     u8                   i_sub_pic;
     u8                   i;
+    int                  j;
     boolean_t            b_last;
 
     p_dvd = (thread_dvd_data_t*)p_input->p_plugin_data;
@@ -476,14 +490,21 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
         p_input->stream.p_selected_area =
                     p_input->stream.pp_areas[p_area->i_id];
 
-        /* title number: it is not vts nb! */
+        /* title number: it is not vts nb!,
+         * it is what appears in the interface list */
         p_dvd->i_title = p_area->i_id;
         p_dvd->p_ifo->i_title = p_dvd->i_title;
 
         /* ifo vts */
-        IfoTitleSet( p_dvd->p_ifo );
-        intf_WarnMsg( 2, "ifo info: vts initialized" );
+        if( IfoTitleSet( p_dvd->p_ifo ) < 0 )
+        {
+            intf_ErrMsg( "dvd error: fatal error in vts ifo" );
+            free( p_dvd );
+            p_input->b_error = 1;
+            return -1;
+        }
 
+//intf_WarnMsg( 3, "cell nb %d", p_dvd->p_ifo->vts.title_unit.p_title[p_dvd->i_program_chain-1].title.i_cell_nb );
 #define vmg p_dvd->p_ifo->vmg
 #define vts p_dvd->p_ifo->vts
         /* title position inside the selected vts */
@@ -492,16 +513,36 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
         p_dvd->i_program_chain =
           vts.title_inf.p_title_start[p_dvd->i_vts_title-1].i_program_chain_num;
 
+        intf_WarnMsg( 1, "dvd: title %d vts_title %d pgc %d",
+                        p_dvd->i_title,
+                        p_dvd->i_vts_title,
+                        p_dvd->i_program_chain );
+
         /* css title key for current vts */
         if( p_dvd->b_encrypted )
         {
+            /* this one is vts number */
             p_dvd->p_css->i_title =
                     vmg.title_inf.p_attr[p_dvd->i_title-1].i_title_set_num;
             p_dvd->p_css->i_title_pos =
                     vts.i_pos +
                     vts.manager_inf.i_title_vob_start_sector * DVD_LB_SIZE;
-            CSSGetKey( p_dvd->p_css );
-            intf_WarnMsg( 2, "css info: vts key initialized" );
+
+            j = CSSGetKey( p_dvd->p_css );
+            if( j < 0 )
+            {
+                intf_ErrMsg( "dvd error: fatal error in vts css key" );
+                free( p_dvd );
+                p_input->b_error = 1;
+                return -1;
+            }
+            else if( j > 0 )
+            {
+                intf_ErrMsg( "dvd error: css decryption unavailable" );
+                free( p_dvd );
+                p_input->b_error = 1;
+                return -1;
+            }
         }
     
         /*
@@ -516,6 +557,9 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
         p_dvd->i_cell = 0;
         p_dvd->i_prg_cell = -1 +
             vts.title_unit.p_title[p_dvd->i_program_chain-1].title.i_cell_nb;
+
+intf_WarnMsg( 3, "cell nb %d", vts.title_unit.p_title[p_dvd->i_program_chain-1].title.i_cell_nb );
+
         DVDFindCell( p_dvd );
 
         /* temporary hack to fix size in some dvds */
@@ -575,8 +619,11 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
         p_es->i_stream_id = 0xe0;
         p_es->i_type = MPEG2_VIDEO_ES;
         p_es->i_cat = VIDEO_ES;
-        input_SelectES( p_input, p_es );
-        intf_WarnMsg( 1, "dvd info: video MPEG2 stream" );
+        intf_WarnMsg( 1, "dvd info: video mpeg2 stream" );
+        if( p_main->b_video )
+        {
+            input_SelectES( p_input, p_es );
+        }
 
         /* Audio ES, in the order they appear in .ifo */
             
@@ -679,29 +726,35 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
             }
         }
 
-        /* For audio: first one if none or a not existing one specified */
-        i_audio = main_GetIntVariable( INPUT_CHANNEL_VAR, 1 );
-        if( i_audio < 0 || i_audio > vts.manager_inf.i_audio_nb )
+        if( p_main->b_audio )
         {
-            main_PutIntVariable( INPUT_CHANNEL_VAR, 1 );
-            i_audio = 1;
-        }
-        if( i_audio > 0 && vts.manager_inf.i_audio_nb > 0 )
-        {
-            input_SelectES( p_input, p_input->stream.pp_es[i_audio] );
-        }
-    
-        /* for spu, default is none */
-        i_spu = main_GetIntVariable( INPUT_SUBTITLE_VAR, 0 );
-        if( i_spu < 0 || i_spu > vts.manager_inf.i_spu_nb )
-        {
-            main_PutIntVariable( INPUT_CHANNEL_VAR, 1 );
-            i_spu = 0;
+            /* For audio: first one if none or a not existing one specified */
+            i_audio = main_GetIntVariable( INPUT_CHANNEL_VAR, 1 );
+            if( i_audio < 0 || i_audio > vts.manager_inf.i_audio_nb )
+            {
+                main_PutIntVariable( INPUT_CHANNEL_VAR, 1 );
+                i_audio = 1;
+            }
+            if( i_audio > 0 && vts.manager_inf.i_audio_nb > 0 )
+            {
+                input_SelectES( p_input, p_input->stream.pp_es[i_audio] );
+            }
         }
-        if( i_spu > 0 && vts.manager_inf.i_spu_nb > 0 )
+
+        if( p_main->b_video )
         {
-            i_spu += vts.manager_inf.i_audio_nb;
-            input_SelectES( p_input, p_input->stream.pp_es[i_spu] );
+            /* for spu, default is none */
+            i_spu = main_GetIntVariable( INPUT_SUBTITLE_VAR, 0 );
+            if( i_spu < 0 || i_spu > vts.manager_inf.i_spu_nb )
+            {
+                main_PutIntVariable( INPUT_CHANNEL_VAR, 1 );
+                i_spu = 0;
+            }
+            if( i_spu > 0 && vts.manager_inf.i_spu_nb > 0 )
+            {
+                i_spu += vts.manager_inf.i_audio_nb;
+                input_SelectES( p_input, p_input->stream.pp_es[i_spu] );
+            }
         }
     } /* i_title >= 0 */
     else
@@ -729,6 +782,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 #undef vts
 #undef vmg
+
     return 0;
 }
 
@@ -738,6 +792,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
 static void DVDInit( input_thread_t * p_input )
 {
     thread_dvd_data_t *  p_dvd;
+    input_area_t *       p_area;
     int                  i_title;
     int                  i_chapter;
     int                  i;
@@ -762,13 +817,12 @@ static void DVDInit( input_thread_t * p_input )
      * when using input_ToggleES
      * who wrote thez damn buggy piece of shit ??? --stef */
     p_dvd->i_block_once = 1;//32;
-    p_input->i_read_once = 4;//128;
+    p_input->i_read_once = 8;//128;
 
     i = CSSTest( p_input->i_handle );
 
     if( i < 0 )
     {
-        intf_ErrMsg( "css error: could not get copyright bit" );
         free( p_dvd );
         p_input->b_error = 1;
         return;
@@ -783,8 +837,15 @@ static void DVDInit( input_thread_t * p_input )
         DVDNetlistInit( 2048, 8192, 2048, DVD_LB_SIZE, p_dvd->i_block_once );
     intf_WarnMsg( 2, "dvd info: netlist initialized" );
 
-    /* Ifo initialisation */
-    if( IfoInit( &p_dvd->p_ifo, p_input->i_handle ) < 0 )
+    /* Ifo allocation & initialisation */
+    if( IfoCreate( p_dvd ) < 0 )
+    {
+        intf_ErrMsg( "dvd error: allcation error in IFO" );
+        p_input->b_error = 1;
+        return;
+    }
+
+    if( IfoInit( p_dvd->p_ifo ) < 0 )
     {
         intf_ErrMsg( "dvd error: fatal failure in IFO" );
         free( p_dvd );
@@ -807,7 +868,7 @@ static void DVDInit( input_thread_t * p_input )
         p_dvd->p_css->i_fd = p_input->i_handle;
         p_dvd->p_css->i_agid = 0;
 
-        if( CSSInit( p_dvd->p_css ) )
+        if( CSSInit( p_dvd->p_css ) < 0 )
         {
             intf_ErrMsg( "dvd error: fatal failure in CSS" );
             free( p_dvd->p_css );
@@ -819,12 +880,12 @@ static void DVDInit( input_thread_t * p_input )
         intf_WarnMsg( 2, "dvd info: CSS initialized" );
     }
 
-    /* Initialize ES structures */
-    input_InitStream( p_input, sizeof( stream_ps_data_t ) );
-
     /* Set stream and area data */
     vlc_mutex_lock( &p_input->stream.stream_lock );
 
+    /* Initialize ES structures */
+    input_InitStream( p_input, sizeof( stream_ps_data_t ) );
+
 #define title_inf p_dvd->p_ifo->vmg.title_inf
     intf_WarnMsg( 2, "dvd info: number of titles: %d", title_inf.i_title_nb );
 
@@ -853,8 +914,6 @@ static void DVDInit( input_thread_t * p_input )
     }   
 #undef area
 
-    vlc_mutex_unlock( &p_input->stream.stream_lock );
-
     /* Get requested title - if none try the first title */
     i_title = main_GetIntVariable( INPUT_TITLE_VAR, 1 );
     if( i_title <= 0 || i_title > title_inf.i_title_nb )
@@ -871,8 +930,12 @@ static void DVDInit( input_thread_t * p_input )
 
     p_input->stream.pp_areas[i_title]->i_part = i_chapter;
 
+    p_area = p_input->stream.pp_areas[i_title];
+
+    vlc_mutex_unlock( &p_input->stream.stream_lock );
+
     /* set title, chapter, audio and subpic */
-    DVDSetArea( p_input, p_input->stream.pp_areas[i_title] );
+    DVDSetArea( p_input, p_area );
 
     return;
 }
index 89545ce01665297b4d3d008812aba232bfd8b67e..ff211610bcf49842af648fdc6cdbf465b00f8b01 100644 (file)
@@ -2,7 +2,7 @@
  * input_dvd.h: thread structure of the DVD plugin
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: input_dvd.h,v 1.16 2001/04/08 16:57:47 sam Exp $
+ * $Id: input_dvd.h,v 1.17 2001/04/10 17:47:05 stef Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -64,13 +64,6 @@ typedef struct thread_dvd_data_s
 
 } thread_dvd_data_t;
 
-/*****************************************************************************
- * Prototypes in dvd_ifo.c
- *****************************************************************************/
-int   IfoInit     ( struct ifo_s **, int );
-int   IfoTitleSet ( struct ifo_s * );
-void  IfoEnd      ( struct ifo_s * );
-
 /*****************************************************************************
  * Prototypes in dvd_css.c
  *****************************************************************************/
@@ -79,3 +72,12 @@ int   CSSInit             ( struct css_s * );
 int   CSSGetKey           ( struct css_s * );
 int   CSSDescrambleSector ( u8 * , u8 * );
 
+/*****************************************************************************
+ * Prototypes in dvd_ifo.c
+ *****************************************************************************/
+int   IfoCreate   ( struct thread_dvd_data_s * );
+int   IfoInit     ( struct ifo_s * );
+int   IfoTitleSet ( struct ifo_s * );
+void  IfoEnd      ( struct ifo_s * );
+
+
index e7c09ac1b55b3fb38a94450130dda62133652ed2..131486afc5a314a23311e4e29ffb6335b823ff78 100644 (file)
@@ -4,7 +4,7 @@
  * decoders.
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input.c,v 1.95 2001/04/08 09:04:33 stef Exp $
+ * $Id: input.c,v 1.96 2001/04/10 17:47:05 stef Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -233,6 +233,7 @@ static void RunThread( input_thread_t *p_input )
 #endif
 
         vlc_mutex_lock( &p_input->stream.stream_lock );
+
         if( p_input->stream.p_selected_area->i_seek != NO_SEEK )
         {
             if( p_input->stream.b_seekable && p_input->pf_seek != NULL )
@@ -254,6 +255,7 @@ static void RunThread( input_thread_t *p_input )
             }
             p_input->stream.p_selected_area->i_seek = NO_SEEK;
         }
+
         vlc_mutex_unlock( &p_input->stream.stream_lock );
 
         i_error = p_input->pf_read( p_input, pp_packets );
index d62f00b6c016056c0eb1c4bea1d8d0b6bd7848ee..4ac64d14bb4772b3ae0a175f03dc939a4ff8ce65 100644 (file)
@@ -2,7 +2,7 @@
  * input_programs.c: es_descriptor_t, pgrm_descriptor_t management
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_programs.c,v 1.45 2001/04/08 07:24:47 stef Exp $
+ * $Id: input_programs.c,v 1.46 2001/04/10 17:47:05 stef Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -58,6 +58,8 @@ int input_InitStream( input_thread_t * p_input, size_t i_data_len )
     p_input->stream.pp_es = NULL;
     p_input->stream.pp_selected_es = NULL;
     p_input->stream.pp_programs = NULL;
+    p_input->stream.pp_areas = NULL;
+    p_input->stream.p_selected_area = NULL;
 
     if( i_data_len )
     {