#include <vlc_sout.h>
#include <avahi-client/client.h>
-#ifdef HAVE_AVAHI_06
-# include <avahi-client/publish.h>
-# include <avahi-client/lookup.h>
-#endif
+#include <avahi-client/publish.h>
+#include <avahi-client/lookup.h>
#include <avahi-common/alternative.h>
#include <avahi-common/simple-watch.h>
#include <avahi-common/malloc.h>
AvahiEntryGroupState state,
void *userdata )
{
+ (void)g;
bonjour_t *p_sys = (bonjour_t *)userdata;
if( state == AVAHI_ENTRY_GROUP_ESTABLISHED )
}
error = avahi_entry_group_add_service( p_sys->group, AVAHI_IF_UNSPEC,
-#ifdef HAVE_AVAHI_06
AVAHI_PROTO_UNSPEC, 0, p_sys->psz_name,
-#else
- AVAHI_PROTO_UNSPEC, p_sys->psz_name,
-#endif
p_sys->psz_stype, NULL, NULL,
p_sys->i_port,
p_sys->psz_txt, NULL );
if( p_sys->group != NULL )
avahi_entry_group_reset( p_sys->group );
}
-#ifdef HAVE_AVAHI_06
else if( state == AVAHI_CLIENT_FAILURE &&
(avahi_client_errno(c) == AVAHI_ERR_DISCONNECTED) )
-#else
- else if( state == AVAHI_CLIENT_DISCONNECTED )
-#endif
{
msg_Err( p_sys->p_log, "avahi client disconnected" );
avahi_simple_poll_quit( p_sys->simple_poll );
/*****************************************************************************
* poll_iterate_thread
*****************************************************************************/
-static void poll_iterate_thread( poll_thread_t *p_pt )
+static void* poll_iterate_thread( vlc_object_t *p_this )
{
- vlc_thread_ready( p_pt );
+ poll_thread_t *p_pt = (poll_thread_t*)p_this;
+ int canc = vlc_savecancel ();
- while( !p_pt->b_die )
+ while( vlc_object_alive (p_pt) )
if( avahi_simple_poll_iterate( p_pt->simple_poll, 100 ) != 0 )
break;
+
+ vlc_restorecancel (canc);
+ return NULL;
}
/*****************************************************************************
const char *psz_name, int i_port, char *psz_txt )
{
int err;
- bonjour_t *p_sys;
- p_sys = (bonjour_t *)malloc( sizeof(*p_sys) );
+ bonjour_t* p_sys = calloc( 1, sizeof(*p_sys) );
if( p_sys == NULL )
return NULL;
- memset( p_sys, 0, sizeof(*p_sys) );
-
p_sys->p_log = p_log;
-
p_sys->i_port = i_port;
p_sys->psz_name = avahi_strdup( psz_name );
p_sys->psz_stype = avahi_strdup( psz_stype );
}
p_sys->client = avahi_client_new( avahi_simple_poll_get(p_sys->simple_poll),
-#ifdef HAVE_AVAHI_06
0,
-#endif
client_callback, p_sys, &err );
if( p_sys->client == NULL )
{
if( vlc_thread_create( p_sys->poll_thread, "Avahi Poll Iterate Thread",
poll_iterate_thread,
- VLC_THREAD_PRIORITY_HIGHEST, false ) )
+ VLC_THREAD_PRIORITY_HIGHEST ) )
{
msg_Err( p_sys->p_log, "failed to create poll iterate thread" );
goto error;
if( p_sys->psz_txt != NULL )
avahi_free( p_sys->psz_txt );
- free( (void *)p_sys );
+ free( p_sys );
return NULL;
}