]> git.sesse.net Git - vlc/blobdiff - modules/access/dv.c
Removes trailing spaces. Removes tabs.
[vlc] / modules / access / dv.c
index 5a3dda1cfe455b2c4368a850c29303370c134351..3f94f8d839256cf06032470195db9e8e65f1f4e1 100644 (file)
@@ -2,7 +2,7 @@
  * dv.c: Digital video/Firewire input (file: access plug-in)
  *****************************************************************************
  * Copyright (C) 2005 M2X
- * $Id: dv.c 12318 2005-08-21 17:46:48Z jpsaman $
+ * $Id$
  *
  * Authors: Jean-Paul Saman <jpsaman at m2x dot nl>
  *
  *
  * 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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include <vlc/vlc.h>
-#include <vlc/input.h>
+#include <vlc_access.h>
 
-#include <stdlib.h>
-#include <string.h>
 #include <errno.h>
 #ifdef HAVE_SYS_TYPES_H
 #   include <sys/types.h>
@@ -67,16 +65,16 @@ static int Control( access_t *, int, va_list );
 
 #define CACHING_TEXT N_("Caching value in ms")
 #define CACHING_LONGTEXT N_( \
-    "Allows you to modify the default caching value for file streams. This " \
-    "value should be set in millisecond units." )
+    "Caching value for DV streams. This" \
+    "value should be set in milliseconds." )
 
 vlc_module_begin();
     set_description( _("Digital Video (Firewire/ieee1394)  input") );
     set_shortname( _("dv") );
     set_category( CAT_INPUT );
     set_subcategory( SUBCAT_INPUT_ACCESS );
-    add_integer( "dv-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
-    set_capability( "access2", 50 );
+    add_integer( "dv-caching", 60000 / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
+    set_capability( "access2", 0 );
     add_shortcut( "dv" );
     add_shortcut( "dv1394" );
     add_shortcut( "raw1394" );
@@ -142,17 +140,9 @@ static int Open( vlc_object_t *p_this )
     msg_Dbg( p_access, "opening device %s", psz_name );
 
     /* Set up p_access */
-    p_access->pf_read = NULL;
-    p_access->pf_block = Block;
-    p_access->pf_control = Control;
-    p_access->pf_seek = NULL;
-    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;
+    access_InitFields( p_access );
+    ACCESS_SET_CALLBACKS( NULL, Block, Control, NULL );
     p_access->info.b_prebuffered = VLC_FALSE;
-    p_access->info.i_title = 0;
-    p_access->info.i_seekpoint = 0;
 
     p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
     if( !p_sys )
@@ -169,10 +159,19 @@ static int Open( vlc_object_t *p_this )
     p_sys->p_raw1394 = NULL;
     p_sys->p_avc1394 = NULL;
     p_sys->p_frame = NULL;
+    p_sys->p_ev = NULL;
 
     vlc_mutex_init( p_access, &p_sys->lock );
 
     p_sys->i_node = DiscoverAVC( p_access, &p_sys->i_port, p_sys->i_guid );
+    if( p_sys->i_node < 0 )
+    {
+        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 )
     {
@@ -221,12 +220,20 @@ static int Open( vlc_object_t *p_this )
 
     /* Now create our event thread catcher */
     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 );
+        Close( 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_access, &p_sys->p_ev->lock );
     vlc_thread_create( p_sys->p_ev, "dv event thread handler", Raw1394EventThread,
-                       VLC_THREAD_PRIORITY_INPUT, VLC_FALSE );
+                       VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE );
 
     free( psz_name );
     return VLC_SUCCESS;
@@ -240,29 +247,32 @@ static void Close( vlc_object_t *p_this )
     access_t     *p_access = (access_t*)p_this;
     access_sys_t *p_sys = p_access->p_sys;
 
-    /* stop the event handler */
-    p_sys->p_ev->b_die = VLC_TRUE;
+    if( p_sys->p_ev )
+    {
+        /* stop the event handler */
+        vlc_object_kill( p_sys->p_ev );
 
-    if( p_sys->p_raw1394)
-        raw1394_stop_iso_rcv( p_sys->p_raw1394, p_sys->i_channel );
+        if( p_sys->p_raw1394 )
+            raw1394_stop_iso_rcv( p_sys->p_raw1394, p_sys->i_channel );
 
-    vlc_mutex_destroy( &p_sys->p_ev->lock );
-    vlc_thread_join( p_sys->p_ev );
+        vlc_mutex_destroy( &p_sys->p_ev->lock );
+        vlc_thread_join( p_sys->p_ev );
 
-    /* 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 );
+        /* 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_destroy( p_sys->p_ev );
     }
-    vlc_object_destroy( p_sys->p_ev );
 
     if( p_sys->p_frame )
         block_ChainRelease( p_sys->p_frame );
-    if( p_sys->p_raw1394)
+    if( p_sys->p_raw1394 )
         raw1394_destroy_handle( p_sys->p_raw1394 );
 
     AVCClose( p_access );
@@ -278,16 +288,19 @@ 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;
 
     switch( i_query )
     {
         /* */
-        case ACCESS_CAN_SEEK:
-        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;
+            break;
+
+       case ACCESS_CAN_SEEK:
+       case ACCESS_CAN_FASTSEEK:
+       case ACCESS_CAN_CONTROL_PACE:
             pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
             *pb_bool = VLC_FALSE;
             break;
@@ -517,7 +530,7 @@ static void Raw1394Close( raw1394handle_t handle )
 static int DiscoverAVC( access_t *p_access, int* port, uint64_t guid )
 {
     rom1394_directory rom_dir;
-    raw1394handle_t handle;
+    raw1394handle_t handle = NULL;
     int device = -1;
     int i, j = 0;
     int m = Raw1394GetNumPorts( p_access );
@@ -532,6 +545,9 @@ static int DiscoverAVC( access_t *p_access, int* port, uint64_t guid )
     for( ; j < m && device == -1; j++ )
     {
         handle = Raw1394Open( p_access, j );
+        if( !handle )
+            return -1;
+
         for( i = 0; i < raw1394_get_nodecount( handle ); ++i )
         {
             if( guid != 0 )