From: RĂ©mi Denis-Courmont Date: Mon, 7 Sep 2009 19:13:49 +0000 (+0300) Subject: Move LibVLC error messages to libvlc_printerr(). X-Git-Tag: 1.1.0-ff~3469 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=848c006a787a468ebc8bc68960e01cfd812d8d6f;p=vlc Move LibVLC error messages to libvlc_printerr(). --- diff --git a/include/vlc/libvlc.h b/include/vlc/libvlc.h index 3e45bfe4c7..a5027dad50 100644 --- a/include/vlc/libvlc.h +++ b/include/vlc/libvlc.h @@ -88,15 +88,12 @@ VLC_PUBLIC_API int libvlc_exception_raised( const libvlc_exception_t *p_exception ); /** - * Raise an exception using a user-provided message. + * Raise an exception. * * \param p_exception the exception to raise - * \param psz_format the exception message format string - * \param ... the format string arguments */ VLC_PUBLIC_API void -libvlc_exception_raise( libvlc_exception_t *p_exception, - const char *psz_format, ... ); +libvlc_exception_raise( libvlc_exception_t *p_exception ); /** * Clear an exception object so it can be reused. diff --git a/src/control/audio.c b/src/control/audio.c index c75379a300..89ee0a76bc 100644 --- a/src/control/audio.c +++ b/src/control/audio.c @@ -52,7 +52,8 @@ static aout_instance_t *GetAOut( libvlc_instance_t *p_instance, p_aout = vlc_object_find( p_instance->p_libvlc_int, VLC_OBJECT_AOUT, FIND_CHILD ); if( !p_aout ) { - libvlc_exception_raise( p_exception, "No active audio output" ); + libvlc_exception_raise( p_exception ); + libvlc_printerr( "No active audio output" ); return NULL; } @@ -84,7 +85,8 @@ libvlc_audio_output_t * malloc( sizeof( libvlc_audio_output_t ) ); if( p_actual == NULL ) { - libvlc_exception_raise( p_e, "Not enough memory" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); libvlc_audio_output_list_release( p_list ); module_list_free( module_list ); return NULL; @@ -287,7 +289,6 @@ int libvlc_audio_output_get_device_type( libvlc_instance_t *p_instance, vlc_object_release( p_aout ); return i_device_type; } - libvlc_exception_raise( p_e, "Unable to get audio output" ); return libvlc_AudioOutputDevice_Error; } @@ -299,12 +300,14 @@ void libvlc_audio_output_set_device_type( libvlc_instance_t *p_instance, libvlc_exception_t *p_e ) { aout_instance_t *p_aout = GetAOut( p_instance, p_e ); - if( p_aout ) + if( !p_aout ) + return; + if( var_SetInteger( p_aout, "audio-device", device_type ) < 0 ) { - if( var_SetInteger( p_aout, "audio-device", device_type ) < 0 ) - libvlc_exception_raise( p_e, "Failed setting audio device" ); - vlc_object_release( p_aout ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Error setting audio device" ); } + vlc_object_release( p_aout ); } /***************************************************************************** @@ -363,7 +366,8 @@ void libvlc_audio_set_volume( libvlc_instance_t *p_instance, int i_volume, } else { - libvlc_exception_raise( p_e, "Volume out of range" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Volume out of range" ); } } @@ -414,8 +418,9 @@ int libvlc_audio_get_track( libvlc_media_player_t *p_mi, i_ret = var_Get( p_input_thread, "audio-es", &val ); if( i_ret < 0 ) { - libvlc_exception_raise( p_e, "Getting Audio track information failed" ); vlc_object_release( p_input_thread ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Audio track information not found" ); return i_ret; } @@ -450,14 +455,18 @@ void libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track, var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL ); if( (i_track < 0) || (i_track > val_list.p_list->i_count) ) { - libvlc_exception_raise( p_e, "Audio track out of range" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Audio track out of range" ); goto end; } newval = val_list.p_list->p_values[i_track]; i_ret = var_Set( p_input_thread, "audio-es", newval ); if( i_ret < 0 ) - libvlc_exception_raise( p_e, "Setting audio track failed" ); + { + libvlc_exception_raise( p_e ); + libvlc_printerr( "Audio track out of range" ); /* Race... */ + } end: var_FreeList( &val_list, NULL ); @@ -471,16 +480,12 @@ int libvlc_audio_get_channel( libvlc_instance_t *p_instance, libvlc_exception_t *p_e ) { aout_instance_t *p_aout = GetAOut( p_instance, p_e ); - if( p_aout ) - { - vlc_value_t val; + if( !p_aout ) + return 0; - var_Get( p_aout, "audio-channels", &val ); - vlc_object_release( p_aout ); - return val.i_int; - } - libvlc_exception_raise( p_e, "Unable to get audio output" ); - return libvlc_AudioChannel_Error; + int val = var_GetInteger( p_aout, "audio-channels" ); + vlc_object_release( p_aout ); + return val; } /***************************************************************************** @@ -491,14 +496,13 @@ void libvlc_audio_set_channel( libvlc_instance_t *p_instance, libvlc_exception_t *p_e ) { aout_instance_t *p_aout = GetAOut( p_instance, p_e ); - if( p_aout ) - { - vlc_value_t val; - - val.i_int = channel; - if( var_Set( p_aout, "audio-channels", val ) < 0 ) - libvlc_exception_raise( p_e, "Failed setting audio channel" ); + if( !p_aout ) + return; - vlc_object_release( p_aout ); + if( var_SetInteger( p_aout, "audio-channels", channel ) < 0 ) + { + libvlc_exception_raise( p_e ); + libvlc_printerr( "Audio channel out of range" ); } + vlc_object_release( p_aout ); } diff --git a/src/control/core.c b/src/control/core.c index 25f190e790..986c37704a 100644 --- a/src/control/core.c +++ b/src/control/core.c @@ -65,23 +65,8 @@ static void libvlc_exception_not_handled( const char *psz ) abort(); } -void libvlc_exception_raise( libvlc_exception_t *p_exception, - const char *psz_format, ... ) +void libvlc_exception_raise( libvlc_exception_t *p_exception ) { - va_list args; - - /* Make sure that there is no unnoticed previous exception */ - if( p_exception && p_exception->b_raised ) - { - libvlc_exception_not_handled( libvlc_errmsg() ); - libvlc_exception_clear( p_exception ); - } - - /* Unformat-ize the message */ - va_start( args, psz_format ); - libvlc_vprinterr( psz_format, args ); - va_end( args ); - /* Does caller care about exceptions ? */ if( p_exception == NULL ) { /* Print something, so that lazy third-parties can easily @@ -187,7 +172,8 @@ int libvlc_add_intf( libvlc_instance_t *p_i, const char *name, { if( libvlc_InternalAddIntf( p_i->p_libvlc_int, name ) ) { - libvlc_exception_raise( p_e, "Interface initialization failed" ); + libvlc_printerr("Interface initialization failed"); + libvlc_exception_raise( p_e ); return -1; } return 0; diff --git a/src/control/event.c b/src/control/event.c index c368c1a0d7..af7f9aa654 100644 --- a/src/control/event.c +++ b/src/control/event.c @@ -31,6 +31,7 @@ #include "libvlc_internal.h" #include "event_internal.h" +#include typedef struct libvlc_event_listeners_group_t { @@ -74,7 +75,8 @@ libvlc_event_manager_new( void * p_obj, libvlc_instance_t * p_libvlc_inst, p_em = malloc(sizeof( libvlc_event_manager_t )); if( !p_em ) { - libvlc_exception_raise( p_e, "No Memory left" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); return NULL; } @@ -134,7 +136,8 @@ void libvlc_event_manager_register_event_type( listeners_group = malloc(sizeof(libvlc_event_listeners_group_t)); if( !listeners_group ) { - libvlc_exception_raise( p_e, "No Memory left" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); return; } @@ -287,7 +290,8 @@ void event_attach( libvlc_event_manager_t * p_event_manager, listener = malloc(sizeof(libvlc_event_listener_t)); if( !listener ) { - libvlc_exception_raise( p_e, "No Memory left" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); return; } @@ -310,9 +314,9 @@ void event_attach( libvlc_event_manager_t * p_event_manager, vlc_mutex_unlock( &p_event_manager->object_lock ); free(listener); - libvlc_exception_raise( p_e, - "This object event manager doesn't know about '%s' events", - libvlc_event_type_name(event_type)); + fprintf( stderr, "This object event manager doesn't know about '%s' events", + libvlc_event_type_name(event_type) ); + assert(0); } /************************************************************************** @@ -399,10 +403,5 @@ void libvlc_event_detach( libvlc_event_manager_t *p_event_manager, libvlc_event_async_ensure_listener_removal(p_event_manager, &listener_to_remove); - if(!found) - { - libvlc_exception_raise( p_e, - "This object event manager doesn't know about '%s,%p,%p' event observer", - libvlc_event_type_name(event_type), pf_callback, p_user_data ); - } + assert(found); } diff --git a/src/control/hierarchical_node_media_list_view.c b/src/control/hierarchical_node_media_list_view.c index bffd6ecbdf..ad6f4b3034 100644 --- a/src/control/hierarchical_node_media_list_view.c +++ b/src/control/hierarchical_node_media_list_view.c @@ -105,7 +105,8 @@ hierarch_node_media_list_view_item_at_index( libvlc_media_list_view_t * p_mlv, libvlc_media_release( p_md ); } - libvlc_exception_raise( p_e, "Index out of bound in Media List View" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Index out of bound in Media List View" ); return NULL; } diff --git a/src/control/libvlc_internal.h b/src/control/libvlc_internal.h index ef97eff54f..7e784cd709 100644 --- a/src/control/libvlc_internal.h +++ b/src/control/libvlc_internal.h @@ -104,9 +104,11 @@ void libvlc_event_attach_async( libvlc_event_manager_t * p_event_manager, /* Exception shorcuts */ -#define RAISENULL( ... ) { libvlc_exception_raise( p_e, __VA_ARGS__ ); \ +#define RAISENULL( ... ) { libvlc_printerr(__VA_ARGS__); \ + libvlc_exception_raise( p_e ); \ return NULL; } -#define RAISEZERO( ... ) { libvlc_exception_raise( p_e, __VA_ARGS__ ); \ +#define RAISEZERO( ... ) { libvlc_printerr(__VA_ARGS__); \ + libvlc_exception_raise( p_e ); \ return 0; } #endif diff --git a/src/control/media.c b/src/control/media.c index 6f853f8e62..38c64d68ae 100644 --- a/src/control/media.c +++ b/src/control/media.c @@ -245,14 +245,16 @@ libvlc_media_t * libvlc_media_new_from_input_item( if (!p_input_item) { - libvlc_exception_raise( p_e, "No input item given" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "No input item given" ); return NULL; } p_md = malloc( sizeof(libvlc_media_t) ); if( !p_md ) { - libvlc_exception_raise( p_e, "Not enough memory" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); return NULL; } @@ -302,7 +304,8 @@ libvlc_media_t * libvlc_media_new( if (!p_input_item) { - libvlc_exception_raise( p_e, "Can't create md's input_item" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); return NULL; } @@ -330,7 +333,8 @@ libvlc_media_t * libvlc_media_new_as_node( if (!p_input_item) { - libvlc_exception_raise( p_e, "Can't create md's input_item" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); return NULL; } @@ -545,7 +549,8 @@ libvlc_media_get_duration( libvlc_media_t * p_md, if( !p_md || !p_md->p_input_item) { - libvlc_exception_raise( p_e, "No input item" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "No input item" ); return -1; } @@ -563,7 +568,8 @@ libvlc_media_is_preparsed( libvlc_media_t * p_md, if( !p_md || !p_md->p_input_item) { - libvlc_exception_raise( p_e, "No input item" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "No input item" ); return false; } diff --git a/src/control/media_discoverer.c b/src/control/media_discoverer.c index e7f479ea37..e4482de9e5 100644 --- a/src/control/media_discoverer.c +++ b/src/control/media_discoverer.c @@ -178,7 +178,8 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst, p_mdis = malloc(sizeof(libvlc_media_discoverer_t)); if( !p_mdis ) { - libvlc_exception_raise( p_e, "Not enough memory" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); return NULL; } @@ -202,7 +203,8 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst, if( !p_mdis->p_sd ) { libvlc_media_list_release( p_mdis->p_mlist ); - libvlc_exception_raise( p_e, "Can't find the services_discovery module named '%s'", psz_name ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "%s: no such discovery module found", psz_name ); free( p_mdis ); return NULL; } @@ -228,7 +230,8 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst, if( !vlc_sd_Start( p_mdis->p_sd, psz_name ) ) { libvlc_media_list_release( p_mdis->p_mlist ); - libvlc_exception_raise( p_e, "Can't start the services_discovery module named '%s'", psz_name ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "%s: internal module error", psz_name ); free( p_mdis ); return NULL; } diff --git a/src/control/media_library.c b/src/control/media_library.c index d25e414681..929358dccf 100644 --- a/src/control/media_library.c +++ b/src/control/media_library.c @@ -111,20 +111,19 @@ libvlc_media_library_load( libvlc_media_library_t * p_mlib, char *psz_datadir = config_GetUserDir( VLC_DATA_DIR ); char * psz_uri; - if( !psz_datadir ) /* XXX: i doubt that this can ever happen */ - { - libvlc_exception_raise( p_e, "Can't get data directory" ); - return; - } - - if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xsp", + if( psz_datadir == NULL + || asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xsp", psz_datadir ) == -1 ) + psz_uri = NULL; + free( psz_datadir ); + + if( psz_uri == NULL ); { - free( psz_datadir ); - libvlc_exception_raise( p_e, "Can't get create the path" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); return; } - free( psz_datadir ); + if( p_mlib->p_mlist ) libvlc_media_list_release( p_mlib->p_mlist ); @@ -145,7 +144,8 @@ libvlc_media_library_save( libvlc_media_library_t * p_mlib, libvlc_exception_t * p_e ) { (void)p_mlib; - libvlc_exception_raise( p_e, "Not supported" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Function not implemented" ); } /************************************************************************** diff --git a/src/control/media_list.c b/src/control/media_list.c index 5cebf41fed..d5b4aab022 100644 --- a/src/control/media_list.c +++ b/src/control/media_list.c @@ -134,7 +134,8 @@ int mlist_is_writable( libvlc_media_list_t *p_mlist, libvlc_exception_t *p_e ) if( !p_mlist||p_mlist->b_read_only ) { /* We are read-only from user side */ - libvlc_exception_raise( p_e, "Cannot write to read-only media list." ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Attempt to write a read-only media list" ); return 0; } return 1; @@ -259,7 +260,8 @@ libvlc_media_list_add_file_content( libvlc_media_list_t * p_mlist, if( !p_input_item ) { - libvlc_exception_raise( p_e, "Can't create an input item" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); return; } @@ -417,7 +419,8 @@ void _libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist, if( index < 0 || index >= vlc_array_count( &p_mlist->items )) { - libvlc_exception_raise( p_e, "Index out of bounds"); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Index out of bounds" ); return; } @@ -444,7 +447,8 @@ libvlc_media_list_item_at_index( libvlc_media_list_t * p_mlist, if( index < 0 || index >= vlc_array_count( &p_mlist->items )) { - libvlc_exception_raise( p_e, "Index out of bounds"); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Index out of bounds" ); return NULL; } diff --git a/src/control/media_list_player.c b/src/control/media_list_player.c index e273a4b1f7..8ad8206c42 100644 --- a/src/control/media_list_player.c +++ b/src/control/media_list_player.c @@ -566,14 +566,9 @@ void libvlc_media_list_player_set_media_player(libvlc_media_list_player_t * p_ml **************************************************************************/ void libvlc_media_list_player_set_media_list(libvlc_media_list_player_t * p_mlp, libvlc_media_list_t * p_mlist, libvlc_exception_t * p_e) { - lock(p_mlp); + assert (p_mlist); - if (!p_mlist) - { - libvlc_exception_raise(p_e, "No media list provided"); - unlock(p_mlp); - return; - } + lock(p_mlp); if (p_mlp->p_mlist) { uninstall_playlist_observer(p_mlp); @@ -668,7 +663,8 @@ void libvlc_media_list_player_play_item(libvlc_media_list_player_t * p_mlp, libv libvlc_media_list_path_t path = libvlc_media_list_path_of_item(p_mlp->p_mlist, p_md); if (!path) { - libvlc_exception_raise(p_e, "No such item in media list"); + libvlc_exception_raise(p_e); + libvlc_printerr("Item not found in media list"); unlock(p_mlp); return; } @@ -726,7 +722,8 @@ static void set_relative_playlist_position_and_play( if (!p_mlp->p_mlist) { - libvlc_exception_raise(p_e, "No media list"); + libvlc_exception_raise(p_e); + libvlc_printerr("No media list"); return; } diff --git a/src/control/media_list_view.c b/src/control/media_list_view.c index d4a56fc962..ba8ea6490f 100644 --- a/src/control/media_list_view.c +++ b/src/control/media_list_view.c @@ -475,7 +475,8 @@ libvlc_media_list_view_children_for_item( libvlc_media_list_view_t * p_mlv, { \ if( p_mlv->pf_##name ) \ return p_mlv->pf_##name ARGS(__VA_ARGS__) ; \ - libvlc_exception_raise( p_e, "No '" #name "' method in this media_list_view" ); \ + libvlc_exception_raise( p_e ); \ + libvlc_printerr( "No '" #name "' method in this media_list_view" ); \ return default_ret_value;\ } @@ -490,7 +491,8 @@ libvlc_media_list_view_children_for_item( libvlc_media_list_view_t * p_mlv, p_mlv->pf_##name ARGS(__VA_ARGS__) ; \ return; \ } \ - libvlc_exception_raise( p_e, "No '" #name "' method in this media_list_view" ); \ + libvlc_exception_raise( p_e ); \ + libvlc_printerr( "No '" #name "' method in this media_list_view" ); \ } diff --git a/src/control/media_player.c b/src/control/media_player.c index bfc177c3a2..0b7d9c4be5 100644 --- a/src/control/media_player.c +++ b/src/control/media_player.c @@ -275,16 +275,13 @@ libvlc_media_player_new( libvlc_instance_t * p_libvlc_instance, { libvlc_media_player_t * p_mi; - if( !p_libvlc_instance ) - { - libvlc_exception_raise( p_e, "invalid libvlc instance" ); - return NULL; - } + assert( p_libvlc_instance ); p_mi = malloc( sizeof(libvlc_media_player_t) ); if( !p_mi ) { - libvlc_exception_raise( p_e, "not enough memory" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); return NULL; } p_mi->p_md = NULL; @@ -558,8 +555,9 @@ void libvlc_media_player_play( libvlc_media_player_t *p_mi, if( !p_mi->p_md ) { - libvlc_exception_raise( p_e, "no associated media descriptor" ); vlc_mutex_unlock( &p_mi->object_lock ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "No associated media descriptor" ); return; } @@ -1038,7 +1036,8 @@ void libvlc_media_player_set_rate( if( (rate < 0.0) && !b_can_rewind ) { vlc_object_release( p_input_thread ); - libvlc_exception_raise( p_e, "Rate value is invalid" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Invalid playback rate" ); return; } @@ -1063,7 +1062,6 @@ float libvlc_media_player_get_rate( if( i_rate < 0 && !b_can_rewind ) { vlc_object_release( p_input_thread ); - libvlc_exception_raise( p_e, "invalid rate" ); return 0.0; } vlc_object_release( p_input_thread ); @@ -1143,7 +1141,8 @@ libvlc_track_description_t * malloc( sizeof( libvlc_track_description_t ) ); if ( !p_track_description ) { - libvlc_exception_raise( p_e, "not enough memory" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); goto end; } p_actual = p_track_description; @@ -1157,7 +1156,8 @@ libvlc_track_description_t * if ( !p_actual ) { libvlc_track_description_release( p_track_description ); - libvlc_exception_raise( p_e, "not enough memory" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); goto end; } } @@ -1220,5 +1220,8 @@ void libvlc_media_player_next_frame( libvlc_media_player_t *p_mi, libvlc_excepti vlc_object_release( p_input_thread ); } else - libvlc_exception_raise( p_e, "Input thread is NULL" ); + { + libvlc_exception_raise( p_e ); + libvlc_printerr( "No active input" ); + } } diff --git a/src/control/video.c b/src/control/video.c index 9274ea05ff..a7d854a440 100644 --- a/src/control/video.c +++ b/src/control/video.c @@ -39,6 +39,7 @@ #include "media_player_internal.h" #include +#include /* * Remember to release the returned vout_thread_t. @@ -54,7 +55,8 @@ static vout_thread_t *GetVout( libvlc_media_player_t *p_mi, p_vout = input_GetVout( p_input ); if( !p_vout ) { - libvlc_exception_raise( p_exception, "No active video output" ); + libvlc_exception_raise( p_exception ); + libvlc_printerr( "No active video output" ); } vlc_object_release( p_input ); } @@ -116,16 +118,13 @@ libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, const char *psz_filepat { vout_thread_t *p_vout; - /* The filepath must be not NULL */ - if( !psz_filepath ) - { - libvlc_exception_raise( p_e, "filepath is null" ); - return; - } + assert( psz_filepath ); + /* We must have an input */ if( !p_mi->p_input_thread ) { - libvlc_exception_raise( p_e, "Input does not exist" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Input does not exist" ); return; } @@ -243,11 +242,12 @@ void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi, if( !p_vout ) return; i_ret = var_SetString( p_vout, "aspect-ratio", psz_aspect ); - if( i_ret ) - libvlc_exception_raise( p_e, - "Unexpected error while setting aspect-ratio value" ); - vlc_object_release( p_vout ); + if( i_ret ) + { + libvlc_exception_raise( p_e ); + libvlc_printerr( "Bad or unsupported aspect ratio" ); + } } int libvlc_video_get_spu( libvlc_media_player_t *p_mi, @@ -265,8 +265,9 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi, i_ret = var_Get( p_input_thread, "spu-es", &val ); if( i_ret < 0 ) { - libvlc_exception_raise( p_e, "Getting subtitle information failed" ); vlc_object_release( p_input_thread ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Subtitle informations not found" ); return i_ret; } @@ -318,15 +319,11 @@ void libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu, var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL ); - if( val_list.p_list->i_count == 0 ) + if( ( val_list.p_list->i_count == 0 ) + || (i_spu < 0) || (i_spu > val_list.p_list->i_count) ) { - libvlc_exception_raise( p_e, "Subtitle value out of range" ); - goto end; - } - - if( (i_spu < 0) || (i_spu > val_list.p_list->i_count) ) - { - libvlc_exception_raise( p_e, "Subtitle value out of range" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Subtitle number out of range" ); goto end; } @@ -334,7 +331,8 @@ void libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu, i_ret = var_Set( p_input_thread, "spu-es", newval ); if( i_ret < 0 ) { - libvlc_exception_raise( p_e, "Setting subtitle value failed" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Subtitle selection error" ); } end: @@ -397,16 +395,19 @@ void libvlc_video_set_crop_geometry( libvlc_media_player_t *p_mi, if( !p_vout ) return; i_ret = var_SetString( p_vout, "crop", psz_geometry ); - if( i_ret ) - libvlc_exception_raise( p_e, - "Unexpected error while setting crop geometry" ); - vlc_object_release( p_vout ); + + if( i_ret ) + { + libvlc_exception_raise( p_e ); + libvlc_printerr( "Bad or unsupported cropping geometry" ); + } } int libvlc_video_get_teletext( libvlc_media_player_t *p_mi, libvlc_exception_t *p_e ) { +#if 0 vout_thread_t *p_vout = GetVout( p_mi, p_e ); vlc_object_t *p_vbi; int i_ret = -1; @@ -423,11 +424,15 @@ int libvlc_video_get_teletext( libvlc_media_player_t *p_mi, vlc_object_release( p_vout ); return i_ret; +#else + return -1; +#endif } void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page, libvlc_exception_t *p_e ) { +#if 0 vout_thread_t *p_vout = GetVout( p_mi, p_e ); vlc_object_t *p_vbi; int i_ret = -1; @@ -445,13 +450,13 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page, "Unexpected error while setting teletext page" ); } vlc_object_release( p_vout ); +#endif } void libvlc_toggle_teletext( libvlc_media_player_t *p_mi, libvlc_exception_t *p_e ) { input_thread_t *p_input_thread; - vlc_object_t *p_vbi; int i_ret; p_input_thread = libvlc_get_input_thread(p_mi, p_e); @@ -463,7 +468,8 @@ void libvlc_toggle_teletext( libvlc_media_player_t *p_mi, return; } const bool b_selected = var_GetInteger( p_input_thread, "teletext-es" ) >= 0; - +#if 0 + vlc_object_t *p_vbi; p_vbi = (vlc_object_t *)vlc_object_find_name( p_input_thread, "zvbi", FIND_CHILD ); if( p_vbi ) @@ -488,7 +494,9 @@ void libvlc_toggle_teletext( libvlc_media_player_t *p_mi, } vlc_object_release( p_vbi ); } - else if( b_selected ) + else +#endif + if( b_selected ) { var_SetInteger( p_input_thread, "spu-es", -1 ); } @@ -544,7 +552,8 @@ int libvlc_video_get_track( libvlc_media_player_t *p_mi, i_ret = var_Get( p_input_thread, "video-es", &val ); if( i_ret < 0 ) { - libvlc_exception_raise( p_e, "Getting Video track information failed" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Video track information not found" ); vlc_object_release( p_input_thread ); return i_ret; } @@ -577,17 +586,16 @@ void libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track, var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL ); for( i = 0; i < val_list.p_list->i_count; i++ ) { - vlc_value_t val = val_list.p_list->p_values[i]; - if( i_track == val.i_int ) + if( i_track == val_list.p_list->p_values[i].i_int ) { - i_ret = var_Set( p_input_thread, "video-es", val ); + i_ret = var_SetInteger( p_input_thread, "video-es", i_track ); if( i_ret < 0 ) - libvlc_exception_raise( p_e, "Setting video track failed" ); + break; goto end; } } - libvlc_exception_raise( p_e, "Video track out of range" ); - + libvlc_exception_raise( p_e ); + libvlc_printerr( "Video track number out of range" ); end: var_FreeList( &val_list, NULL ); vlc_object_release( p_input_thread ); @@ -603,10 +611,7 @@ void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi, int b_enable, vout_thread_t *p_vout = GetVout( p_mi, p_e ); if( !p_vout ) - { - libvlc_exception_raise( p_e, "Unable to get video output" ); return; - } if( b_enable ) { @@ -620,7 +625,8 @@ void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi, int b_enable, } else { - libvlc_exception_raise( p_e, "Unsuported or bad deinterlace filter name" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Bad or unsuported deinterlacing mode" ); } } else @@ -691,7 +697,8 @@ int libvlc_video_get_marquee_option_as_int( libvlc_media_player_t *p_mi, const char * identifier = get_marquee_int_option_identifier(option); if(!identifier) { - libvlc_exception_raise( p_e, "This option is not available" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Unknown marquee option" ); return 0; } vlc_object_t * marquee = get_marquee_object(p_mi); @@ -707,9 +714,11 @@ int libvlc_video_get_marquee_option_as_int( libvlc_media_player_t *p_mi, /* Generic case */ if(!identifier) { - libvlc_exception_raise( p_e, "Marquee is not enabled" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Marquee not enabled" ); return 0; } +#warning This and the next function may crash due to type checking! int ret = var_GetInteger(marquee, identifier); vlc_object_release(marquee); return ret; @@ -725,15 +734,17 @@ char * libvlc_video_get_marquee_option_as_string( libvlc_media_player_t *p_mi, const char * identifier = get_marquee_string_option_identifier(option); if(!identifier) { - libvlc_exception_raise( p_e, "This option is not available" ); - return 0; + libvlc_exception_raise( p_e ); + libvlc_printerr( "Unknown marquee option" ); + return NULL; } vlc_object_t * marquee = get_marquee_object(p_mi); if(!marquee) { - libvlc_exception_raise( p_e, "Marquee is not enabled" ); - return 0; + libvlc_exception_raise( p_e ); + libvlc_printerr( "Marquee not enabled" ); + return NULL; } char *ret = var_GetString(marquee, identifier); vlc_object_release(marquee); @@ -750,7 +761,8 @@ void libvlc_video_set_marquee_option_as_int( libvlc_media_player_t *p_mi, const char * identifier = get_marquee_int_option_identifier(option); if(!identifier) { - libvlc_exception_raise( p_e, "This option is not available" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Unknown marquee option" ); return; } @@ -766,17 +778,14 @@ void libvlc_video_set_marquee_option_as_int( libvlc_media_player_t *p_mi, vout_EnableFilter(vout, identifier, value, false); vlc_object_release(vout); } - else - { - libvlc_exception_raise( p_e, "No Vout" ); - } return; } vlc_object_t * marquee = get_marquee_object(p_mi); if(!marquee) { - libvlc_exception_raise( p_e, "Marquee is not enabled" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Marquee not enabled" ); return; } var_SetInteger(marquee, identifier, value); @@ -794,13 +803,15 @@ void libvlc_video_set_marquee_option_as_string( libvlc_media_player_t *p_mi, const char * identifier = get_marquee_string_option_identifier(option); if(!identifier) { - libvlc_exception_raise( p_e, "This option is not available" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Unknown marquee option" ); return; } vlc_object_t * marquee = get_marquee_object(p_mi); if(!marquee) { - libvlc_exception_raise( p_e, "Marquee is not enabled" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Marquee not enabled" ); return; } var_SetString(marquee, identifier, value); diff --git a/src/control/vlm.c b/src/control/vlm.c index e6e96b653a..2c9dc6274b 100644 --- a/src/control/vlm.c +++ b/src/control/vlm.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "libvlc_internal.h" @@ -166,8 +167,8 @@ static int libvlc_vlm_init( libvlc_instance_t *p_instance, p_instance->libvlc_vlm.p_vlm = vlm_New( p_instance->p_libvlc_int ); if( !p_instance->libvlc_vlm.p_vlm ) { - libvlc_exception_raise( p_exception, - "Unable to create VLM." ); + libvlc_exception_raise( p_exception ); + libvlc_printerr( "VLM not supported or out of memory" ); return VLC_EGENERIC; } var_AddCallback( (vlc_object_t *)p_instance->libvlc_vlm.p_vlm, @@ -209,8 +210,8 @@ libvlc_vlm_get_media_instance( libvlc_instance_t *p_instance, vlm_Control( p_vlm, VLM_GET_MEDIA_INSTANCES, id, &pp_minstance, &i_minstance ) ) { - libvlc_exception_raise( p_exception, "Unable to get %s instances", - psz_name ); + libvlc_exception_raise( p_exception ); + libvlc_printerr( "%s: media instances not found", psz_name ); return NULL; } p_minstance = NULL; @@ -355,44 +356,41 @@ const char* libvlc_vlm_show_media( libvlc_instance_t *p_instance, VLM_RET(p_vlm, NULL); - if( psz_name == NULL ) + assert( psz_name ); + + if( asprintf( &psz_message, "show %s", psz_name ) == -1 ) { - libvlc_exception_raise( p_exception, "No media name supplied" ); + libvlc_exception_raise( p_exception ); + libvlc_printerr( "Not enough memory" ); + return NULL; } - else if( asprintf( &psz_message, "show %s", psz_name ) == -1 ) + + vlm_ExecuteCommand( p_vlm, psz_message, &answer ); + if( answer->psz_value ) { - libvlc_exception_raise( p_exception, "Unable to call show %s", - psz_name ); + libvlc_exception_raise( p_exception ); + libvlc_printerr( "Unable to call show %s: %s", + psz_name, answer->psz_value ); } - else - { - vlm_ExecuteCommand( p_vlm, psz_message, &answer ); - if( answer->psz_value ) + else if ( answer->child ) + { /* in case everything was requested */ + if ( strcmp( psz_name, "" ) == 0 ) { - libvlc_exception_raise( p_exception, "Unable to call show %s: %s", - psz_name, answer->psz_value ); + psz_fmt = "{\n\t%s\n}\n"; + psz_delimiter = "\n\t"; + i_list = 0; } - else if ( answer->child ) { - /* in case everything was requested */ - if ( strcmp( psz_name, "" ) == 0 ) - { - psz_fmt = "{\n\t%s\n}\n"; - psz_delimiter = "\n\t"; - i_list = 0; - } - else - { - psz_fmt = "%s\n"; - psz_delimiter = "\n"; - i_list = 1; - } - if( asprintf( &psz_response, psz_fmt, - recurse_answer( answer, psz_delimiter, i_list ) ) - == -1 ) - { - libvlc_exception_raise( p_exception, "Error in show %s", - psz_name ); - } + else + { + psz_fmt = "%s\n"; + psz_delimiter = "\n"; + i_list = 1; + } + if( asprintf( &psz_response, psz_fmt, + recurse_answer( answer, psz_delimiter, i_list ) ) == -1 ) + { + libvlc_exception_raise( p_exception ); + libvlc_printerr( "Out of memory" ); } } free( psz_message ); @@ -429,8 +427,10 @@ void libvlc_vlm_add_broadcast( libvlc_instance_t *p_instance, n = vlm_Control( p_vlm, VLM_ADD_MEDIA, &m, NULL ); vlm_media_Clean( &m ); if( n ) - libvlc_exception_raise( p_exception, "Media %s creation failed", - psz_name ); + { + libvlc_exception_raise( p_exception ); + libvlc_printerr( "Media %s creation failed", psz_name ); + } } void libvlc_vlm_add_vod( libvlc_instance_t *p_instance, const char *psz_name, @@ -457,8 +457,10 @@ void libvlc_vlm_add_vod( libvlc_instance_t *p_instance, const char *psz_name, n = vlm_Control( p_vlm, VLM_ADD_MEDIA, &m, NULL ); vlm_media_Clean( &m ); if( n ) - libvlc_exception_raise( p_exception, "Media %s creation failed", - psz_name ); + { + libvlc_exception_raise( p_exception ); + libvlc_printerr( "Media %s creation failed", psz_name ); + } } void libvlc_vlm_del_media( libvlc_instance_t *p_instance, const char *psz_name, @@ -472,7 +474,8 @@ void libvlc_vlm_del_media( libvlc_instance_t *p_instance, const char *psz_name, if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) || vlm_Control( p_vlm, VLM_DEL_MEDIA, id ) ) { - libvlc_exception_raise( p_exception, "Unable to delete %s", psz_name ); + libvlc_exception_raise( p_exception ); + libvlc_printerr( "Unable to delete %s", psz_name ); } } @@ -483,7 +486,8 @@ void libvlc_vlm_del_media( libvlc_instance_t *p_instance, const char *psz_name, VLM(p_vlm); \ if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) || \ vlm_Control( p_vlm, VLM_GET_MEDIA, id, &p_media ) ) { \ - libvlc_exception_raise( p_exception, psz_error, psz_name ); \ + libvlc_exception_raise( p_exception ); \ + libvlc_printerr( psz_error, psz_name ); \ return; \ } \ if( !p_media ) goto error; \ @@ -497,7 +501,8 @@ void libvlc_vlm_del_media( libvlc_instance_t *p_instance, const char *psz_name, vlm_media_Delete( p_media ); \ return; \ error: \ - libvlc_exception_raise( p_exception, psz_error, psz_name );\ + libvlc_exception_raise( p_exception ); \ + libvlc_printerr( psz_error, psz_name ); \ } while(0) void libvlc_vlm_set_enabled( libvlc_instance_t *p_instance, @@ -598,7 +603,8 @@ void libvlc_vlm_play_media( libvlc_instance_t *p_instance, if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) || vlm_Control( p_vlm, VLM_START_MEDIA_BROADCAST_INSTANCE, id, NULL, 0 ) ) { - libvlc_exception_raise( p_exception, "Unable to play %s", psz_name ); + libvlc_exception_raise( p_exception ); + libvlc_printerr( "Unable to play %s", psz_name ); } } @@ -614,7 +620,8 @@ void libvlc_vlm_stop_media( libvlc_instance_t *p_instance, if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) || vlm_Control( p_vlm, VLM_STOP_MEDIA_INSTANCE, id, NULL ) ) { - libvlc_exception_raise( p_exception, "Unable to stop %s", psz_name ); + libvlc_exception_raise( p_exception ); + libvlc_printerr( "Unable to stop %s", psz_name ); } } @@ -630,7 +637,8 @@ void libvlc_vlm_pause_media( libvlc_instance_t *p_instance, if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) || vlm_Control( p_vlm, VLM_PAUSE_MEDIA_INSTANCE, id, NULL ) ) { - libvlc_exception_raise( p_exception, "Unable to pause %s", psz_name ); + libvlc_exception_raise( p_exception ); + libvlc_printerr( "Unable to pause %s", psz_name ); } } @@ -646,8 +654,10 @@ void libvlc_vlm_seek_media( libvlc_instance_t *p_instance, if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) || vlm_Control( p_vlm, VLM_SET_MEDIA_INSTANCE_POSITION, id, NULL, f_percentage ) ) - libvlc_exception_raise( p_exception, "Unable to seek %s to %f", - psz_name, f_percentage ); + { + libvlc_exception_raise( p_exception ); + libvlc_printerr( "Unable to seek %s to %f%%", psz_name, f_percentage ); + } } float libvlc_vlm_get_media_instance_position( libvlc_instance_t *p_instance,