[vlc-devel] [RFC PATCH 03/10] playlist: Add playlist_SetRenderer

Rémi Denis-Courmont remi at remlab.net
Thu Sep 7 19:26:03 CEST 2017


Le torstaina 7. syyskuuta 2017, 19.19.07 EEST Hugo Beauzée-Luyssen a écrit :
> On Thu, Sep 7, 2017, at 04:53 PM, Rémi Denis-Courmont wrote:
> > Le torstaina 7. syyskuuta 2017, 15.45.59 EEST Hugo Beauzée-Luyssen a
> > 
> > écrit :
> > > ---
> > > 
> > >  include/vlc_playlist.h           |  8 +++++++
> > >  src/Makefile.am                  |  1 +
> > >  src/libvlccore.sym               |  1 +
> > >  src/playlist/engine.c            |  3 +++
> > >  src/playlist/playlist_internal.h |  1 +
> > >  src/playlist/renderer.c          | 50
> > > 
> > > ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 64
> > > insertions(+)
> > > 
> > >  create mode 100644 src/playlist/renderer.c
> > > 
> > > diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
> > > index b320e98b50..b74d9b3e55 100644
> > > --- a/include/vlc_playlist.h
> > > +++ b/include/vlc_playlist.h
> > > @@ -358,6 +358,14 @@ VLC_API bool playlist_IsServicesDiscoveryLoaded(
> > > playlist_t *,const char *) VLC_ /** Query a services discovery */
> > > 
> > >  VLC_API int playlist_ServicesDiscoveryControl( playlist_t *, const char
> > >  *,
> > > 
> > > int, ... );
> > > 
> > > +/********************** Renderer ***********************/
> > > +/**
> > > + * Sets a renderer or remove the current one
> > > + * @param p_item    The renderer item to be used, or NULL to disable
> > > the
> > > current + *                  one. If a renderer is provided, its
> > > reference
> > > count will be + *                  incremented.
> > > + */
> > > +VLC_API int playlist_SetRenderer( playlist_t* p_pl,
> > > vlc_renderer_item_t*
> > > p_item );
> > > 
> > >  /********************************************************
> > > 
> > > diff --git a/src/Makefile.am b/src/Makefile.am
> > > index 512ee10bf7..9712483bb8 100644
> > > --- a/src/Makefile.am
> > > +++ b/src/Makefile.am
> > > @@ -225,6 +225,7 @@ libvlccore_la_SOURCES = \
> > > 
> > >  	playlist/item.c \
> > >  	playlist/search.c \
> > >  	playlist/services_discovery.c \
> > > 
> > > +	playlist/renderer.c \
> > > 
> > >  	input/item.c \
> > >  	input/access.c \
> > >  	input/clock.c \
> > > 
> > > diff --git a/src/libvlccore.sym b/src/libvlccore.sym
> > > index 929a6dcc1f..4f0bf20dbc 100644
> > > --- a/src/libvlccore.sym
> > > +++ b/src/libvlccore.sym
> > > @@ -362,6 +362,7 @@ playlist_VolumeSet
> > > 
> > >  playlist_VolumeUp
> > >  playlist_MuteSet
> > >  playlist_MuteGet
> > > 
> > > +playlist_SetRenderer
> > > 
> > >  sdp_AddAttribute
> > >  sdp_AddMedia
> > >  secstotimestr
> > > 
> > > diff --git a/src/playlist/engine.c b/src/playlist/engine.c
> > > index 0b0c82ee92..680366cd09 100644
> > > --- a/src/playlist/engine.c
> > > +++ b/src/playlist/engine.c
> > > @@ -34,6 +34,7 @@
> > > 
> > >  #include <vlc_playlist.h>
> > >  #include <vlc_interface.h>
> > >  #include <vlc_http.h>
> > > 
> > > +#include <vlc_renderer_discovery.h>
> > > 
> > >  #include "playlist_internal.h"
> > >  #include "input/resource.h"
> > > 
> > > @@ -310,6 +311,8 @@ void playlist_Destroy( playlist_t *p_playlist )
> > > 
> > >      /* Release input resources */
> > >      assert( p_sys->p_input == NULL );
> > >      input_resource_Release( p_sys->p_input_resource );
> > > 
> > > +    if( p_sys->p_renderer )
> > > +        vlc_renderer_item_release( p_sys->p_renderer );
> > > 
> > >      if( p_playlist->p_media_library != NULL )
> > >      
> > >          playlist_MLDump( p_playlist );
> > > 
> > > diff --git a/src/playlist/playlist_internal.h
> > > b/src/playlist/playlist_internal.h index ed40679f8f..3515a898bd 100644
> > > --- a/src/playlist/playlist_internal.h
> > > +++ b/src/playlist/playlist_internal.h
> > > @@ -58,6 +58,7 @@ typedef struct playlist_private_t
> > > 
> > >      input_thread_t *      p_input;  /**< the input thread associated
> > >      
> > >                                       * with the current item */
> > >      
> > >      input_resource_t *   p_input_resource; /**< input resources */
> > > 
> > > +    vlc_renderer_item_t *p_renderer;
> > > 
> > >      struct {
> > >      
> > >          /* Current status. These fields are readonly, only the playlist
> > >          
> > >           * main loop can touch it*/
> > > 
> > > diff --git a/src/playlist/renderer.c b/src/playlist/renderer.c
> > > new file mode 100644
> > > index 0000000000..eb1da914a7
> > > --- /dev/null
> > > +++ b/src/playlist/renderer.c
> > > @@ -0,0 +1,50 @@
> > > +/**********************************************************************
> > > **** *** + * renderer.c : Manage renderer modules
> > > +
> > > ************************************************************************
> > > ***
> > > ** + * Copyright (C) 1999-2017 VLC authors, VideoLAN and VideoLabs
> > > + *
> > > + * Authors: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
> > > + *
> > > + * This program is free software; you can redistribute it and/or modify
> > > it
> > > + * under the terms of the GNU Lesser General Public License as
> > > published by + * the Free Software Foundation; either version 2.1 of
> > > the License, or + * (at your option) any later version.
> > > + *
> > > + * This program is distributed in the hope that it will be useful,
> > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > > + * GNU Lesser General Public License for more details.
> > > + *
> > > + * You should have received a copy of the GNU Lesser General Public
> > > License + * along with this program; if not, write to the Free Software
> > > Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA
> > > 02110-1301, USA. +
> > > ***********************************************************************
> > > **** **/ +
> > > +#ifdef HAVE_CONFIG_H
> > > +# include "config.h"
> > > +#endif
> > > +
> > > +#include <vlc_common.h>
> > > +#include <vlc_playlist.h>
> > > +#include <vlc_renderer_discovery.h>
> > > +
> > > +#include "playlist/playlist_internal.h"
> > > +
> > > +int playlist_SetRenderer( playlist_t* p_playlist, vlc_renderer_item_t*
> > > p_item ) +{
> > > +    PL_LOCK;
> > > +
> > > +    playlist_private_t* p_priv = pl_priv( p_playlist );
> > > +    if( p_priv->p_renderer )
> > > +        vlc_renderer_item_release( p_priv->p_renderer );
> > 
> > Can be moved out of contention.
> 
> I disagree on this specific one, moving it out of the locked scope
> wouldn't guaranty that the item wasn't decremented when using it in
> input_Create. However the implementation in those patchset was already
> racy, but it should be fixed now.

I don´t understand what you mean. If you can increment the reference before 
lock, why couldn´t symmetrically you decrease the reference after unlock?

-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list