[vlc-devel] [PATCH] V4L2: Allow device to be specified with option.

Thierry Reding thierry.reding at avionic-design.de
Wed Apr 20 10:44:29 CEST 2011


* Rémi Denis-Courmont wrote:
>    Hello,
> 
> On Wednesday 20 April 2011, Thierry Reding wrote:
> > Currently the V4L2 device to be used can only be set via the media URL.
> > This patch allows the :v4l2-dev option to set the device as well.
> > Setting the device via the media URL still takes precedence.
> > 
> > This is useful if a program auto-detects the V4L2 device so that the
> > media URL only needs to contain e.g. the tuner settings.
> > ---
> >  modules/access/v4l2.c |    5 +++--
> >  1 files changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/modules/access/v4l2.c b/modules/access/v4l2.c
> > index bae9d0d..49d694b 100644
> > --- a/modules/access/v4l2.c
> > +++ b/modules/access/v4l2.c
> > @@ -705,6 +705,8 @@ static int DemuxOpen( vlc_object_t *p_this )
> >  
> > **************************************************************************
> > ***/ static void GetV4L2Params( demux_sys_t *p_sys, vlc_object_t *p_obj ) {
> > +    p_sys->psz_device = var_CreateGetNonEmptyString( p_obj, "v4l2-dev" );
> > +
> >      p_sys->i_selected_standard_id =
> >          i_standards_list[var_CreateGetInteger( p_obj, "v4l2-standard" )];
> > 
> > @@ -743,7 +745,6 @@ static void GetV4L2Params( demux_sys_t *p_sys,
> > vlc_object_t *p_obj ) }
> >      free( psz_aspect );
> > 
> > -    p_sys->psz_device = NULL;
> >      p_sys->i_fd = -1;
> > 
> >      p_sys->p_es = NULL;
> > @@ -1002,7 +1003,7 @@ static void ParseMRL( demux_sys_t *p_sys, char
> > *psz_path, vlc_object_t *p_obj ) /* Main device */
> >      if( *psz_dup )
> >          p_sys->psz_device = strdup( psz_dup );
> > -    else
> > +    else if( p_sys->psz_device == NULL )
> >          p_sys->psz_device = strdup( V4L2_DEFAULT );
> 
> I guess there is a memory leak here.

Nothing that hasn't been there before. Although looking at it more closely,
p_sys->psz_device is free()'d in CommonClose(), so that is not a leak. However
it seems like an additional strdup() is required after the call to
var_CreateGetNonEmptyString(), otherwise the variable's value will be free()'d
twice. Then again I haven't seen any crashes.

Am I overlooking something?

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20110420/34283567/attachment.sig>


More information about the vlc-devel mailing list