[vlc-devel] [PATCH 3/4] avahi: Prepare code for support of renderer discovery

Rémi Denis-Courmont remi at remlab.net
Thu Jan 3 18:49:55 CET 2019


Le perjantaina 28. joulukuuta 2018, 17.33.16 EET Stefan Brüns a écrit :
> On Mittwoch, 26. Dezember 2018 09:03:58 CET you wrote:
> > Le mercredi 26 décembre 2018, 04:21:42 EET Stefan Brüns a écrit :
> > > Instead of passing the services_discovery_t as userdata for the
> > > callbacks,
> > > use a struct (discovery_sys_t) which can be used regardless of the
> > > service
> > > type (input or renderer).
> > > ---
> > > 
> > >  modules/services_discovery/avahi.c | 83 ++++++++++++++++++------------
> > >  1 file changed, 50 insertions(+), 33 deletions(-)
> > > 
> > > diff --git a/modules/services_discovery/avahi.c
> > > b/modules/services_discovery/ avahi.c
> > > index aa58c7f673..1ea60ab152 100644
> > > --- a/modules/services_discovery/avahi.c
> > > +++ b/modules/services_discovery/avahi.c
> > > @@ -46,8 +46,8 @@
> > > 
> > > ************************************************************************
> > > **
> > > *
> > > **/
> > > 
> > >  /* Callbacks */
> > > 
> > > -static int  Open ( vlc_object_t * );
> > > -static void Close( vlc_object_t * );
> > > +static int  OpenSD ( vlc_object_t * );
> > > +static void CloseSD( vlc_object_t * );
> > > 
> > >  VLC_SD_PROBE_HELPER("avahi", N_("Zeroconf network services"),
> > >  SD_CAT_LAN)
> > > 
> > > @@ -57,7 +57,7 @@ vlc_module_begin ()
> > > 
> > >      set_category( CAT_PLAYLIST )
> > >      set_subcategory( SUBCAT_PLAYLIST_SD )
> > >      set_capability( "services_discovery", 0 )
> > > 
> > > -    set_callbacks( Open, Close )
> > > +    set_callbacks( OpenSD, CloseSD )
> > > 
> > >      add_shortcut( "mdns", "avahi" )
> > >      
> > >      VLC_SD_PROBE_SUBMODULE
> > > 
> > > @@ -72,7 +72,14 @@ typedef struct
> > > 
> > >      AvahiThreadedPoll   *poll;
> > >      AvahiClient         *client;
> > >      vlc_dictionary_t    services_name_to_input_item;
> > > 
> > > -} services_discovery_sys_t;
> > > +    vlc_object_t        *parent;
> > > +    bool                renderer;
> > > +} discovery_sys_t;
> > > +
> > > +struct services_discovery_sys_t
> > > +{
> > > +    discovery_sys_t s;
> > > +};
> > 
> > Uh, should there not be some SD-specific members there?
> 
> vlc_renderer_discovery_t and services_discovery_t both have a private data
> pointer called p_sys. Unfortunately, one has the type
> services_discovery_sys_t and the other one is vlc_renderer_discovery_t.
> 
> To avoid crosscasting the common userdata struct required for the avahi
> callbacks, the struct is embedded into both structs.

If that's your problem, you can convert the (p_)sys fields to void pointers in 
the common headers.

I just find it suspicious that the content of both compound types is exactly 
the same.

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





More information about the vlc-devel mailing list