playlist/services_discovery.c: Use a stop method to end the service.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Sat, 18 Aug 2007 03:44:13 +0000 (03:44 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Sat, 18 Aug 2007 03:44:13 +0000 (03:44 +0000)
include/vlc_playlist.h
src/playlist/services_discovery.c

index 3a7f95d..20bce26 100644 (file)
@@ -428,6 +428,7 @@ VLC_EXPORT( playlist_item_t *, playlist_GetLastLeaf, ( playlist_t *p_playlist, p
 VLC_EXPORT( services_discovery_t *, services_discovery_Create, ( vlc_object_t * p_super, const char * psz_service_name ) );
 VLC_EXPORT( void,                   services_discovery_Destroy, ( services_discovery_t * p_this ) );
 VLC_EXPORT( int,                    services_discovery_Start, ( services_discovery_t * p_this ) );
+VLC_EXPORT( void,                   services_discovery_Stop, ( services_discovery_t * p_this ) );
 
 /* Read info from discovery object */
 VLC_EXPORT( char *,                 services_discovery_GetLocalizedName, ( services_discovery_t * p_this ) );
index bc32a18..d66adab 100644 (file)
@@ -72,13 +72,9 @@ services_discovery_Create ( vlc_object_t * p_super, const char * psz_module_name
  ***********************************************************************/
 void services_discovery_Destroy ( services_discovery_t * p_sd )
 {
-    vlc_object_kill( p_sd );
-    if( p_sd->pf_run ) vlc_thread_join( p_sd );
+    vlc_event_manager_fini( &p_sd->event_manager );
 
     free( p_sd->psz_module );
-    module_Unneed( p_sd, p_sd->p_module );
-
-    vlc_event_manager_fini( &p_sd->event_manager );
     free( p_sd->psz_localized_name );
 
     vlc_object_destroy( p_sd );
@@ -100,6 +96,17 @@ int services_discovery_Start ( services_discovery_t * p_sd )
     return VLC_SUCCESS;
 }
 
+/***********************************************************************
+ * Stop
+ ***********************************************************************/
+void services_discovery_Stop ( services_discovery_t * p_sd )
+{
+    vlc_object_kill( p_sd );
+    if( p_sd->pf_run ) vlc_thread_join( p_sd );
+
+    module_Unneed( p_sd, p_sd->p_module );
+}
+
 /***********************************************************************
  * GetLocalizedName
  ***********************************************************************/
@@ -316,7 +323,7 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
 
     if( p_asd && p_asd->p_sd )
     {
-        services_discovery_Destroy( p_asd->p_sd );
+        services_discovery_Stop( p_asd->p_sd );
 
         vlc_event_detach( services_discovery_EventManager( p_asd->p_sd ),
                           vlc_ServicesDiscoveryItemAdded,
@@ -348,6 +355,8 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
         }
         PL_UNLOCK;
 
+        services_discovery_Destroy( p_asd->p_sd );
+
         free( p_asd );
     }
     else