]> git.sesse.net Git - vlc/blobdiff - modules/access/vcd/vcd.c
* INSTALL.win32: added a small note about running vlc under the msvc debugger.
[vlc] / modules / access / vcd / vcd.c
index 14e84ed2cd642650d3865f91a4e8e3f02bae5cad..57e1cbf534f479344e134126ae312cffa30296be 100644 (file)
@@ -2,7 +2,7 @@
  * vcd.c : VCD input module for vlc
  *****************************************************************************
  * Copyright (C) 2000 VideoLAN
- * $Id: vcd.c,v 1.16 2003/03/11 23:56:54 gbazin Exp $
+ * $Id: vcd.c,v 1.22 2003/05/22 12:00:57 gbazin Exp $
  *
  * Author: Johan Bilien <jobi@via.ecp.fr>
  *
@@ -38,7 +38,7 @@
 
 #include <string.h>
 
-#include "vcd.h"
+#include "cdrom.h"
 
 /* how many blocks VCDRead will read in each loop */
 #define VCD_BLOCKS_ONCE 20
@@ -76,7 +76,7 @@ static int  VCDEntryPoints  ( input_thread_t * );
  * Module descriptior
  *****************************************************************************/
 vlc_module_begin();
-    set_description( _("VCD input module") );
+    set_description( _("VCD input") );
     set_capability( "access", 80 );
     set_callbacks( VCDOpen, VCDClose );
     add_shortcut( "svcd" );
@@ -101,17 +101,7 @@ static int VCDOpen( vlc_object_t *p_this )
     input_area_t *          p_area;
     int                     i_title = 1;
     int                     i_chapter = 1;
-
-    p_input->pf_read = VCDRead;
-    p_input->pf_seek = VCDSeek;
-    p_input->pf_set_area = VCDSetArea;
-    p_input->pf_set_program = VCDSetProgram;
-
-#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
+    vcddev_t                *vcddev;
 
     /* parse the options passed in command line : */
     psz_orig = psz_parser = psz_source = strdup( p_input->psz_name );
@@ -154,41 +144,38 @@ static int VCDOpen( vlc_object_t *p_this )
         if( !psz_source ) return -1;
     }
 
-    p_vcd = malloc( sizeof(thread_vcd_data_t) );
+    /* Open VCD */
+    if( !(vcddev = ioctl_Open( p_this, psz_source )) )
+    {
+        msg_Warn( p_input, "could not open %s", psz_source );
+        free( psz_source );
+        return -1;
+    }
 
+    p_vcd = malloc( sizeof(thread_vcd_data_t) );
     if( p_vcd == NULL )
     {
         msg_Err( p_input, "out of memory" );
         free( psz_source );
         return -1;
     }
+    free( psz_source );
 
+    p_vcd->vcddev = vcddev;
     p_input->p_access_data = (void *)p_vcd;
 
     p_input->i_mtu = VCD_DATA_ONCE;
 
     vlc_mutex_lock( &p_input->stream.stream_lock );
-
     p_input->stream.b_pace_control = 1;
     p_input->stream.b_seekable = 1;
-    p_input->stream.b_connected = 1;
     p_input->stream.p_selected_area->i_size = 0;
     p_input->stream.p_selected_area->i_tell = 0;
-
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 
-    if( !(p_vcd->vcddev = ioctl_Open( p_this, psz_source )) )
-    {
-        msg_Warn( p_input, "could not open %s", psz_source );
-        free( psz_source );
-        free( p_vcd );
-        return -1;
-    }
-
     /* We read the Table Of Content information */
     p_vcd->i_nb_tracks = ioctl_GetTracksMap( VLC_OBJECT(p_input),
                                            p_vcd->vcddev, &p_vcd->p_sectors );
-    free( psz_source );
     if( p_vcd->i_nb_tracks < 0 )
         msg_Err( p_input, "unable to count tracks" );
     else if( p_vcd->i_nb_tracks <= 1 )
