]> git.sesse.net Git - vlc/blobdiff - modules/access/dv.c
Merge commit 'origin/base'
[vlc] / modules / access / dv.c
index 570ec5ed76a223eb818d7d5b96aee3d1ad8a50ab..fe4dfa74ff6bae561fa21ecea5bf417b71198389 100644 (file)
@@ -16,9 +16,9 @@
  * 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.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -70,21 +70,22 @@ static int Control( access_t *, int, va_list );
 
 #define CACHING_TEXT N_("Caching value in ms")
 #define CACHING_LONGTEXT N_( \
-    "Caching value for DV streams. This" \
+    "Caching value for DV streams. This " \
     "value should be set in milliseconds." )
 
-vlc_module_begin();
-    set_description( N_("Digital Video (Firewire/ieee1394)  input") );
-    set_shortname( N_("dv") );
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_ACCESS );
-    add_integer( "dv-caching", 60000 / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, true );
-    set_capability( "access", 0 );
-    add_shortcut( "dv" );
-    add_shortcut( "dv1394" );
-    add_shortcut( "raw1394" );
-    set_callbacks( Open, Close );
-vlc_module_end();
+vlc_module_begin ()
+    set_description( N_("Digital Video (Firewire/ieee1394)  input") )
+    set_shortname( N_("DV") )
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_ACCESS )
+    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" )
+    set_callbacks( Open, Close )
+vlc_module_end ()
 
 typedef struct
 {
@@ -147,7 +148,6 @@ static int Open( vlc_object_t *p_this )
     /* Set up p_access */
     access_InitFields( p_access );
     ACCESS_SET_CALLBACKS( NULL, Block, Control, NULL );
-    p_access->info.b_prebuffered = false;
 
     p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
     if( !p_sys )
@@ -232,13 +232,13 @@ static int Open( vlc_object_t *p_this )
         free( psz_name );
         return VLC_EGENERIC;
     }
+
     p_sys->p_ev->p_frame = NULL;
     p_sys->p_ev->pp_last = &p_sys->p_ev->p_frame;
     p_sys->p_ev->p_access = p_access;
     vlc_mutex_init( &p_sys->p_ev->lock );
-    vlc_thread_create( p_sys->p_ev, "dv event thread handler", Raw1394EventThread,
-                       VLC_THREAD_PRIORITY_OUTPUT, false );
+    vlc_thread_create( p_sys->p_ev, "dv event thread handler",
+                       Raw1394EventThread, VLC_THREAD_PRIORITY_OUTPUT );
 
     free( psz_name );
     return VLC_SUCCESS;
@@ -312,7 +312,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
 
         case ACCESS_GET_PTS_DELAY:
             pi_64 = (int64_t*)va_arg( args, int64_t * );
-            *pi_64 = var_GetInteger( p_access, "dv-caching" ) * 1000;
+            *pi_64 = (int64_t)var_GetInteger( p_access, "dv-caching" ) * 1000;
             break;
 
         /* */
@@ -340,14 +340,6 @@ static block_t *Block( access_t *p_access )
     access_sys_t *p_sys = p_access->p_sys;
     block_t *p_block = NULL;
 
-#if 0
-    if( !p_access->psz_demux )
-    {
-        free( p_access->psz_demux );
-        p_access->psz_demux = strdup( "rawdv" );
-    }
-#endif
-
     vlc_mutex_lock( &p_sys->lock );
     p_block = p_sys->p_frame;
     //msg_Dbg( p_access, "sending frame %p",p_block );
@@ -363,11 +355,10 @@ static void* Raw1394EventThread( vlc_object_t *p_this )
     access_t *p_access = (access_t *) p_ev->p_access;
     access_sys_t *p_sys = (access_sys_t *) p_access->p_sys;
     int result = 0;
+    int canc = vlc_savecancel ();
 
     AVCPlay( p_access, p_sys->i_node );
 
-    vlc_thread_ready( p_this );
-
     while( vlc_object_alive (p_sys->p_ev) )
     {
         while( ( result = poll( &(p_sys->raw1394_poll), 1, 200 ) ) < 0 )
@@ -386,6 +377,7 @@ static void* Raw1394EventThread( vlc_object_t *p_this )
     }
 
     AVCStop( p_access, p_sys->i_node );
