X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcontrol%2Fmedia_player.c;h=4901319f47340e20e9ed7db7b34b4128e4690cbe;hb=7e30f80eed086fafd1583b4e852a550ecc118d32;hp=b189c390fd99944dccf186a042815bbd5a5fed04;hpb=556953c4c2ec361c1d5508702083b76edf89cb4d;p=vlc diff --git a/src/control/media_player.c b/src/control/media_player.c index b189c390fd..4901319f47 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 ); /* @@ -111,10 +126,6 @@ static void release_input_thread( libvlc_media_player_t *p_mi, bool b_input_abor /* Store the input resource for future use. */ p_mi->p_input_resource = input_DetachResource( p_input_thread ); - var_Destroy( p_input_thread, "drawable-hwnd" ); - var_Destroy( p_input_thread, "drawable-xid" ); - var_Destroy( p_input_thread, "drawable-agl" ); - vlc_object_release( p_input_thread ); p_mi->p_input_thread = NULL; @@ -126,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; } /* @@ -160,19 +209,21 @@ 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); - - libvlc_media_release(media); + + libvlc_media_release(media); } } @@ -258,7 +309,7 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd, default: return VLC_SUCCESS; } - + set_state( p_mi, libvlc_state, false ); libvlc_event_send( p_mi->p_event_manager, &event ); } @@ -294,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; @@ -318,7 +379,91 @@ 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); + + libvlc_media_player_t *mp = p_data; + libvlc_event_t event; + event.type = libvlc_MediaPlayerMouseMoved; + event.u.media_player_mouse_moved.x = newval.coords.x; + event.u.media_player_mouse_moved.y = newval.coords.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 input_thread_t *find_input (vlc_object_t *obj) +{ + libvlc_media_player_t *mp = (libvlc_media_player_t *)obj; + input_thread_t *p_input; + + lock (mp); + p_input = mp->p_input_thread; + if (p_input) + vlc_object_hold (p_input); + unlock (mp); + return p_input; +} + +/* */ static void libvlc_media_player_destroy( libvlc_media_player_t * ); @@ -337,34 +482,81 @@ 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; assert(instance); - mp = malloc(sizeof(libvlc_media_player_t)); - if (!mp) + mp = vlc_object_create (instance->p_libvlc_int, sizeof(*mp)); + if (unlikely(mp == NULL)) { - libvlc_exception_raise(e); libvlc_printerr("Not enough memory"); return NULL; } + vlc_object_attach (mp, mp->p_libvlc); + + /* Video */ + var_Create (mp, "drawable-xid", VLC_VAR_INTEGER); +#ifdef WIN32 + var_Create (mp, "drawable-hwnd", VLC_VAR_ADDRESS); +#endif +#ifdef __APPLE__ + var_Create (mp, "drawable-agl", VLC_VAR_INTEGER); + var_Create (mp, "drawable-nsobject", VLC_VAR_ADDRESS); +#endif + + 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); + var_Create (mp, "find-input-callback", VLC_VAR_ADDRESS); + var_SetAddress (mp, "find-input-callback", find_input); + mp->p_md = NULL; - mp->drawable.agl = 0; - mp->drawable.xid = 0; - mp->drawable.hwnd = NULL; - mp->drawable.nsobject = NULL; - mp->keyboard_events = mp->mouse_events = 1; 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)) { - free(mp); + vlc_object_release(mp); return NULL; } vlc_mutex_init(&mp->object_lock); @@ -392,6 +584,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 @@ -399,8 +597,9 @@ libvlc_media_player_new( libvlc_instance_t *instance, libvlc_exception_t *e ) * FIXME: It's unclear why we want to put this in public API, and why we * want to expose it in such a limiting and ugly way. */ - var_AddCallback(instance->p_libvlc_int, "snapshot-file", snapshot_was_taken, mp); + var_AddCallback(mp->p_libvlc, "snapshot-file", snapshot_was_taken, mp); + libvlc_retain(instance); return mp; } @@ -408,13 +607,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; @@ -434,7 +631,7 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi ) assert( p_mi ); /* Detach Callback from the main libvlc object */ - var_DelCallback( p_mi->p_libvlc_instance->p_libvlc_int, + var_DelCallback( p_mi->p_libvlc, "snapshot-file", snapshot_was_taken, p_mi ); /* If the input thread hasn't been already deleted it means @@ -442,19 +639,25 @@ 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 ) { input_resource_Delete( p_mi->p_input_resource ); - p_mi->p_input_resource = NULL; + p_mi->p_input_resource = NULL; } libvlc_event_manager_release( p_mi->p_event_manager ); libvlc_media_release( p_mi->p_md ); vlc_mutex_destroy( &p_mi->object_lock ); - free( p_mi ); + + libvlc_instance_t *instance = p_mi->p_libvlc_instance; + vlc_object_release( p_mi ); + libvlc_release(instance); } /************************************************************************** @@ -532,7 +735,7 @@ void libvlc_media_player_set_media( event.type = libvlc_MediaPlayerMediaChanged; event.u.media_player_media_changed.new_media = p_md; libvlc_event_send( p_mi->p_event_manager, &event ); - + } /************************************************************************** @@ -563,65 +766,41 @@ 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->p_libvlc_instance->p_libvlc_int, - p_mi->p_md->p_input_item, NULL, p_mi->p_input_resource ); - + p_mi->p_input_thread = input_Create( p_mi, + p_mi->p_md->p_input_item, NULL, + p_mi->p_input_resource ); if( !p_mi->p_input_thread ) { unlock(p_mi); - return; + libvlc_printerr( "Not enough memory" ); + return -1; } p_mi->p_input_resource = NULL; p_input_thread = p_mi->p_input_thread; - var_Create( p_input_thread, "drawable-agl", VLC_VAR_INTEGER ); - if( p_mi->drawable.agl ) - var_SetInteger( p_input_thread, "drawable-agl", p_mi->drawable.agl ); - - var_Create( p_input_thread, "drawable-xid", VLC_VAR_INTEGER ); - if( p_mi->drawable.xid ) - var_SetInteger( p_input_thread, "drawable-xid", p_mi->drawable.xid ); - - var_Create( p_input_thread, "drawable-hwnd", VLC_VAR_ADDRESS ); - if( p_mi->drawable.hwnd != NULL ) - var_SetAddress( p_input_thread, "drawable-hwnd", p_mi->drawable.hwnd ); - - var_Create( p_input_thread, "drawable-nsobject", VLC_VAR_ADDRESS ); - if( p_mi->drawable.nsobject != NULL ) - var_SetAddress( p_input_thread, "drawable-nsobject", p_mi->drawable.nsobject ); - - var_Create( p_input_thread, "keyboard-events", VLC_VAR_BOOL ); - var_SetBool( p_input_thread, "keyboard-events", p_mi->keyboard_events ); - var_Create( p_input_thread, "mouse-events", VLC_VAR_BOOL ); - var_SetBool( p_input_thread, "mouse-events", p_mi->mouse_events ); - var_AddCallback( p_input_thread, "can-seek", input_seekable_changed, p_mi ); var_AddCallback( p_input_thread, "can-pause", input_pausable_changed, p_mi ); var_AddCallback( p_input_thread, "intf-event", input_event_changed, p_mi ); @@ -633,22 +812,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 ); @@ -700,7 +879,12 @@ void libvlc_media_player_stop( libvlc_media_player_t *p_mi ) void libvlc_media_player_set_nsobject( libvlc_media_player_t *p_mi, void * drawable ) { - p_mi->drawable.nsobject = drawable; + assert (p_mi != NULL); +#ifdef __APPLE__ + var_SetAddress (p_mi, "drawable-nsobject", drawable); +#else + (void) p_mi; (void)drawable; +#endif } /************************************************************************** @@ -708,7 +892,12 @@ void libvlc_media_player_set_nsobject( libvlc_media_player_t *p_mi, **************************************************************************/ void * libvlc_media_player_get_nsobject( libvlc_media_player_t *p_mi ) { - return p_mi->drawable.nsobject; + assert (p_mi != NULL); +#ifdef __APPLE__ + return var_GetAddress (p_mi, "drawable-nsobject"); +#else + return NULL; +#endif } /************************************************************************** @@ -717,7 +906,11 @@ void * libvlc_media_player_get_nsobject( libvlc_media_player_t *p_mi ) void libvlc_media_player_set_agl( libvlc_media_player_t *p_mi, uint32_t drawable ) { - p_mi->drawable.agl = drawable; +#ifdef __APPLE__ + var_SetInteger (p_mi, "drawable-agl", drawable); +#else + (void) p_mi; (void)drawable; +#endif } /************************************************************************** @@ -725,7 +918,12 @@ void libvlc_media_player_set_agl( libvlc_media_player_t *p_mi, **************************************************************************/ uint32_t libvlc_media_player_get_agl( libvlc_media_player_t *p_mi ) { - return p_mi->drawable.agl; + assert (p_mi != NULL); +#ifdef __APPLE__ + return var_GetInteger (p_mi, "drawable-agl"); +#else + return 0; +#endif } /************************************************************************** @@ -734,7 +932,8 @@ uint32_t libvlc_media_player_get_agl( libvlc_media_player_t *p_mi ) void libvlc_media_player_set_xwindow( libvlc_media_player_t *p_mi, uint32_t drawable ) { - p_mi->drawable.xid = drawable; + assert (p_mi != NULL); + var_SetInteger (p_mi, "drawable-xid", drawable); } /************************************************************************** @@ -742,7 +941,7 @@ void libvlc_media_player_set_xwindow( libvlc_media_player_t *p_mi, **************************************************************************/ uint32_t libvlc_media_player_get_xwindow( libvlc_media_player_t *p_mi ) { - return p_mi->drawable.xid; + return var_GetInteger (p_mi, "drawable-xid"); } /************************************************************************** @@ -751,7 +950,12 @@ uint32_t libvlc_media_player_get_xwindow( libvlc_media_player_t *p_mi ) void libvlc_media_player_set_hwnd( libvlc_media_player_t *p_mi, void *drawable ) { - p_mi->drawable.hwnd = drawable; + assert (p_mi != NULL); +#ifdef WIN32 + var_SetAddress (p_mi, "drawable-hwnd", drawable); +#else + (void) p_mi; (void) drawable; +#endif } /************************************************************************** @@ -759,20 +963,24 @@ void libvlc_media_player_set_hwnd( libvlc_media_player_t *p_mi, **************************************************************************/ void *libvlc_media_player_get_hwnd( libvlc_media_player_t *p_mi ) { - return p_mi->drawable.hwnd; + assert (p_mi != NULL); +#ifdef WIN32 + return var_GetAddress (p_mi, "drawable-hwnd"); +#else + return NULL; +#endif } /************************************************************************** * 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; @@ -782,14 +990,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; @@ -798,14 +1004,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; @@ -813,14 +1017,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; @@ -828,14 +1030,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; @@ -845,14 +1045,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; @@ -860,14 +1058,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; @@ -877,14 +1073,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; @@ -896,13 +1090,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; @@ -919,14 +1112,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; @@ -940,14 +1131,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; @@ -957,14 +1146,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; @@ -974,13 +1161,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; @@ -991,13 +1176,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; @@ -1008,11 +1191,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 ) @@ -1024,12 +1205,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; @@ -1039,40 +1219,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 */ @@ -1097,19 +1272,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 ); @@ -1119,10 +1289,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; @@ -1140,7 +1309,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; } @@ -1155,7 +1323,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; } @@ -1190,36 +1357,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" ); - } }