]> git.sesse.net Git - vlc/blobdiff - modules/access/vcd/vcd.c
Fix a missing path for p_config->Release().
[vlc] / modules / access / vcd / vcd.c
index 58e7773a30107bf6de75cc5b13c9b3619a5dfeaf..e94dc617293b208a380543929c1c434606987c20 100644 (file)
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>
 
-#include <vlc/vlc.h>
-#include <vlc/input.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_input.h>
+#include <vlc_access.h>
+#include <vlc_charset.h>
 
 #include "cdrom.h"
 
@@ -39,23 +45,22 @@ static void Close( vlc_object_t * );
 
 #define CACHING_TEXT N_("Caching value in ms")
 #define CACHING_LONGTEXT N_( \
-    "Allows you to modify the default caching value for cdda streams. This " \
-    "value should be set in milliseconds units." )
-
-vlc_module_begin();
-    set_shortname( _("VCD"));
-    set_description( _("VCD input") );
-    set_capability( "access2", 60 );
-    set_callbacks( Open, Close );
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_ACCESS );
-
-    add_usage_hint( N_("[vcd:][device][@[title][,[chapter]]]") );
+    "Caching value for VCDs. This " \
+    "value should be set in milliseconds." )
+
+vlc_module_begin ()
+    set_shortname( N_("VCD"))
+    set_description( N_("VCD input") )
+    set_capability( "access", 60 )
+    set_callbacks( Open, Close )
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_ACCESS )
+
+    add_usage_hint( N_("[vcd:][device][@[title][,[chapter]]]") )
     add_integer( "vcd-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT,
-                 CACHING_LONGTEXT, VLC_TRUE );
-    add_shortcut( "vcd" );
-    add_shortcut( "svcd" );
-vlc_module_end();
+                 CACHING_LONGTEXT, true )
+    add_shortcut( "vcd", "svcd" )
+vlc_module_end ()
 
 /*****************************************************************************
  * Local prototypes
@@ -79,7 +84,7 @@ struct access_sys_t
 };
 
 static block_t *Block( access_t * );
-static int      Seek( access_t *, int64_t );
+static int      Seek( access_t *, uint64_t );
 static int      Control( access_t *, int, va_list );
 static int      EntryPoints( access_t * );
 
@@ -90,7 +95,10 @@ static int Open( vlc_object_t *p_this )
 {
     access_t     *p_access = (access_t *)p_this;
     access_sys_t *p_sys;
-    char *psz_dup = strdup( p_access->psz_path );
+    if( p_access->psz_filepath == NULL )
+        return VLC_EGENERIC;
+
+    char *psz_dup = ToLocaleDup( p_access->psz_filepath );
     char *psz;
     int i_title = 0;
     int i_chapter = 0;
@@ -130,12 +138,10 @@ static int Open( vlc_object_t *p_this )
 #endif
 
     /* Open VCD */
-    if( !(vcddev = ioctl_Open( p_this, psz_dup )) )
-    {
-        free( psz_dup );
-        return VLC_EGENERIC;
-    }
+    vcddev = ioctl_Open( p_this, psz_dup );
     free( psz_dup );
+    if( !vcddev )
+        return VLC_EGENERIC;
 
     /* Set up p_access */
     p_access->pf_read = NULL;
@@ -145,11 +151,12 @@ static int Open( vlc_object_t *p_this )
     p_access->info.i_update = 0;
     p_access->info.i_size = 0;
     p_access->info.i_pos = 0;
-    p_access->info.b_eof = VLC_FALSE;
+    p_access->info.b_eof = false;
     p_access->info.i_title = 0;
     p_access->info.i_seekpoint = 0;
-    p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
-    memset( p_sys, 0, sizeof( access_sys_t ) );
+    p_access->p_sys = p_sys = calloc( 1, sizeof( access_sys_t ) );
+    if( !p_sys )
+        goto error;
     p_sys->vcddev = vcddev;
 
     /* We read the Table Of Content information */
@@ -173,8 +180,8 @@ static int Open( vlc_object_t *p_this )
     {
         input_title_t *t = p_sys->title[i] = vlc_input_title_New();
 
-        msg_Dbg( p_access, "title[%d] start=%d\n", i, p_sys->p_sectors[1+i] );
-        msg_Dbg( p_access, "title[%d] end=%d\n", i, p_sys->p_sectors[i+2] );
+        msg_Dbg( p_access, "title[%d] start=%d", i, p_sys->p_sectors[1+i] );
+        msg_Dbg( p_access, "title[%d] end=%d", i, p_sys->p_sectors[i+2] );
 
         t->i_size = ( p_sys->p_sectors[i+2] - p_sys->p_sectors[i+1] ) *
                     (int64_t)VCD_DATA_SIZE;
@@ -205,12 +212,13 @@ static int Open( vlc_object_t *p_this )
     p_access->info.i_pos = ( p_sys->i_sector - p_sys->p_sectors[1+i_title] ) *
         VCD_DATA_SIZE;
 
+    free( p_access->psz_demux );
     p_access->psz_demux = strdup( "ps" );
 
     return VLC_SUCCESS;
 
 error:
-    ioctl_Close( VLC_OBJECT(p_access), p_sys->vcddev );
+    ioctl_Close( VLC_OBJECT(p_access), vcddev );
     free( p_sys );
     return VLC_EGENERIC;
 }
