X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcontrol%2Fmedia_player.c;h=ba2c1890f764faafe5a6f88bcbef86a463791d24;hb=e22624799da7c67a3cfa6ab366927d2ddc985a01;hp=e8f937948f7cb89240fe186d1847d52a5580fd12;hpb=8f9c3647ccfcd55cd6835ed90e98766a7f2eb677;p=vlc diff --git a/src/control/media_player.c b/src/control/media_player.c index e8f937948f..ba2c1890f7 100644 --- a/src/control/media_player.c +++ b/src/control/media_player.c @@ -58,6 +58,21 @@ static int snapshot_was_taken( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ); +/* Mouse events */ +static int +mouse_moved( vlc_object_t *p_this, char const *psz_cmd, + vlc_value_t oldval, vlc_value_t newval, void *p_data ); +static int +mouse_button( vlc_object_t *p_this, char const *psz_cmd, + vlc_value_t oldval, vlc_value_t newval, void *p_data ); +static int +mouse_clicked( vlc_object_t *p_this, char const *psz_cmd, + vlc_value_t oldval, vlc_value_t newval, void *p_data ); +static int +mouse_object( vlc_object_t *p_this, char const *psz_cmd, + vlc_value_t oldval, vlc_value_t newval, void *p_data ); + +/* */ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi ); /* @@ -122,27 +137,65 @@ static void release_input_thread( libvlc_media_player_t *p_mi, bool b_input_abor * * Function will lock the object. */ -input_thread_t *libvlc_get_input_thread( libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +input_thread_t *libvlc_get_input_thread( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; - if( !p_mi ) RAISENULL( "Media Instance is NULL" ); + assert( p_mi ); lock(p_mi); + p_input_thread = p_mi->p_input_thread; + if( p_input_thread ) + vlc_object_hold( p_input_thread ); + else + libvlc_printerr( "No active input" ); + unlock(p_mi); - if( !p_mi->p_input_thread ) + return p_input_thread; +} + +/* + * Get vout thread from current input + * + * Object lock is NOT held. + */ +static vout_thread_t *get_vout_thread( libvlc_media_player_t *p_mi ) +{ + vout_thread_t *p_vout_thread; + + p_vout_thread = input_GetVout( p_mi->p_input_thread ); + if( p_vout_thread ) { - unlock(p_mi); - RAISENULL( "Input is NULL" ); + var_AddCallback( p_vout_thread, "mouse-button-down", mouse_button, p_mi ); + var_AddCallback( p_vout_thread, "mouse-moved", mouse_moved, p_mi ); + var_AddCallback( p_vout_thread, "mouse-clicked", mouse_clicked, p_mi ); + var_AddCallback( p_vout_thread, "mouse-object", mouse_object, p_mi ); } - p_input_thread = p_mi->p_input_thread; - vlc_object_hold( p_input_thread ); + return p_vout_thread; +} - unlock(p_mi); +/* + * Release the associated vout thread. + * + * Object lock is NOT held. + */ +static void release_vout_thread( libvlc_media_player_t *p_mi ) +{ + vout_thread_t *p_vout_thread; - return p_input_thread; + if( !p_mi || !p_mi->p_vout_thread ) + return; + + p_vout_thread = p_mi->p_vout_thread; + + var_DelCallback( p_vout_thread, "mouse-button-down", mouse_button, p_mi ); + var_DelCallback( p_vout_thread, "mouse-moved", mouse_moved, p_mi ); + var_DelCallback( p_vout_thread, "mouse-clicked", mouse_clicked, p_mi ); + var_DelCallback( p_vout_thread, "mouse-object", mouse_object, p_mi ); + + vlc_object_release( p_vout_thread ); + p_mi->p_vout_thread = NULL; } /* @@ -156,14 +209,16 @@ static void set_state( libvlc_media_player_t *p_mi, libvlc_state_t state, if(!b_locked) lock(p_mi); p_mi->state = state; + libvlc_media_t *media = p_mi->p_md; if (media) libvlc_media_retain(media); + if(!b_locked) unlock(p_mi); - - if (media) { + if (media) + { // Also set the state of the corresponding media // This is strictly for convenience. libvlc_media_set_state(media, state); @@ -290,6 +345,16 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd, from_mtime(var_GetTime( p_input, "length" )); libvlc_event_send( p_mi->p_event_manager, &event ); } + else if( newval.i_int == INPUT_EVENT_VOUT ) + { + lock( p_mi ); + /* release old vout */ + if( p_mi->p_vout_thread ) + release_vout_thread( p_mi ); + /* remember new vout */ + p_mi->p_vout_thread = get_vout_thread( p_mi ); + unlock( p_mi ); + } return VLC_SUCCESS; @@ -314,7 +379,78 @@ static int snapshot_was_taken(vlc_object_t *p_this, char const *psz_cmd, return VLC_SUCCESS; } +/************************************************************************** + * Mouse Events. + *************************************************************************/ + +static int +mouse_moved( vlc_object_t *p_this, char const *psz_cmd, + vlc_value_t oldval, vlc_value_t newval, void *p_data ) +{ + VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_this); VLC_UNUSED(newval); + + libvlc_media_player_t *mp = p_data; + libvlc_event_t event; + event.type = libvlc_MediaPlayerMouseMoved; + event.u.media_player_mouse_moved.x = var_GetInteger( mp->p_vout_thread, "mouse-x" ); + event.u.media_player_mouse_moved.y = var_GetInteger( mp->p_vout_thread, "mouse-y" ); + libvlc_event_send(mp->p_event_manager, &event); + + return VLC_SUCCESS; +} + +static int +mouse_button( vlc_object_t *p_this, char const *psz_cmd, + vlc_value_t oldval, vlc_value_t newval, void *p_data ) +{ + VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_this); + + libvlc_media_player_t *mp = p_data; + libvlc_event_t event; + int pressed = newval.i_int; + + event.type = libvlc_MediaPlayerMouseButton; + event.u.media_player_mouse_button.mb_left = (pressed & (1<p_event_manager, &event); + + return VLC_SUCCESS; +} + +static int +mouse_clicked( vlc_object_t *p_this, char const *psz_cmd, + vlc_value_t oldval, vlc_value_t newval, void *p_data ) +{ + VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_this); + + libvlc_media_player_t *mp = p_data; + libvlc_event_t event; + event.type = libvlc_MediaPlayerMouseClick; + event.u.media_player_mouse_clicked.clicked = newval.b_bool ? 1 : 0; + libvlc_event_send(mp->p_event_manager, &event); + + return VLC_SUCCESS; +} + +static int +mouse_object( vlc_object_t *p_this, char const *psz_cmd, + vlc_value_t oldval, vlc_value_t newval, void *p_data ) +{ + VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_this); + + libvlc_media_player_t *mp = p_data; + libvlc_event_t event; + event.type = libvlc_MediaPlayerMouseObject; + event.u.media_player_mouse_object.moved = (newval.b_bool ? 1 : 0); + libvlc_event_send(mp->p_event_manager, &event); + + return VLC_SUCCESS; +} +/* */ static void libvlc_media_player_destroy( libvlc_media_player_t * ); @@ -333,7 +469,7 @@ static void libvlc_media_player_destroy( libvlc_media_player_t * ); * - When attempting to destroy the object the lock is also held. **************************************************************************/ libvlc_media_player_t * -libvlc_media_player_new( libvlc_instance_t *instance, libvlc_exception_t *e ) +libvlc_media_player_new( libvlc_instance_t *instance ) { libvlc_media_player_t * mp; @@ -347,7 +483,7 @@ libvlc_media_player_new( libvlc_instance_t *instance, libvlc_exception_t *e ) } vlc_object_attach (mp, mp->p_libvlc); - /* Drawable */ + /* Video */ var_Create (mp, "drawable-xid", VLC_VAR_INTEGER); #ifdef WIN32 var_Create (mp, "drawable-hwnd", VLC_VAR_ADDRESS); @@ -357,16 +493,50 @@ libvlc_media_player_new( libvlc_instance_t *instance, libvlc_exception_t *e ) var_Create (mp, "drawable-nsobject", VLC_VAR_ADDRESS); #endif - /* Drawable input methods */ var_Create (mp, "keyboard-events", VLC_VAR_BOOL); var_SetBool (mp, "keyboard-events", true); var_Create (mp, "mouse-events", VLC_VAR_BOOL); + var_SetBool (mp, "mouse-events", true); + + var_Create (mp, "fullscreen", VLC_VAR_BOOL); + var_Create (mp, "autoscale", VLC_VAR_BOOL); + var_SetBool (mp, "autoscale", true); + var_Create (mp, "scale", VLC_VAR_FLOAT); + var_SetFloat (mp, "scale", 1.); + var_Create (mp, "aspect-ratio", VLC_VAR_STRING); + var_Create (mp, "crop", VLC_VAR_STRING); + var_Create (mp, "deinterlace", VLC_VAR_INTEGER); + var_Create (mp, "deinterlace-mode", VLC_VAR_STRING); + + var_Create (mp, "vbi-page", VLC_VAR_INTEGER); + + var_Create (mp, "marq-marquee", VLC_VAR_STRING); + var_Create (mp, "marq-color", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "marq-opacity", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "marq-position", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "marq-refresh", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "marq-size", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "marq-timeout", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "marq-x", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "marq-y", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + + var_Create (mp, "logo-file", VLC_VAR_STRING); + var_Create (mp, "logo-x", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "logo-y", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "logo-delay", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "logo-repeat", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "logo-opacity", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "logo-position", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + + /* Audio */ + var_Create (mp, "aout", VLC_VAR_STRING | VLC_VAR_DOINHERIT); mp->p_md = NULL; mp->state = libvlc_NothingSpecial; mp->p_libvlc_instance = instance; mp->p_input_thread = NULL; mp->p_input_resource = NULL; + mp->p_vout_thread = NULL; mp->i_refcount = 1; mp->p_event_manager = libvlc_event_manager_new(mp, instance); if (unlikely(mp->p_event_manager == NULL)) @@ -399,6 +569,12 @@ libvlc_media_player_new( libvlc_instance_t *instance, libvlc_exception_t *e ) register_event(mp, MediaChanged); + /* mouse events */ + register_event(mp, MouseMoved); + register_event(mp, MouseButton); + register_event(mp, MouseClick); + register_event(mp, MouseObject); + /* Attach a var callback to the global object to provide the glue between * vout_thread that generates the event and media_player that re-emits it * with its own event manager @@ -408,6 +584,7 @@ libvlc_media_player_new( libvlc_instance_t *instance, libvlc_exception_t *e ) */ var_AddCallback(mp->p_libvlc, "snapshot-file", snapshot_was_taken, mp); + libvlc_retain(instance); return mp; } @@ -415,13 +592,11 @@ libvlc_media_player_new( libvlc_instance_t *instance, libvlc_exception_t *e ) * Create a Media Instance object with a media descriptor. **************************************************************************/ libvlc_media_player_t * -libvlc_media_player_new_from_media( - libvlc_media_t * p_md, - libvlc_exception_t *p_e ) +libvlc_media_player_new_from_media( libvlc_media_t * p_md ) { libvlc_media_player_t * p_mi; - p_mi = libvlc_media_player_new( p_md->p_libvlc_instance, p_e ); + p_mi = libvlc_media_player_new( p_md->p_libvlc_instance ); if( !p_mi ) return NULL; @@ -449,7 +624,10 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi ) assert(!p_mi->p_input_thread); /* Fallback for those who don't use NDEBUG */ - if (p_mi->p_input_thread) + if( p_mi->p_vout_thread ) + release_vout_thread( p_mi ); + + if(p_mi->p_input_thread ) release_input_thread(p_mi, true); if( p_mi->p_input_resource ) @@ -461,7 +639,10 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi ) libvlc_event_manager_release( p_mi->p_event_manager ); libvlc_media_release( p_mi->p_md ); vlc_mutex_destroy( &p_mi->object_lock ); + + libvlc_instance_t *instance = p_mi->p_libvlc_instance; vlc_object_release( p_mi ); + libvlc_release(instance); } /************************************************************************** @@ -570,30 +751,26 @@ libvlc_media_player_event_manager( libvlc_media_player_t *p_mi ) /************************************************************************** * Tell media player to start playing. **************************************************************************/ -void libvlc_media_player_play( libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +int libvlc_media_player_play( libvlc_media_player_t *p_mi ) { input_thread_t * p_input_thread; - if( (p_input_thread = libvlc_get_input_thread( p_mi, p_e )) ) + if( (p_input_thread = libvlc_get_input_thread( p_mi )) ) { /* A thread already exists, send it a play message */ input_Control( p_input_thread, INPUT_SET_STATE, PLAYING_S ); vlc_object_release( p_input_thread ); - return; + return 0; } /* Ignore previous exception */ - libvlc_exception_clear( p_e ); - lock(p_mi); if( !p_mi->p_md ) { unlock(p_mi); - libvlc_exception_raise( p_e ); libvlc_printerr( "No associated media descriptor" ); - return; + return -1; } p_mi->p_input_thread = input_Create( p_mi, @@ -602,7 +779,8 @@ void libvlc_media_player_play( libvlc_media_player_t *p_mi, if( !p_mi->p_input_thread ) { unlock(p_mi); - return; + libvlc_printerr( "Not enough memory" ); + return -1; } p_mi->p_input_resource = NULL; @@ -619,22 +797,22 @@ void libvlc_media_player_play( libvlc_media_player_t *p_mi, } unlock(p_mi); + return 0; } /************************************************************************** * Pause. **************************************************************************/ -void libvlc_media_player_pause( libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +void libvlc_media_player_pause( libvlc_media_player_t *p_mi ) { - input_thread_t * p_input_thread = libvlc_get_input_thread( p_mi, p_e ); + input_thread_t * p_input_thread = libvlc_get_input_thread( p_mi ); if( !p_input_thread ) return; libvlc_state_t state = libvlc_media_player_get_state( p_mi ); if( state == libvlc_Playing || state == libvlc_Buffering ) { - if( libvlc_media_player_can_pause( p_mi, p_e ) ) + if( libvlc_media_player_can_pause( p_mi ) ) input_Control( p_input_thread, INPUT_SET_STATE, PAUSE_S ); else libvlc_media_player_stop( p_mi ); @@ -782,13 +960,12 @@ void *libvlc_media_player_get_hwnd( libvlc_media_player_t *p_mi ) * Getters for stream information **************************************************************************/ libvlc_time_t libvlc_media_player_get_length( - libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) + libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; libvlc_time_t i_time; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return -1; @@ -798,14 +975,12 @@ libvlc_time_t libvlc_media_player_get_length( return i_time; } -libvlc_time_t libvlc_media_player_get_time( - libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +libvlc_time_t libvlc_media_player_get_time( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; libvlc_time_t i_time; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return -1; @@ -814,14 +989,12 @@ libvlc_time_t libvlc_media_player_get_time( return i_time; } -void libvlc_media_player_set_time( - libvlc_media_player_t *p_mi, - libvlc_time_t i_time, - libvlc_exception_t *p_e ) +void libvlc_media_player_set_time( libvlc_media_player_t *p_mi, + libvlc_time_t i_time ) { input_thread_t *p_input_thread; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return; @@ -829,14 +1002,12 @@ void libvlc_media_player_set_time( vlc_object_release( p_input_thread ); } -void libvlc_media_player_set_position( - libvlc_media_player_t *p_mi, - float position, - libvlc_exception_t *p_e ) +void libvlc_media_player_set_position( libvlc_media_player_t *p_mi, + float position ) { input_thread_t *p_input_thread; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return; @@ -844,14 +1015,12 @@ void libvlc_media_player_set_position( vlc_object_release( p_input_thread ); } -float libvlc_media_player_get_position( - libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +float libvlc_media_player_get_position( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; float f_position; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return -1.0; @@ -861,14 +1030,12 @@ float libvlc_media_player_get_position( return f_position; } -void libvlc_media_player_set_chapter( - libvlc_media_player_t *p_mi, - int chapter, - libvlc_exception_t *p_e ) +void libvlc_media_player_set_chapter( libvlc_media_player_t *p_mi, + int chapter ) { input_thread_t *p_input_thread; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return; @@ -876,14 +1043,12 @@ void libvlc_media_player_set_chapter( vlc_object_release( p_input_thread ); } -int libvlc_media_player_get_chapter( - libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +int libvlc_media_player_get_chapter( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; int i_chapter; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return -1; @@ -893,14 +1058,12 @@ int libvlc_media_player_get_chapter( return i_chapter; } -int libvlc_media_player_get_chapter_count( - libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +int libvlc_media_player_get_chapter_count( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; vlc_value_t val; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return -1; @@ -912,13 +1075,12 @@ int libvlc_media_player_get_chapter_count( int libvlc_media_player_get_chapter_count_for_title( libvlc_media_player_t *p_mi, - int i_title, - libvlc_exception_t *p_e ) + int i_title ) { input_thread_t *p_input_thread; vlc_value_t val; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return -1; @@ -935,14 +1097,12 @@ int libvlc_media_player_get_chapter_count_for_title( return val.i_int; } -void libvlc_media_player_set_title( - libvlc_media_player_t *p_mi, - int i_title, - libvlc_exception_t *p_e ) +void libvlc_media_player_set_title( libvlc_media_player_t *p_mi, + int i_title ) { input_thread_t *p_input_thread; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return; @@ -956,14 +1116,12 @@ void libvlc_media_player_set_title( libvlc_event_send( p_mi->p_event_manager, &event ); } -int libvlc_media_player_get_title( - libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +int libvlc_media_player_get_title( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; int i_title; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return -1; @@ -973,14 +1131,12 @@ int libvlc_media_player_get_title( return i_title; } -int libvlc_media_player_get_title_count( - libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +int libvlc_media_player_get_title_count( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; vlc_value_t val; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return -1; @@ -990,13 +1146,11 @@ int libvlc_media_player_get_title_count( return val.i_int; } -void libvlc_media_player_next_chapter( - libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +void libvlc_media_player_next_chapter( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return; @@ -1007,13 +1161,11 @@ void libvlc_media_player_next_chapter( vlc_object_release( p_input_thread ); } -void libvlc_media_player_previous_chapter( - libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +void libvlc_media_player_previous_chapter( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return; @@ -1024,11 +1176,9 @@ void libvlc_media_player_previous_chapter( vlc_object_release( p_input_thread ); } -float libvlc_media_player_get_fps( - libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e) +float libvlc_media_player_get_fps( libvlc_media_player_t *p_mi ) { - input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi ); double f_fps = 0.0; if( p_input_thread ) @@ -1040,12 +1190,11 @@ float libvlc_media_player_get_fps( return f_fps; } -int libvlc_media_player_will_play( libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e) +int libvlc_media_player_will_play( libvlc_media_player_t *p_mi ) { bool b_will_play; input_thread_t *p_input_thread = - libvlc_get_input_thread ( p_mi, p_e); + libvlc_get_input_thread ( p_mi ); if ( !p_input_thread ) return false; @@ -1055,40 +1204,35 @@ int libvlc_media_player_will_play( libvlc_media_player_t *p_mi, return b_will_play; } -void libvlc_media_player_set_rate( - libvlc_media_player_t *p_mi, - float rate, - libvlc_exception_t *p_e ) +int libvlc_media_player_set_rate( libvlc_media_player_t *p_mi, float rate ) { input_thread_t *p_input_thread; bool b_can_rewind; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) - return; + return -1; b_can_rewind = var_GetBool( p_input_thread, "can-rewind" ); if( (rate < 0.0) && !b_can_rewind ) { vlc_object_release( p_input_thread ); - libvlc_exception_raise( p_e ); libvlc_printerr( "Invalid playback rate" ); - return; + return -1; } var_SetFloat( p_input_thread, "rate", rate ); vlc_object_release( p_input_thread ); + return 0; } -float libvlc_media_player_get_rate( - libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +float libvlc_media_player_get_rate( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; float f_rate; bool b_can_rewind; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + p_input_thread = libvlc_get_input_thread ( p_mi ); if( !p_input_thread ) return 0.0; /* rate < 0 indicates rewind */ @@ -1113,19 +1257,14 @@ libvlc_state_t libvlc_media_player_get_state( libvlc_media_player_t *p_mi ) return state; } -int libvlc_media_player_is_seekable( libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +int libvlc_media_player_is_seekable( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; bool b_seekable; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + p_input_thread = libvlc_get_input_thread ( p_mi ); if ( !p_input_thread ) - { - /* We do return the right value, no need to throw an exception */ - clear_if_needed(p_e); return false; - } b_seekable = var_GetBool( p_input_thread, "can-seek" ); vlc_object_release( p_input_thread ); @@ -1135,10 +1274,9 @@ int libvlc_media_player_is_seekable( libvlc_media_player_t *p_mi, /* internal function, used by audio, video */ libvlc_track_description_t * libvlc_get_track_description( libvlc_media_player_t *p_mi, - const char *psz_variable, - libvlc_exception_t *p_e ) + const char *psz_variable ) { - input_thread_t *p_input = libvlc_get_input_thread( p_mi, p_e ); + input_thread_t *p_input = libvlc_get_input_thread( p_mi ); libvlc_track_description_t *p_track_description = NULL, *p_actual, *p_previous; @@ -1156,7 +1294,6 @@ libvlc_track_description_t * malloc( sizeof( libvlc_track_description_t ) ); if ( !p_track_description ) { - libvlc_exception_raise( p_e ); libvlc_printerr( "Not enough memory" ); goto end; } @@ -1171,7 +1308,6 @@ libvlc_track_description_t * if ( !p_actual ) { libvlc_track_description_release( p_track_description ); - libvlc_exception_raise( p_e ); libvlc_printerr( "Not enough memory" ); goto end; } @@ -1206,36 +1342,26 @@ void libvlc_track_description_release( libvlc_track_description_t *p_td ) } } -int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi, - libvlc_exception_t *p_e ) +int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; bool b_can_pause; - p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + p_input_thread = libvlc_get_input_thread ( p_mi ); if ( !p_input_thread ) - { - /* We do return the right value, no need to throw an exception */ - clear_if_needed(p_e); return false; - } b_can_pause = var_GetBool( p_input_thread, "can-pause" ); vlc_object_release( p_input_thread ); return b_can_pause; } -void libvlc_media_player_next_frame( libvlc_media_player_t *p_mi, libvlc_exception_t *p_e ) +void libvlc_media_player_next_frame( libvlc_media_player_t *p_mi ) { - input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi, p_e ); + input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi ); if( p_input_thread != NULL ) { var_TriggerCallback( p_input_thread, "frame-next" ); vlc_object_release( p_input_thread ); } - else - { - libvlc_exception_raise( p_e ); - libvlc_printerr( "No active input" ); - } }