]> git.sesse.net Git - vlc/blobdiff - modules/access/dv.c
Update LGPL license blurb, choosing v2.1+.
[vlc] / modules / access / dv.c
index 3491eb229c81e149314f2778960f80ab00f6fd3f..372bf74653301345775aab0310b5e47d92a71d30 100644 (file)
 #include <vlc_access.h>
 
 #include <errno.h>
-#ifdef HAVE_SYS_TYPES_H
-#   include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-#   include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#   include <sys/stat.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#   include <fcntl.h>
-#endif
-
+#include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #   include <unistd.h>
 #elif defined( WIN32 ) && !defined( UNDER_CE )
@@ -81,9 +69,7 @@ vlc_module_begin ()
     add_integer( "dv-caching", 60000 / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, true )
         change_safe()
     set_capability( "access", 0 )
-    add_shortcut( "dv" )
-    add_shortcut( "dv1394" )
-    add_shortcut( "raw1394" )
+    add_shortcut( "dv", "dv1394", "raw1394" )
     set_callbacks( Open, Close )
 vlc_module_end ()
 
@@ -145,12 +131,10 @@ static int Open( vlc_object_t *p_this )
 {
     access_t     *p_access = (access_t*)p_this;
     access_sys_t *p_sys;
-    char *psz_name = strdup( p_access->psz_path );
 
     struct raw1394_portinfo port_inf[ 16 ];
-    raw1394_iso_recv_handler_t handler;
 
-    msg_Dbg( p_access, "opening device %s", psz_name );
+    msg_Dbg( p_access, "opening device" );
 
     /* Set up p_access */
     access_InitFields( p_access );
@@ -158,10 +142,7 @@ static int Open( vlc_object_t *p_this )
 
     p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
     if( !p_sys )
-    {
-        free( psz_name );
         return VLC_EGENERIC;
-    }
 
     p_sys->i_cards = 0;
     p_sys->i_node = 0;
@@ -180,42 +161,37 @@ static int Open( vlc_object_t *p_this )
     {
         msg_Err( p_access, "failed to open a Firewire (IEEE1394) connection" );
         Close( p_this );
-        free( psz_name );
         return VLC_EGENERIC;
     }
 
     p_sys->p_avc1394 = AVCOpen( p_access, p_sys->i_port );
     if( !p_sys->p_avc1394 )
     {
-        msg_Err( p_access, "no Digital Video Control device found on %s", psz_name );
+        msg_Err( p_access, "no Digital Video Control device found" );
         Close( p_this );
-        free( psz_name );
         return VLC_EGENERIC;
     }
 
     p_sys->p_raw1394 = raw1394_new_handle();
     if( !p_sys->p_raw1394 )
     {
-        msg_Err( p_access, "no Digital Video device found on %s", psz_name );
+        msg_Err( p_access, "no Digital Video device found" );
         Close( p_this );
-        free( psz_name );
         return VLC_EGENERIC;
     }
 
     p_sys->i_cards = raw1394_get_port_info( p_sys->p_raw1394, port_inf, 16 );
     if( p_sys->i_cards < 0 )
     {
-        msg_Err( p_access, "failed to get port info for %s", psz_name );
+        msg_Err( p_access, "failed to get port info" );
         Close( p_this );
-        free( psz_name );
         return VLC_EGENERIC;
     }
 
     if( raw1394_set_port( p_sys->p_raw1394, p_sys->i_port ) < 0 )
     {
-        msg_Err( p_access, "failed to set port info for %s", psz_name );
+        msg_Err( p_access, "failed to set port info" );
         Close( p_this );
-        free( psz_name );
         return VLC_EGENERIC;
     }
 
@@ -223,9 +199,8 @@ static int Open( vlc_object_t *p_this )
                 ISOCHRONOUS_QUEUE_LENGTH, ISOCHRONOUS_MAX_PACKET_SIZE,
                 p_sys->i_channel, RAW1394_DMA_PACKET_PER_BUFFER, -1 ) < 0 )
     {
-        msg_Err( p_access, "failed to init isochronous recv for %s", psz_name );
+        msg_Err( p_access, "failed to init isochronous recv" );
         Close( p_this );
-        free( psz_name );
         return VLC_EGENERIC;
     }
 
@@ -242,9 +217,8 @@ static int Open( vlc_object_t *p_this )
     p_sys->p_ev = vlc_object_create( p_access, sizeof( event_thread_t ) );
     if( !p_sys->p_ev )
     {
-        msg_Err( p_access, "failed to create event thread for %s", psz_name );
+        msg_Err( p_access, "failed to create event thread" );
         Close( p_this );
-        free( psz_name );
         return VLC_EGENERIC;
     }
 
