[vlc-devel] [PATCH] dv.c raw1394 new API fixes

Jean-Paul Saman jpsaman at videolan.org
Sat Jun 13 17:37:41 CEST 2009


Thanks for this patch.

Since the old raw1394 has a big security hole in it I intended to drop 
the support for anything older then 2.0.1 so forcing the use of the 
newer API.

Please adapt your patch for this.

Francois Cartegnie wrote:
> ---
>  configure.ac        |    1 +
>  modules/access/dv.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++--
>  2 files changed, 49 insertions(+), 2 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 7ecf0bc..4e650d6 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -2066,6 +2066,7 @@ then
>    PKG_CHECK_MODULES(LIBRAW1394, libraw1394 >= 2.0.1,
>      [
>        VLC_ADD_LIBS([access_dv],[`${PKG_CONFIG} --libs libraw1394`])
> +      AC_DEFINE_UNQUOTED(LIBRAW1394_VERSION,`${PKG_CONFIG} --modversion libraw1394 | tr -d .`, [check version for deprecated API])

No need to check for depreceated API just AC_MSG_ERROR instead.

>        VLC_ADD_CPPFLAGS([access_dv],[`${PKG_CONFIG} --cflags libraw1394`])
>      ],
>      [AC_MSG_ERROR([Couldn't find libraw1394 >= 2.0.1, install libraw1394 development package])]
> diff --git a/modules/access/dv.c b/modules/access/dv.c
> index fe4dfa7..59bd3d3 100644
> --- a/modules/access/dv.c
> +++ b/modules/access/dv.c
> @@ -60,6 +60,10 @@
>  #include <libavc1394/avc1394_vcr.h>
>  #include <libavc1394/rom1394.h>
>  
> +#ifndef LIBRAW1394_VERSION
> +#define LIBRAW1394_VERSION 201
> +#endif
Remove this.

> +
>  /*****************************************************************************
>   * Module descriptor
>   *****************************************************************************/
> @@ -99,7 +103,16 @@ typedef struct
>  } event_thread_t;
>  
>  static void* Raw1394EventThread( vlc_object_t * );
> +
> +#if LIBRAW1394_VERSION < 200
>  static int Raw1394Handler( raw1394handle_t, int, size_t, quadlet_t * );

Do not check for older API. It makes to code easier to read.

Same comment holds for all "+#if LIBRAW1394_VERSION < 200" below.'

> +#else
> +static enum raw1394_iso_disposition
> +Raw1394Handler(raw1394handle_t, unsigned char *,
> +        unsigned int, unsigned char,
> +        unsigned char, unsigned char, unsigned int,
> +        unsigned int);
> +#endif
>  
>  static int Raw1394GetNumPorts( access_t *p_access );
>  static raw1394handle_t Raw1394Open( access_t *, int );
> @@ -141,7 +154,11 @@ static int Open( vlc_object_t *p_this )
>      char *psz_name = strdup( p_access->psz_path );
>  
>      struct raw1394_portinfo port_inf[ 16 ];
> +#if LIBRAW1394_VERSION < 200
>      iso_handler_t oldhandler;
> +#else
> +    raw1394_iso_recv_handler_t handler;
> +#endif
>  
>      msg_Dbg( p_access, "opening device %s", psz_name );
>  
> @@ -212,10 +229,21 @@ static int Open( vlc_object_t *p_this )
>          return VLC_EGENERIC;
>      }
>  
> +#if LIBRAW1394_VERSION < 200
>      oldhandler = raw1394_set_iso_handler( p_sys->p_raw1394,
>                                            p_sys->i_channel, Raw1394Handler );
> +#else
> +    raw1394_iso_recv_init( p_sys->p_raw1394, Raw1394Handler, 1000, 4096,
> +                           p_sys->i_channel, RAW1394_DMA_PACKET_PER_BUFFER, -1 );
> +#endif
> +
>      raw1394_set_userdata( p_sys->p_raw1394, p_access );
> +
> +#if LIBRAW1394_VERSION < 200
>      raw1394_start_iso_rcv( p_sys->p_raw1394, p_sys->i_channel );
> +#else
> +    raw1394_iso_recv_start( p_sys->p_raw1394, -1, -1, 0 );
> +#endif
>  
>      p_sys->raw1394_poll.fd = raw1394_get_fd( p_sys->p_raw1394 );
>      p_sys->raw1394_poll.events = POLLIN | POLLPRI;
> @@ -258,7 +286,11 @@ static void Close( vlc_object_t *p_this )
>          vlc_object_kill( p_sys->p_ev );
>  
>          if( p_sys->p_raw1394 )
> +#if LIBRAW1394_VERSION < 200
>              raw1394_stop_iso_rcv( p_sys->p_raw1394, p_sys->i_channel );
> +#else
> +            raw1394_iso_shutdown( p_sys->p_raw1394 );
> +#endif
>  
>          vlc_mutex_destroy( &p_sys->p_ev->lock );
>          vlc_thread_join( p_sys->p_ev );
> @@ -372,8 +404,9 @@ static void* Raw1394EventThread( vlc_object_t *p_this )
>          if( !vlc_object_alive (p_sys->p_ev) )
>                  break;
>          if( result > 0 && ( ( p_sys->raw1394_poll.revents & POLLIN )
> -                || ( p_sys->raw1394_poll.revents & POLLPRI ) ) )
> -            result = raw1394_loop_iterate( p_sys->p_raw1394 );
> +                || ( p_sys->raw1394_poll.revents & POLLPRI ) ) ){
> +            msg_Err( p_access, "iterate" );
> +            result = raw1394_loop_iterate( p_sys->p_raw1394 );}
>      }
>  
>      AVCStop( p_access, p_sys->i_node );
> @@ -381,7 +414,15 @@ static void* Raw1394EventThread( vlc_object_t *p_this )
>      return NULL;
>  }
>  
> +#if LIBRAW1394_VERSION < 200
>  static int Raw1394Handler( raw1394handle_t handle, int channel, size_t length, quadlet_t *data )
> +#else
> +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)
> +#endif
>  {
>      access_t *p_access = NULL;
>      access_sys_t *p_sys = NULL;
> @@ -395,7 +436,11 @@ static int Raw1394Handler( raw1394handle_t handle, int channel, size_t length, q
>      /* skip empty packets */
>      if( length > 16 )
>      {
> +#if LIBRAW1394_VERSION < 200
>          unsigned char * p = ( unsigned char* ) &data[ 3 ];
> +#else
> +        unsigned char * p = data + 8;
> +#endif
>          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 +496,7 @@ static int Raw1394Handler( raw1394handle_t handle, int channel, size_t length, q
>                  break;
>              }
>          }
> +
>          vlc_mutex_unlock( &p_sys->p_ev->lock );
>      }
>      return 0;

For the rest this looks OK.

Thanks,
Jean-Paul Saman.



More information about the vlc-devel mailing list