Commit 44f031cb authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Privatize libvlc_media_player_destroy

parent 9f36a1de
...@@ -263,15 +263,6 @@ input_thread_t *libvlc_get_input_thread( ...@@ -263,15 +263,6 @@ input_thread_t *libvlc_get_input_thread(
libvlc_media_player_t *, libvlc_media_player_t *,
libvlc_exception_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 */ /* Media Descriptor */
libvlc_media_t * libvlc_media_new_from_input_item( libvlc_media_t * libvlc_media_new_from_input_item(
libvlc_instance_t *, input_item_t *, libvlc_instance_t *, input_item_t *,
......
...@@ -237,6 +237,8 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd, ...@@ -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. * Create a Media Instance object.
* *
...@@ -359,35 +361,30 @@ libvlc_media_player_new_from_media( ...@@ -359,35 +361,30 @@ libvlc_media_player_new_from_media(
* *
* Warning: No lock held here, but hey, this is internal. Caller must lock. * 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; input_thread_t *p_input_thread;
libvlc_exception_t p_e; libvlc_exception_t p_e;
if( !p_mi ) assert( p_mi );
return;
libvlc_exception_init( &p_e );
/* Detach Callback from the main libvlc object */ /* Detach Callback from the main libvlc object */
var_DelCallback( p_mi->p_libvlc_instance->p_libvlc_int, var_DelCallback( p_mi->p_libvlc_instance->p_libvlc_int,
"vout-snapshottaken", SnapshotTakenCallback, p_mi ); "vout-snapshottaken", SnapshotTakenCallback, p_mi );
libvlc_exception_init( &p_e );
p_input_thread = libvlc_get_input_thread( p_mi, &p_e ); p_input_thread = libvlc_get_input_thread( p_mi, &p_e );
if( libvlc_exception_raised( &p_e ) ) if( libvlc_exception_raised( &p_e ) )
{ /* no need to worry about no input thread */
libvlc_event_manager_release( p_mi->p_event_manager );
libvlc_exception_clear( &p_e ); libvlc_exception_clear( &p_e );
free( p_mi ); else
return; /* no need to worry about no input thread */ release_input_thread( p_mi, true );
}
vlc_mutex_destroy( &p_mi->object_lock );
vlc_object_release( p_input_thread );
libvlc_media_release( p_mi->p_md );
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 ); free( p_mi );
} }
...@@ -398,33 +395,15 @@ void libvlc_media_player_destroy( libvlc_media_player_t *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 ) void libvlc_media_player_release( libvlc_media_player_t *p_mi )
{ {
if( !p_mi ) bool destroy;
return;
assert( p_mi );
vlc_mutex_lock( &p_mi->object_lock ); vlc_mutex_lock( &p_mi->object_lock );
destroy = !--p_mi->i_refcount;
p_mi->i_refcount--;
if( p_mi->i_refcount > 0 )
{
vlc_mutex_unlock( &p_mi->object_lock );
return;
}
vlc_mutex_unlock( &p_mi->object_lock ); vlc_mutex_unlock( &p_mi->object_lock );
/* Detach Callback from the main libvlc object */ if( destroy )
var_DelCallback( p_mi->p_libvlc_instance->p_libvlc_int, libvlc_media_player_destroy( p_mi );
"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 );
} }
/************************************************************************** /**************************************************************************
......
...@@ -119,7 +119,6 @@ libvlc_media_new ...@@ -119,7 +119,6 @@ libvlc_media_new
libvlc_media_new_as_node libvlc_media_new_as_node
libvlc_media_new_from_input_item libvlc_media_new_from_input_item
libvlc_media_player_can_pause libvlc_media_player_can_pause
libvlc_media_player_destroy
libvlc_media_player_event_manager libvlc_media_player_event_manager
libvlc_media_player_get_agl libvlc_media_player_get_agl
libvlc_media_player_get_chapter libvlc_media_player_get_chapter
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment