[vlc-devel] [PATCH] avahi: remove AvahiServiceBrowser from sys
Petri Hintukainen
phintuka at gmail.com
Tue Mar 8 10:46:25 CET 2016
Only last created service browser was stored.
avahi_client_free() should free also all service browsers.
---
modules/services_discovery/avahi.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/modules/services_discovery/avahi.c b/modules/services_discovery/avahi.c
index ee91afd..cff96de 100644
--- a/modules/services_discovery/avahi.c
+++ b/modules/services_discovery/avahi.c
@@ -71,7 +71,6 @@ struct services_discovery_sys_t
{
AvahiThreadedPoll *poll;
AvahiClient *client;
- AvahiServiceBrowser *sb;
vlc_dictionary_t services_name_to_input_item;
};
@@ -232,6 +231,7 @@ static void browse_callback(
VLC_UNUSED(flags);
services_discovery_t *p_sd = ( services_discovery_t* )userdata;
services_discovery_sys_t *p_sys = p_sd->p_sys;
+fprintf(stderr, "AVAHI: %s %s %s\n", name, type, domain);
if( event == AVAHI_BROWSER_NEW )
{
if( avahi_service_resolver_new( p_sys->client, interface, protocol,
@@ -295,11 +295,12 @@ static int Open( vlc_object_t *p_this )
for( unsigned i = 0; i < NB_PROTOCOLS; i++ )
{
- p_sys->sb = avahi_service_browser_new( p_sys->client, AVAHI_IF_UNSPEC,
+ AvahiServiceBrowser *sb;
+ sb = avahi_service_browser_new( p_sys->client, AVAHI_IF_UNSPEC,
AVAHI_PROTO_UNSPEC,
protocols[i].psz_service_name, NULL,
0, browse_callback, p_sd );
- if( p_sys->sb == NULL )
+ if( sb == NULL )
{
msg_Err( p_sd, "failed to create avahi service browser %s", avahi_strerror( avahi_client_errno(p_sys->client) ) );
goto error;
@@ -311,8 +312,6 @@ static int Open( vlc_object_t *p_this )
return VLC_SUCCESS;
error:
- if( p_sys->sb != NULL )
- avahi_service_browser_free( p_sys->sb );
if( p_sys->client != NULL )
avahi_client_free( p_sys->client );
if( p_sys->poll != NULL )
@@ -336,7 +335,6 @@ static void Close( vlc_object_t *p_this )
services_discovery_sys_t *p_sys = p_sd->p_sys;
avahi_threaded_poll_stop( p_sys->poll );
- avahi_service_browser_free( p_sys->sb );
avahi_client_free( p_sys->client );
avahi_threaded_poll_free( p_sys->poll );
--
2.5.0
More information about the vlc-devel
mailing list