Commit 23942f1f authored by Damien Fouilleul's avatar Damien Fouilleul

- libvlc APIs: bug fixing, and please note that exception argument is OPTIONAL...

- libvlc APIs: bug fixing, and please note that exception argument is OPTIONAL (can be null), do not use exception to control API flow unless you created your own
parent 4f2cfd11
...@@ -89,18 +89,17 @@ static int handle_event( vlc_object_t *p_this, char const *psz_cmd, ...@@ -89,18 +89,17 @@ static int handle_event( vlc_object_t *p_this, char const *psz_cmd,
**************************************************************************/ **************************************************************************/
static input_thread_t * get_input(libvlc_instance_t * p_instance) static input_thread_t * get_input(libvlc_instance_t * p_instance)
{ {
libvlc_exception_t p_e_unused; /* FIXME: error checking here */
libvlc_media_instance_t * p_mi; libvlc_media_instance_t * p_mi;
input_thread_t * p_input; input_thread_t * p_input;
p_mi = libvlc_playlist_get_media_instance( p_instance, &p_e_unused ); p_mi = libvlc_playlist_get_media_instance( p_instance, NULL );
if( !p_mi ) if( !p_mi )
return NULL; return NULL;
p_input = libvlc_get_input_thread( p_mi, &p_e_unused ); p_input = libvlc_get_input_thread( p_mi, NULL );
libvlc_media_instance_destroy( p_mi ); libvlc_media_instance_release( p_mi );
return p_input; return p_input;
} }
...@@ -119,6 +118,9 @@ static int install_input_event( vlc_object_t *p_this, char const *psz_cmd, ...@@ -119,6 +118,9 @@ static int install_input_event( vlc_object_t *p_this, char const *psz_cmd,
struct libvlc_callback_entry_list_t *p_listitem; struct libvlc_callback_entry_list_t *p_listitem;
input_thread_t * p_input = get_input( p_instance ); input_thread_t * p_input = get_input( p_instance );
if( !p_input )
return;
vlc_mutex_lock( &p_instance->instance_lock ); vlc_mutex_lock( &p_instance->instance_lock );
p_listitem = p_instance->p_callback_list; p_listitem = p_instance->p_callback_list;
......
...@@ -138,12 +138,18 @@ libvlc_media_instance_t * libvlc_media_instance_new_from_input_thread( ...@@ -138,12 +138,18 @@ libvlc_media_instance_t * libvlc_media_instance_new_from_input_thread(
{ {
libvlc_media_instance_t * p_mi; libvlc_media_instance_t * p_mi;
if( !p_input )
{
libvlc_exception_raise( p_e, "invalid input thread" );
return NULL;
}
p_mi = malloc( sizeof(libvlc_media_instance_t) ); p_mi = malloc( sizeof(libvlc_media_instance_t) );
p_mi->p_md = libvlc_media_descriptor_new_from_input_item( p_mi->p_md = libvlc_media_descriptor_new_from_input_item(
p_libvlc_instance, p_libvlc_instance,
p_input->p->input.p_item, p_e ); p_input->p->input.p_item, p_e );
if( libvlc_exception_raised( p_e ) ) if( !p_mi->p_md )
{ {
free( p_mi ); free( p_mi );
return NULL; return NULL;
...@@ -266,7 +272,7 @@ void libvlc_media_instance_play( libvlc_media_instance_t *p_mi, ...@@ -266,7 +272,7 @@ void libvlc_media_instance_play( libvlc_media_instance_t *p_mi,
/* A thread alread exists, send it a play message */ /* A thread alread exists, send it a play message */
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( !p_input_thread )
return; return;
input_Control( p_input_thread, INPUT_CONTROL_SET_STATE, PLAYING_S ); input_Control( p_input_thread, INPUT_CONTROL_SET_STATE, PLAYING_S );
...@@ -300,7 +306,7 @@ void libvlc_media_instance_pause( libvlc_media_instance_t *p_mi, ...@@ -300,7 +306,7 @@ void libvlc_media_instance_pause( libvlc_media_instance_t *p_mi,
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( !p_input_thread )
return; return;
input_Control( p_input_thread, INPUT_CONTROL_SET_STATE, val ); input_Control( p_input_thread, INPUT_CONTROL_SET_STATE, val );
......
...@@ -219,9 +219,17 @@ libvlc_media_instance_t * libvlc_playlist_get_media_instance( ...@@ -219,9 +219,17 @@ libvlc_media_instance_t * libvlc_playlist_get_media_instance(
assert( PL ); assert( PL );
vlc_mutex_lock( &PL->object_lock ); vlc_mutex_lock( &PL->object_lock );
p_mi = libvlc_media_instance_new_from_input_thread( if( PL->p_input )
p_instance, PL->p_input, p_e ); {
p_mi = libvlc_media_instance_new_from_input_thread(
p_instance, PL->p_input, p_e );
}
else
/* no active input */
p_mi = NULL;
vlc_mutex_unlock( &PL->object_lock ); vlc_mutex_unlock( &PL->object_lock );
return p_mi; return p_mi;
} }
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