[vlc-devel] [PATCH] lua: renderers: Allow module name to be omitted

Hugo Beauzée-Luyssen hugo at beauzee.fr
Mon Aug 10 09:37:39 CEST 2020


On Mon, Jun 29, 2020, at 3:48 PM, Rémi Denis-Courmont wrote:
> Le maanantaina 29. kesäkuuta 2020, 12.54.12 EEST Hugo Beauzée-Luyssen a écrit 
> :
> > ---
> >  modules/lua/libs/renderers.c | 32 ++++++++++++++++++++++++++++++--
> >  1 file changed, 30 insertions(+), 2 deletions(-)
> > 
> > diff --git a/modules/lua/libs/renderers.c b/modules/lua/libs/renderers.c
> > index 822b7ad237..3e132a95a8 100644
> > --- a/modules/lua/libs/renderers.c
> > +++ b/modules/lua/libs/renderers.c
> > @@ -179,11 +179,39 @@ static int vlclua_rd_create( lua_State* L )
> >      vlc_vector_init( &sys->items );
> >      vlc_mutex_init( &sys->mutex );
> >      sys->last_renderer_id = 0;
> > +    sys->rd = NULL;
> > 
> >      vlc_object_t *this = vlclua_get_this( L );
> > -    const char* name = luaL_checkstring( L, 1 );
> > +    const char* name = lua_tostring( L, 1 );
> > +
> > +    if ( name )
> > +    {
> > +        sys->rd = vlc_rd_new( this, name, &sys->owner );
> > +    }
> > +    else
> > +    {
> > +        char** names;
> > +        char** longnames;
> > +        if ( vlc_rd_get_names( this, &names, &longnames ) != VLC_SUCCESS )
> > +        {
> > +            vlc_vector_destroy( &sys->items );
> > +            return 0;
> > +        }
> > +        int i = 0;
> > +        while ( sys->rd == NULL && names[i] != NULL )
> > +        {
> > +            sys->rd = vlc_rd_new( this, names[i], &sys->owner );
> > +            ++i;
> > +        }
> > +        for ( i = 0; names[i] != NULL; ++i )
> > +        {
> > +            free( names[i] );
> > +            free( longnames[i] );
> > +        }
> > +        free( longnames );
> > +        free( names );
> > +    }
> 
> If there are more than one renderer, that gives you whatever.
> I can't grasp in what usage scenario this would be intended.
> 
> > 
> > -    sys->rd = vlc_rd_new( this, name, &sys->owner );
> >      if ( !sys->rd )
> >      {
> >          vlc_vector_destroy( &sys->items );
> 
> 

Hi,

This is mostly to be consistent with both Qt and macOS UIs. All renderer discovery modules have expose the same functionalities but they might expose slightly different names. 
Also, I'm not sure we should require a name in this API, but that's on me since I forgot to address it before pushing.

-- 
  Hugo Beauzée-Luyssen
  hugo at beauzee.fr


More information about the vlc-devel mailing list