@@ -233,9 +241,6 @@ static void Close( vlc_object_t *p_this )
 static int Control( access_t *p_access, int i_query, va_list args )
 {
     access_sys_t *p_sys = p_access->p_sys;
-    vlc_bool_t   *pb_bool;
-    int          *pi_int;
-    int64_t      *pi_64;
     input_title_t ***ppp_title;
     int i;
 
@@ -246,19 +251,13 @@ static int Control( access_t *p_access, int i_query, va_list args )
         case ACCESS_CAN_FASTSEEK:
         case ACCESS_CAN_PAUSE:
         case ACCESS_CAN_CONTROL_PACE:
-            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
-            *pb_bool = VLC_TRUE;
+            *va_arg( args, bool* ) = true;
             break;
 
         /* */
-        case ACCESS_GET_MTU:
-            pi_int = (int*)va_arg( args, int * );
-            *pi_int = VCD_DATA_ONCE;
-            break;
-
         case ACCESS_GET_PTS_DELAY:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
-            *pi_64 = var_GetInteger( p_access, "vcd-caching" ) * 1000;
+            *va_arg( args, int64_t * )
+                     = var_GetInteger(p_access,"vcd-caching") * 1000;
             break;
 
         /* */
@@ -266,11 +265,10 @@ static int Control( access_t *p_access, int i_query, va_list args )
             break;
 
         case ACCESS_GET_TITLE_INFO:
-            ppp_title = (input_title_t***)va_arg( args, input_title_t*** );
-            pi_int    = (int*)va_arg( args, int* );
+            ppp_title = va_arg( args, input_title_t*** );
+            *va_arg( args, int* ) = p_sys->i_titles;
 
             /* Duplicate title infos */
-            *pi_int = p_sys->i_titles;
             *ppp_title = malloc( sizeof(input_title_t **) * p_sys->i_titles );
             for( i = 0; i < p_sys->i_titles; i++ )
             {
@@ -279,7 +277,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
             break;
 
         case ACCESS_SET_TITLE:
-            i = (int)va_arg( args, int );
+            i = va_arg( args, int );
             if( i != p_access->info.i_title )
             {
                 /* Update info */
@@ -298,7 +296,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
         case ACCESS_SET_SEEKPOINT:
         {
             input_title_t *t = p_sys->title[p_access->info.i_title];
-            i = (int)va_arg( args, int );
+            i = va_arg( args, int );
             if( t->i_seekpoint > 0 )
             {
                 p_access->info.i_update |= INPUT_UPDATE_SEEKPOINT;
@@ -307,13 +305,14 @@ static int Control( access_t *p_access, int i_query, va_list args )
                 p_sys->i_sector = p_sys->p_sectors[1+p_access->info.i_title] +
                     t->seekpoint[i]->i_byte_offset / VCD_DATA_SIZE;
 
-                p_access->info.i_pos = (int64_t)(p_sys->i_sector -
+                p_access->info.i_pos = (uint64_t)(p_sys->i_sector -
                     p_sys->p_sectors[1+p_access->info.i_title]) *VCD_DATA_SIZE;
             }
             return VLC_SUCCESS;
         }
 
         case ACCESS_SET_PRIVATE_ID_STATE:
+        case ACCESS_GET_CONTENT_TYPE:
             return VLC_EGENERIC;
 
         default:
@@ -342,7 +341,7 @@ static block_t *Block( access_t *p_access )
     {
         if( p_access->info.i_title + 2 >= p_sys->i_titles )
         {
-            p_access->info.b_eof = VLC_TRUE;
+            p_access->info.b_eof = true;
             return NULL;
         }
 
@@ -409,7 +408,7 @@ static block_t *Block( access_t *p_access )
 /*****************************************************************************
  * Seek:
  *****************************************************************************/
-static int Seek( access_t *p_access, int64_t i_pos )
+static int Seek( access_t *p_access, uint64_t i_pos )
 {
     access_sys_t *p_sys = p_access->p_sys;
     input_title_t *t = p_sys->title[p_access->info.i_title];
@@ -434,6 +433,9 @@ static int Seek( access_t *p_access, int64_t i_pos )
         p_access->info.i_seekpoint = i_seekpoint;
     }
 
+    /* Reset eof */
+    p_access->info.b_eof = false;
+
     return VLC_SUCCESS;
 }
 
@@ -483,7 +485,7 @@ static int EntryPoints( access_t *p_access )
         if( i_title < 0 ) continue;   /* Should not occur */
         if( i_title >= p_sys->i_titles ) continue;
 
-        msg_Dbg( p_access, "Entry[%d] title=%d sector=%d\n",
+        msg_Dbg( p_access, "Entry[%d] title=%d sector=%d",
                  i, i_title, i_sector );
 
         s = vlc_seekpoint_New();
@@ -496,3 +498,4 @@ static int EntryPoints( access_t *p_access )
 
     return VLC_SUCCESS;
 }
+