]> git.sesse.net Git - vlc/blobdiff - modules/access/vcd/vcd.c
* modules/access/*: strings review + coding style fixes.
[vlc] / modules / access / vcd / vcd.c
index 0a10eb70b7732bc9388d7b9a09c5f86a9c82be41..124ec647e4e24059d09696cccf2553fd58651741 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * vcd.c : VCD input module for vlc
  *****************************************************************************
- * Copyright (C) 2000 VideoLAN
- * $Id: vcd.c,v 1.21 2003/05/18 15:44:03 gbazin Exp $
+ * Copyright (C) 2000-2004 VideoLAN
+ * $Id: vcd.c,v 1.25 2004/01/25 17:31:22 gbazin Exp $
  *
  * Author: Johan Bilien <jobi@via.ecp.fr>
  *
@@ -103,12 +103,6 @@ static int VCDOpen( vlc_object_t *p_this )
     int                     i_chapter = 1;
     vcddev_t                *vcddev;
 
-#ifdef WIN32
-    /* On Win32 we want the VCD access plugin to be explicitly requested,
-     * we end up with lots of problems otherwise */
-    if( !p_input->psz_access || !*p_input->psz_access ) return( -1 );
-#endif
-
     /* parse the options passed in command line : */
     psz_orig = psz_parser = psz_source = strdup( p_input->psz_name );
 
@@ -135,8 +129,8 @@ static int VCDOpen( vlc_object_t *p_this )
             i_chapter = (int)strtol( psz_parser, &psz_next, 10 );
         }
 
-        i_title = i_title ? i_title : 1;
-        i_chapter = i_chapter ? i_chapter : 1;
+        i_title = i_title > 0 ? i_title : 1;
+        i_chapter = i_chapter > 0 ? i_chapter : 1;
     }
 
     if( !*psz_source )
@@ -215,7 +209,7 @@ static int VCDOpen( vlc_object_t *p_this )
     p_input->stream.i_area_nb = 1;
 
 #define area p_input->stream.pp_areas
-    for( i = 1 ; i <= p_vcd->i_nb_tracks - 1 ; i++ )
+    for( i = 1 ; i < p_vcd->i_nb_tracks; i++ )
     {
         /* Titles are Program Chains */
         input_AddArea( p_input, i, 1 );
@@ -234,7 +228,7 @@ static int VCDOpen( vlc_object_t *p_this )
     }
 #undef area
 
-    p_area = p_input->stream.pp_areas[i_title];
+    p_area = p_input->stream.pp_areas[__MIN(i_title,p_vcd->i_nb_tracks -1)];
 
     p_vcd->b_valid_ep = 1;
     if( VCDEntryPoints( p_input ) < 0 )
@@ -340,8 +334,15 @@ static int VCDRead( input_thread_t * p_input, byte_t * p_buffer,
             if( i_entry + 1 < p_vcd->i_entries_nb &&
                     p_vcd->i_sector >= p_vcd->p_entries[i_entry + 1] )
             {
+                vlc_value_t val;
+
                 msg_Dbg( p_input, "new chapter" );
                 p_input->stream.p_selected_area->i_part ++;
+
+                /* Update the navigation variables without triggering
+                 * a callback */
+                val.i_int = p_input->stream.p_selected_area->i_part;
+                var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
             }
             vlc_mutex_unlock( &p_input->stream.stream_lock );
         }
@@ -459,12 +460,19 @@ static void VCDSeek( input_thread_t * p_input, off_t i_off )
     /* Find chapter */
     if( p_vcd->b_valid_ep )
     {
-        for( i_index = 0 ; i_index < p_area->i_part_nb - 1 ; i_index ++ )
+        for( i_index = 2 ; i_index <= p_area->i_part_nb; i_index ++ )
         {
             if( p_vcd->i_sector < p_vcd->p_entries[p_area->i_plugin_data
-                + i_index + 1] )
+                + i_index - 1] )
             {
-                p_area->i_part = i_index;
+                vlc_value_t val;
+
+                p_area->i_part = i_index - 1;
+
+                /* Update the navigation variables without triggering
+                 * a callback */
+                val.i_int = p_area->i_part;
+                var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
                 break;
             }
         }
@@ -533,6 +541,15 @@ static int VCDEntryPoints( input_thread_t * p_input )
     p_vcd->i_entries_nb = 0;
 
 #define i_track BCD_TO_BIN(entries.entry[i].i_track)
+    /* Reset the i_part_nb for each track */
+    for( i = 0 ; i < i_nb ; i++ )
+    {
+        if( i_track <= p_input->stream.i_area_nb )
+        {
+            p_input->stream.pp_areas[i_track-1]->i_part_nb = 0;
+        }
+    }
+
     for( i = 0 ; i < i_nb ; i++ )
     {
         if( i_track <= p_input->stream.i_area_nb )
@@ -550,6 +567,9 @@ static int VCDEntryPoints( input_thread_t * p_input )
                                                             i_entry_index;
                 i_previous_track = i_track;
             }
+            msg_Dbg( p_input, "entry point %i begins at LBA: %i",
+                     i_entry_index, p_vcd->p_entries[i_entry_index] );
+
             i_entry_index ++;
             p_vcd->i_entries_nb ++;
         }