X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fdv.c;h=b23d6fd908be990b307ee10243a7859bdb59dee9;hb=e4990aba70777b8382f0b0392c02c798d35885ad;hp=fe4dfa74ff6bae561fa21ecea5bf417b71198389;hpb=048c897eb3fa413455846ab5b74ca970f6f6d402;p=vlc diff --git a/modules/access/dv.c b/modules/access/dv.c index fe4dfa74ff..b23d6fd908 100644 --- a/modules/access/dv.c +++ b/modules/access/dv.c @@ -99,7 +99,11 @@ typedef struct } event_thread_t; static void* Raw1394EventThread( vlc_object_t * ); -static int Raw1394Handler( raw1394handle_t, int, size_t, quadlet_t * ); +static enum raw1394_iso_disposition +Raw1394Handler(raw1394handle_t, unsigned char *, + unsigned int, unsigned char, + unsigned char, unsigned char, unsigned int, + unsigned int); static int Raw1394GetNumPorts( access_t *p_access ); static raw1394handle_t Raw1394Open( access_t *, int ); @@ -131,6 +135,9 @@ struct access_sys_t block_t *p_frame; }; +#define ISOCHRONOUS_QUEUE_LENGTH 1000 +#define ISOCHRONOUS_MAX_PACKET_SIZE 4096 + /***************************************************************************** * Open: open the file *****************************************************************************/ @@ -141,7 +148,6 @@ static int Open( vlc_object_t *p_this ) char *psz_name = strdup( p_access->psz_path ); struct raw1394_portinfo port_inf[ 16 ]; - iso_handler_t oldhandler; msg_Dbg( p_access, "opening device %s", psz_name ); @@ -212,10 +218,18 @@ static int Open( vlc_object_t *p_this ) return VLC_EGENERIC; } - oldhandler = raw1394_set_iso_handler( p_sys->p_raw1394, - p_sys->i_channel, Raw1394Handler ); + if ( raw1394_iso_recv_init( p_sys->p_raw1394, Raw1394Handler, + 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 ); + Close( p_this ); + free( psz_name ); + return VLC_EGENERIC; + } + raw1394_set_userdata( p_sys->p_raw1394, p_access ); - raw1394_start_iso_rcv( p_sys->p_raw1394, p_sys->i_channel ); + raw1394_iso_recv_start( p_sys->p_raw1394, -1, -1, 0 ); p_sys->raw1394_poll.fd = raw1394_get_fd( p_sys->p_raw1394 ); p_sys->raw1394_poll.events = POLLIN | POLLPRI; @@ -258,19 +272,17 @@ static void Close( vlc_object_t *p_this ) vlc_object_kill( p_sys->p_ev ); if( p_sys->p_raw1394 ) - raw1394_stop_iso_rcv( p_sys->p_raw1394, p_sys->i_channel ); + 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 ); } @@ -291,33 +303,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 * ) + = (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: @@ -381,11 +387,17 @@ static void* Raw1394EventThread( vlc_object_t *p_this ) return NULL; } -static int Raw1394Handler( raw1394handle_t handle, int channel, size_t length, quadlet_t *data ) +static enum raw1394_iso_disposition +Raw1394Handler(raw1394handle_t handle, unsigned char *data, + unsigned int length, unsigned char channel, + unsigned char tag, unsigned char sy, unsigned int cycle, + unsigned int dropped) { 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; @@ -395,7 +407,7 @@ static int Raw1394Handler( raw1394handle_t handle, int channel, size_t length, q /* skip empty packets */ if( length > 16 ) { - unsigned char * p = ( unsigned char* ) &data[ 3 ]; + unsigned char * p = data + 8; int section_type = p[ 0 ] >> 5; /* section type is in bits 5 - 7 */ int dif_sequence = p[ 1 ] >> 4; /* dif sequence number is in bits 4 - 7 */ int dif_block = p[ 2 ]; @@ -451,6 +463,7 @@ static int Raw1394Handler( raw1394handle_t handle, int channel, size_t length, q break; } } + vlc_mutex_unlock( &p_sys->p_ev->lock ); } return 0; @@ -623,10 +636,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 ) @@ -639,10 +650,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 ) ) @@ -657,10 +665,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;