#define register_event(a, b) __register_event(a, libvlc_MediaPlayer ## b)
static inline void __register_event(libvlc_media_player_t *mp, libvlc_event_type_t type)
{
- libvlc_event_manager_register_event_type(mp->p_event_manager, type, NULL);
+ libvlc_event_manager_register_event_type(mp->p_event_manager, type);
}
static inline void lock(libvlc_media_player_t *mp)
vlc_mutex_unlock(&mp->object_lock);
}
-static inline void clear_if_needed(libvlc_exception_t *e)
-{
- if (libvlc_exception_raised(e))
- libvlc_exception_clear(e);
-}
-
/*
* Release the associated input thread.
*
*
* Function will lock the media_player.
*/
-static void set_state( libvlc_media_player_t *p_mi, libvlc_state_t state )
-{
- lock(p_mi);
+static void set_state( libvlc_media_player_t *p_mi, libvlc_state_t state,
+ bool b_locked )
+{
+ if(!b_locked)
+ lock(p_mi);
p_mi->state = state;
libvlc_media_t *media = p_mi->p_md;
if (media)
libvlc_media_retain(media);
- unlock(p_mi);
+ if(!b_locked)
+ unlock(p_mi);
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);
}
}
default:
return VLC_SUCCESS;
}
-
- set_state( p_mi, libvlc_state );
+
+ set_state( p_mi, libvlc_state, false );
libvlc_event_send( p_mi->p_event_manager, &event );
}
else if( newval.i_int == INPUT_EVENT_ABORT )
libvlc_state_t libvlc_state = libvlc_Stopped;
event.type = libvlc_MediaPlayerStopped;
- set_state( p_mi, libvlc_state );
+ set_state( p_mi, libvlc_state, false );
libvlc_event_send( p_mi->p_event_manager, &event );
}
else if( newval.i_int == INPUT_EVENT_POSITION )
/* */
event.type = libvlc_MediaPlayerTimeChanged;
event.u.media_player_time_changed.new_time =
- var_GetTime( p_input, "time" );
+ from_mtime(var_GetTime( p_input, "time" ));
libvlc_event_send( p_mi->p_event_manager, &event );
}
else if( newval.i_int == INPUT_EVENT_LENGTH )
{
event.type = libvlc_MediaPlayerLengthChanged;
event.u.media_player_length_changed.new_length =
- var_GetTime( p_input, "length" );
+ from_mtime(var_GetTime( p_input, "length" ));
libvlc_event_send( p_mi->p_event_manager, &event );
}
mp->p_input_thread = NULL;
mp->p_input_resource = NULL;
mp->i_refcount = 1;
- vlc_mutex_init(&mp->object_lock);
- mp->p_event_manager = libvlc_event_manager_new(mp, instance, e);
- if (libvlc_exception_raised(e))
+ mp->p_event_manager = libvlc_event_manager_new(mp, instance);
+ if (unlikely(mp->p_event_manager == NULL))
{
- vlc_mutex_destroy(&mp->object_lock);
free(mp);
return NULL;
}
+ vlc_mutex_init(&mp->object_lock);
register_event(mp, NothingSpecial);
register_event(mp, Opening);
register_event(mp, Backward);
register_event(mp, EndReached);
register_event(mp, EncounteredError);
+ register_event(mp, SeekableChanged);
register_event(mp, PositionChanged);
register_event(mp, TimeChanged);
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 );
**************************************************************************/
void libvlc_media_player_set_media(
libvlc_media_player_t *p_mi,
- libvlc_media_t *p_md,
- libvlc_exception_t *p_e )
+ libvlc_media_t *p_md )
{
- VLC_UNUSED(p_e);
-
lock(p_mi);
/* FIXME I am not sure if it is a user request or on die(eof/error)
p_mi->p_input_thread &&
!p_mi->p_input_thread->b_eof &&
!p_mi->p_input_thread->b_error );
- unlock(p_mi);
-
- set_state( p_mi, libvlc_NothingSpecial );
- lock(p_mi);
+ set_state( p_mi, libvlc_NothingSpecial, true );
libvlc_media_release( p_mi->p_md );
event.type = libvlc_MediaPlayerMediaChanged;
event.u.media_player_media_changed.new_media = p_md;
libvlc_event_send( p_mi->p_event_manager, &event );
-
+
}
/**************************************************************************
* Get the Media descriptor associated with the instance.
**************************************************************************/
libvlc_media_t *
-libvlc_media_player_get_media(
- libvlc_media_player_t *p_mi,
- libvlc_exception_t *p_e )
+libvlc_media_player_get_media( libvlc_media_player_t *p_mi )
{
libvlc_media_t *p_m;
- VLC_UNUSED(p_e);
lock(p_mi);
p_m = p_mi->p_md;
* Get the event Manager.
**************************************************************************/
libvlc_event_manager_t *
-libvlc_media_player_event_manager(
- libvlc_media_player_t *p_mi,
- libvlc_exception_t *p_e )
+libvlc_media_player_event_manager( libvlc_media_player_t *p_mi )
{
- VLC_UNUSED(p_e);
-
return p_mi->p_event_manager;
}
if( !p_input_thread )
return;
- libvlc_state_t state = libvlc_media_player_get_state( p_mi, p_e );
+ 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 ) )
input_Control( p_input_thread, INPUT_SET_STATE, PAUSE_S );
else
- libvlc_media_player_stop( p_mi, p_e );
+ libvlc_media_player_stop( p_mi );
}
else
input_Control( p_input_thread, INPUT_SET_STATE, PLAYING_S );
*
* Enter with lock held.
**************************************************************************/
-int libvlc_media_player_is_playing( libvlc_media_player_t *p_mi,
- libvlc_exception_t *p_e )
+int libvlc_media_player_is_playing( libvlc_media_player_t *p_mi )
{
- libvlc_state_t state = libvlc_media_player_get_state( p_mi, p_e );
+ libvlc_state_t state = libvlc_media_player_get_state( p_mi );
return (libvlc_Playing == state) || (libvlc_Buffering == state);
}
/**************************************************************************
* Stop playing.
**************************************************************************/
-void libvlc_media_player_stop( libvlc_media_player_t *p_mi,
- libvlc_exception_t *p_e )
+void libvlc_media_player_stop( libvlc_media_player_t *p_mi )
{
- libvlc_state_t state = libvlc_media_player_get_state( p_mi, p_e );
+ libvlc_state_t state = libvlc_media_player_get_state( p_mi );
lock(p_mi);
release_input_thread( p_mi, true ); /* This will stop the input thread */
* state. */
if( state != libvlc_Stopped )
{
- set_state( p_mi, libvlc_Stopped );
+ set_state( p_mi, libvlc_Stopped, false );
/* Construct and send the event */
libvlc_event_t event;
* set_nsobject
**************************************************************************/
void libvlc_media_player_set_nsobject( libvlc_media_player_t *p_mi,
- void * drawable,
- libvlc_exception_t *p_e )
+ void * drawable )
{
- (void) p_e;
p_mi->drawable.nsobject = drawable;
}
* set_agl
**************************************************************************/
void libvlc_media_player_set_agl( libvlc_media_player_t *p_mi,
- uint32_t drawable,
- libvlc_exception_t *p_e )
+ uint32_t drawable )
{
- (void) p_e;
p_mi->drawable.agl = drawable;
}
* set_xwindow
**************************************************************************/
void libvlc_media_player_set_xwindow( libvlc_media_player_t *p_mi,
- uint32_t drawable,
- libvlc_exception_t *p_e )
+ uint32_t drawable )
{
- (void) p_e;
p_mi->drawable.xid = drawable;
}
* set_hwnd
**************************************************************************/
void libvlc_media_player_set_hwnd( libvlc_media_player_t *p_mi,
- void *drawable,
- libvlc_exception_t *p_e )
+ void *drawable )
{
- (void) p_e;
p_mi->drawable.hwnd = drawable;
}
if( !p_input_thread )
return -1;
- i_time = var_GetTime( p_input_thread, "length" );
+ i_time = from_mtime(var_GetTime( p_input_thread, "length" ));
vlc_object_release( p_input_thread );
- return (i_time+500LL)/1000LL;
+ return i_time;
}
libvlc_time_t libvlc_media_player_get_time(
if( !p_input_thread )
return -1;
- i_time = var_GetTime( p_input_thread , "time" );
+ i_time = from_mtime(var_GetTime( p_input_thread , "time" ));
vlc_object_release( p_input_thread );
- return (i_time+500LL)/1000LL;
+ return i_time;
}
void libvlc_media_player_set_time(
if( !p_input_thread )
return;
- var_SetTime( p_input_thread, "time", i_time*1000LL );
+ var_SetTime( p_input_thread, "time", to_mtime(i_time) );
vlc_object_release( p_input_thread );
}
return f_rate;
}
-libvlc_state_t libvlc_media_player_get_state( libvlc_media_player_t *p_mi, libvlc_exception_t *p_e )
+libvlc_state_t libvlc_media_player_get_state( libvlc_media_player_t *p_mi )
{
- VLC_UNUSED(p_e);
lock(p_mi);
libvlc_state_t state = p_mi->state;
unlock(p_mi);
libvlc_printerr( "No active input" );
}
}
+
+/**************************************************************************
+ * get_input_thread (Public API version)
+ **************************************************************************/
+struct input_thread_t *libvlc_media_player_get_input_thread( libvlc_media_player_t *player )
+{
+ libvlc_exception_t e;
+ libvlc_exception_init(&e);
+ input_thread_t *input = libvlc_get_input_thread(player, &e);
+ clear_if_needed(&e);
+ return input;
+}