@@ -259,6 +246,11 @@ static int VCDOpen( vlc_object_t *p_this )
         p_input->psz_demux = "ps";
     }
 
+    p_input->pf_read = VCDRead;
+    p_input->pf_seek = VCDSeek;
+    p_input->pf_set_area = VCDSetArea;
+    p_input->pf_set_program = VCDSetProgram;
+
     return 0;
 }
 
@@ -299,8 +291,9 @@ static int VCDRead( input_thread_t * p_input, byte_t * p_buffer,
 
     for ( i_index = 0 ; i_index < i_blocks ; i_index++ )
     {
-        if ( ioctl_ReadSector( VLC_OBJECT(p_input), p_vcd->vcddev,
-                    p_vcd->i_sector, p_buffer + i_index * VCD_DATA_SIZE ) < 0 )
+        if ( ioctl_ReadSectors( VLC_OBJECT(p_input), p_vcd->vcddev,
+             p_vcd->i_sector, p_buffer + i_index * VCD_DATA_SIZE, 1,
+             VCD_TYPE ) < 0 )
         {
             msg_Err( p_input, "could not read sector %d", p_vcd->i_sector );
             return -1;
@@ -352,8 +345,8 @@ static int VCDRead( input_thread_t * p_input, byte_t * p_buffer,
 
     if ( i_len % VCD_DATA_SIZE ) /* this should not happen */
     {
-        if ( ioctl_ReadSector( VLC_OBJECT(p_input), p_vcd->vcddev,
-                               p_vcd->i_sector, p_last_sector ) < 0 )
+        if ( ioctl_ReadSectors( VLC_OBJECT(p_input), p_vcd->vcddev,
+             p_vcd->i_sector, p_last_sector, 1, VCD_TYPE ) < 0 )
         {
             msg_Err( p_input, "could not read sector %d", p_vcd->i_sector );
             return -1;
@@ -367,7 +360,6 @@ static int VCDRead( input_thread_t * p_input, byte_t * p_buffer,
     return i_read;
 }
 
-
 /*****************************************************************************
  * VCDSetProgram: Does nothing since a VCD is mono_program
  *****************************************************************************/
@@ -377,7 +369,6 @@ static int VCDSetProgram( input_thread_t * p_input,
     return 0;
 }
 
-
 /*****************************************************************************
  * VCDSetArea: initialize input data for title x, chapter y.
  * It should be called for each user navigation request.
@@ -410,12 +401,12 @@ static int VCDSetArea( input_thread_t * p_input, input_area_t * p_area )
 
         /* Update the navigation variables without triggering a callback */
         val.i_int = p_area->i_id;
-        var_Change( p_input, "title", VLC_VAR_SETVALUE, &val );
-        var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL );
+        var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
+        var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL );
         for( i = 1; i <= p_area->i_part_nb; i++ )
         {
             val.i_int = i;
-            var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val );
+            var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, NULL );
         }
     }
 
@@ -439,12 +430,11 @@ static int VCDSetArea( input_thread_t * p_input, input_area_t * p_area )
 
     /* Update the navigation variables without triggering a callback */
     val.i_int = p_area->i_part;
-    var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val );
+    var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
 
     return 0;
 }
 
-
 /****************************************************************************
  * VCDSeek
  ****************************************************************************/
@@ -502,8 +492,8 @@ static int VCDEntryPoints( input_thread_t * p_input )
         return -1;
     }
 
-    if( ioctl_ReadSector( VLC_OBJECT(p_input), p_vcd->vcddev,
-                                VCD_ENTRIES_SECTOR, p_sector ) < 0 )
+    if( ioctl_ReadSectors( VLC_OBJECT(p_input), p_vcd->vcddev,
+        VCD_ENTRIES_SECTOR, p_sector, 1, VCD_TYPE ) < 0 )
     {
         msg_Err( p_input, "could not read entry points sector" );
         free( p_sector );