+    vlc_restorecancel (canc);
     return NULL;
 }
 
@@ -401,7 +393,7 @@ static int Raw1394Handler( raw1394handle_t handle, int channel, size_t length, q
     p_sys = p_access->p_sys;
 
     /* skip empty packets */
-    if ( length > 16 )
+    if( length > 16 )
     {
         unsigned char * p = ( unsigned char* ) &data[ 3 ];
         int section_type = p[ 0 ] >> 5;           /* section type is in bits 5 - 7 */
@@ -476,15 +468,15 @@ static int Raw1394GetNumPorts( access_t *p_access )
     raw1394handle_t handle;
 
     /* get a raw1394 handle */
-    if ( !( handle = raw1394_new_handle() ) )
+    if( !( handle = raw1394_new_handle() ) )
     {
         msg_Err( p_access, "raw1394 - failed to get handle: %m." );
         return VLC_EGENERIC;
     }
 
-    if ( ( n_ports = raw1394_get_port_info( handle, pinf, 16 ) ) < 0 )
+    if( ( n_ports = raw1394_get_port_info( handle, pinf, 16 ) ) < 0 )
     {
-        msg_Err( p_access, "raw1394 - failed to get port info: %m.\n" );
+        msg_Err( p_access, "raw1394 - failed to get port info: %m." );
         raw1394_destroy_handle( handle );
         return VLC_EGENERIC;
     }
@@ -500,21 +492,14 @@ static raw1394handle_t Raw1394Open( access_t *p_access, int port )
     raw1394handle_t handle;
 
     /* get a raw1394 handle */
-#ifdef RAW1394_V_0_8
-
-    handle = raw1394_get_handle();
-#else
-
     handle = raw1394_new_handle();
-#endif
-
-    if ( !handle )
+    if( !handle )
     {
         msg_Err( p_access, "raw1394 - failed to get handle: %m." );
         return NULL;
     }
 
-    if ( ( n_ports = raw1394_get_port_info( handle, pinf, 16 ) ) < 0 )
+    if( ( n_ports = raw1394_get_port_info( handle, pinf, 16 ) ) < 0 )
     {
         msg_Err( p_access, "raw1394 - failed to get port info: %m." );
         raw1394_destroy_handle( handle );
@@ -522,7 +507,7 @@ static raw1394handle_t Raw1394Open( access_t *p_access, int port )
     }
 
     /* tell raw1394 which host adapter to use */
-    if ( raw1394_set_port( handle, port ) < 0 )
+    if( raw1394_set_port( handle, port ) < 0 )
     {
         msg_Err( p_access, "raw1394 - failed to set set port: %m." );
         return NULL;
@@ -574,7 +559,7 @@ static int DiscoverAVC( access_t *p_access, int* port, uint64_t guid )
                 /* select first AV/C Tape Reccorder Player node */
                 if( rom1394_get_directory( handle, i, &rom_dir ) < 0 )
                 {
-                    msg_Err( p_access, "error reading config rom directory for node %d\n", i );
+                    msg_Err( p_access, "error reading config rom directory for node %d", i );
                     continue;
                 }
                 if( ( rom1394_get_node_type( &rom_dir ) == ROM1394_NODE_TYPE_AVC ) &&
@@ -598,8 +583,8 @@ static int DiscoverAVC( access_t *p_access, int* port, uint64_t guid )
 static raw1394handle_t AVCOpen( access_t *p_access, int port )
 {
     access_sys_t *p_sys = p_access->p_sys;
-    int numcards;
     struct raw1394_portinfo pinf[ 16 ];
+    int numcards;
 
     p_sys->p_avc1394 = raw1394_new_handle();
     if( !p_sys->p_avc1394 )
@@ -627,7 +612,6 @@ static void AVCClose( access_t *p_access )
     }
 }
 
-
 static int AVCResetHandler( raw1394handle_t handle, unsigned int generation )
 {
     raw1394_update_generation( handle, generation );