@@ -255,7 +229,6 @@ static int Open( vlc_object_t *p_this )
     vlc_thread_create( p_sys->p_ev, "dv event thread handler",
                        Raw1394EventThread, VLC_THREAD_PRIORITY_OUTPUT );
 
-    free( psz_name );
     return VLC_SUCCESS;
 }
 
@@ -275,17 +248,15 @@ static void Close( vlc_object_t *p_this )
         if( p_sys->p_raw1394 )
             raw1394_iso_shutdown( p_sys->p_raw1394 );
 
-        vlc_mutex_destroy( &p_sys->p_ev->lock );
         vlc_thread_join( p_sys->p_ev );
+        vlc_mutex_destroy( &p_sys->p_ev->lock );
 
         /* Cleanup frame data */
         if( p_sys->p_ev->p_frame )
         {
-            vlc_mutex_lock( &p_sys->p_ev->lock );
             block_ChainRelease( p_sys->p_ev->p_frame );
             p_sys->p_ev->p_frame = NULL;
             p_sys->p_ev->pp_last = &p_sys->p_frame;
-            vlc_mutex_unlock( &p_sys->p_ev->lock );
         }
         vlc_object_release( p_sys->p_ev );
     }
@@ -306,33 +277,27 @@ 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;
-    bool   *pb_bool;
-    int64_t      *pi_64;
-
     switch( i_query )
     {
         /* */
         case ACCESS_CAN_PAUSE:
-            pb_bool = (bool*)va_arg( args, bool* );
-            *pb_bool = true;
+            *va_arg( args, bool* ) = true;
             break;
 
        case ACCESS_CAN_SEEK:
        case ACCESS_CAN_FASTSEEK:
        case ACCESS_CAN_CONTROL_PACE:
-            pb_bool = (bool*)va_arg( args, bool* );
-            *pb_bool = false;
+            *va_arg( args, bool* ) = false;
             break;
 
         case ACCESS_GET_PTS_DELAY:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
-            *pi_64 = (int64_t)var_GetInteger( p_access, "dv-caching" ) * 1000;
+            *va_arg( args, int64_t * )
+                   = var_GetInteger( p_access, "dv-caching" ) * 1000;
             break;
 
         /* */
         case ACCESS_SET_PAUSE_STATE:
-            AVCPause( p_access, p_sys->i_node );
+            AVCPause( p_access, p_access->p_sys->i_node );
             break;
 
         case ACCESS_GET_TITLE_INFO:
@@ -405,6 +370,8 @@ Raw1394Handler(raw1394handle_t handle, unsigned char *data,
     access_t *p_access = NULL;
     access_sys_t *p_sys = NULL;
     block_t *p_block = NULL;
+    VLC_UNUSED(channel); VLC_UNUSED(tag);
+    VLC_UNUSED(sy); VLC_UNUSED(cycle); VLC_UNUSED(dropped);
 
     p_access = (access_t *) raw1394_get_userdata( handle );
     if( !p_access ) return 0;
@@ -643,10 +610,8 @@ static int AVCPlay( access_t *p_access, int phyID )
     access_sys_t *p_sys = p_access->p_sys;
 
     msg_Dbg( p_access, "send play command over Digital Video control channel" );
-    if( !p_sys->p_avc1394 )
-        return 0;
 
-    if( phyID >= 0 )
+    if( p_sys->p_avc1394 && phyID >= 0 )
     {
         if( !avc1394_vcr_is_recording( p_sys->p_avc1394, phyID ) &&
             avc1394_vcr_is_playing( p_sys->p_avc1394, phyID ) != AVC1394_VCR_OPERAND_PLAY_FORWARD )
@@ -659,10 +624,7 @@ static int AVCPause( access_t *p_access, int phyID )
 {
     access_sys_t *p_sys = p_access->p_sys;
 
-    if( !p_sys->p_avc1394 )
-        return 0;
-
-    if( phyID >= 0 )
+    if( p_sys->p_avc1394 && phyID >= 0 )
     {
         if( !avc1394_vcr_is_recording( p_sys->p_avc1394, phyID ) &&
             ( avc1394_vcr_is_playing( p_sys->p_avc1394, phyID ) != AVC1394_VCR_OPERAND_PLAY_FORWARD_PAUSE ) )
@@ -677,10 +639,8 @@ static int AVCStop( access_t *p_access, int phyID )
     access_sys_t *p_sys = p_access->p_sys;
 
     msg_Dbg( p_access, "closing Digital Video control channel" );
-    if( !p_sys->p_avc1394 )
-        return 0;
 
-    if ( phyID >= 0 )
+    if ( p_sys->p_avc1394 && phyID >= 0 )
         avc1394_vcr_stop( p_sys->p_avc1394, phyID );
 
     return 0;