]> git.sesse.net Git - vlc/commitdiff
Privatize libvlc_media_player_destroy
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 13 May 2009 15:50:46 +0000 (18:50 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 13 May 2009 15:52:22 +0000 (18:52 +0300)
src/control/libvlc_internal.h
src/control/media_player.c
src/libvlc.sym

index 5db5e305562d1434a8a4dd873e6b254f851c2fe6..2079d504025e723c0f1f13c9358d679cc68e00dd 100644 (file)
@@ -263,15 +263,6 @@ input_thread_t *libvlc_get_input_thread(
      libvlc_media_player_t *,
     libvlc_exception_t * );
 
-/* Media instance */
-libvlc_media_player_t *
-libvlc_media_player_new_from_input_thread( libvlc_instance_t *,
-                                           input_thread_t *,
-                                           libvlc_exception_t * );
-
-void libvlc_media_player_destroy(
-        libvlc_media_player_t * );
-
 /* Media Descriptor */
 libvlc_media_t * libvlc_media_new_from_input_item(
         libvlc_instance_t *, input_item_t *,
index b3c32a9ab611a8753962fd6ae95ab20fd3be34ce..a5f1d68d60ebf87954b941d02f8a9c2dd72057e3 100644 (file)
@@ -237,6 +237,8 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
 
 }
 
+static void libvlc_media_player_destroy( libvlc_media_player_t * );
+
 /**************************************************************************
  * Create a Media Instance object.
  *
@@ -359,35 +361,30 @@ libvlc_media_player_new_from_media(
  *
  * Warning: No lock held here, but hey, this is internal. Caller must lock.
  **************************************************************************/
-void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
+static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
 {
     input_thread_t *p_input_thread;
     libvlc_exception_t p_e;
 
-    if( !p_mi )
-        return;
-
-    libvlc_exception_init( &p_e );
+    assert( p_mi );
 
-       /* Detach Callback from the main libvlc object */
+    /* Detach Callback from the main libvlc object */
     var_DelCallback( p_mi->p_libvlc_instance->p_libvlc_int,
                      "vout-snapshottaken", SnapshotTakenCallback, p_mi );
 
+    libvlc_exception_init( &p_e );
     p_input_thread = libvlc_get_input_thread( p_mi, &p_e );
 
     if( libvlc_exception_raised( &p_e ) )
-    {
-        libvlc_event_manager_release( p_mi->p_event_manager );
+        /* no need to worry about no input thread */
         libvlc_exception_clear( &p_e );
-        free( p_mi );
-        return; /* no need to worry about no input thread */
-    }
-    vlc_mutex_destroy( &p_mi->object_lock );
-
-    vlc_object_release( p_input_thread );
-
-    libvlc_media_release( p_mi->p_md );
+    else
+        release_input_thread( p_mi, true );
 
+    libvlc_event_manager_release( p_mi->p_event_manager );
+    if( p_mi->p_md )
+        libvlc_media_release( p_mi->p_md );
+    vlc_mutex_destroy( &p_mi->object_lock );
     free( p_mi );
 }
 
@@ -398,33 +395,15 @@ void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
  **************************************************************************/
 void libvlc_media_player_release( libvlc_media_player_t *p_mi )
 {
-    if( !p_mi )
-        return;
+    bool destroy;
 
+    assert( p_mi );
     vlc_mutex_lock( &p_mi->object_lock );
-
-    p_mi->i_refcount--;
-
-    if( p_mi->i_refcount > 0 )
-    {
-        vlc_mutex_unlock( &p_mi->object_lock );
-        return;
-    }
+    destroy = !--p_mi->i_refcount;
     vlc_mutex_unlock( &p_mi->object_lock );
 
-    /* Detach Callback from the main libvlc object */
-    var_DelCallback( p_mi->p_libvlc_instance->p_libvlc_int,
-                     "vout-snapshottaken", SnapshotTakenCallback, p_mi );
-
-    vlc_mutex_destroy( &p_mi->object_lock );
-
-    release_input_thread( p_mi, true );
-
-    libvlc_event_manager_release( p_mi->p_event_manager );
-
-    libvlc_media_release( p_mi->p_md );
-
-    free( p_mi );
+    if( destroy )
+        libvlc_media_player_destroy( p_mi );
 }
 
 /**************************************************************************
index c61b6a85b7f7bf87806c69a8d51792b5313e4abc..f404302287a0b7b44dc7e6c98e51071aba35e76d 100644 (file)
@@ -119,7 +119,6 @@ libvlc_media_new
 libvlc_media_new_as_node
 libvlc_media_new_from_input_item
 libvlc_media_player_can_pause
-libvlc_media_player_destroy
 libvlc_media_player_event_manager
 libvlc_media_player_get_agl
 libvlc_media_player_get_chapter