]> git.sesse.net Git - vlc/blobdiff - modules/access_output/bonjour.c
Small fix for DVD menus.
[vlc] / modules / access_output / bonjour.c
index 40374ab1f81019cb9c2908da7d011efd3c2c4728..d02240b3e3497af3b4a4eae14ce95b3827ec06ba 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>
 
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include "bonjour.h"
 
 #ifdef HAVE_AVAHI_CLIENT
-#include <vlc/intf.h>
-#include <vlc/sout.h>
+#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-common/alternative.h>
 #include <avahi-common/simple-watch.h>
 #include <avahi-common/malloc.h>
@@ -114,7 +121,11 @@ static int create_service( bonjour_t *p_sys )
     }
 
     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 );
@@ -155,7 +166,12 @@ static void client_callback( AvahiClient *c,
         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 );
@@ -177,8 +193,8 @@ static void poll_iterate_thread( poll_thread_t *p_pt )
 /*****************************************************************************
  * bonjour_start_service
  *****************************************************************************/
-void *bonjour_start_service( vlc_object_t *p_log, char *psz_stype,
-                            char *psz_name, int i_port, char *psz_txt )
+void *bonjour_start_service( vlc_object_t *p_log, const char *psz_stype,
+                             const char *psz_name, int i_port, char *psz_txt )
 {
     int err;
     bonjour_t *p_sys;
@@ -221,6 +237,9 @@ void *bonjour_start_service( vlc_object_t *p_log, char *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 )
     {
@@ -240,7 +259,7 @@ void *bonjour_start_service( vlc_object_t *p_log, char *psz_stype,
 
     if( vlc_thread_create( p_sys->poll_thread, "Avahi Poll Iterate Thread",
                            poll_iterate_thread,
-                           VLC_THREAD_PRIORITY_HIGHEST, VLC_FALSE ) )
+                           VLC_THREAD_PRIORITY_HIGHEST, false ) )
     {
         msg_Err( p_sys->p_log, "failed to create poll iterate thread" );
         goto error;
@@ -250,7 +269,7 @@ void *bonjour_start_service( vlc_object_t *p_log, char *psz_stype,
 
 error:
     if( p_sys->poll_thread != NULL )
-        vlc_object_destroy( p_sys->poll_thread );
+        vlc_object_release( p_sys->poll_thread );
     if( p_sys->client != NULL )
         avahi_client_free( p_sys->client );
     if( p_sys->simple_poll != NULL )
@@ -274,13 +293,9 @@ void bonjour_stop_service( void *_p_sys )
 {
     bonjour_t *p_sys = (bonjour_t *)_p_sys;
 
-    if( p_sys->poll_thread->b_thread )
-    {
-        p_sys->poll_thread->b_die = 1;
-        vlc_thread_join( p_sys->poll_thread );
-    }
-
-    vlc_object_destroy( p_sys->poll_thread );
+    vlc_object_kill( p_sys->poll_thread );
+    vlc_thread_join( p_sys->poll_thread );
+    vlc_object_release( p_sys->poll_thread );
 
     if( p_sys->group != NULL )
         avahi_entry_group_free( p_sys->group );