Commit a6b1ff10 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

libvlc: Fix a bunch of messed up mtime_t to libvlc_time_t.

Apparently libvlc_time_t is millisec, whereas mtime_t is microsecs.
Most event callbacks where carying an incorrect mtime_t value.
parent c6e4db8d
...@@ -111,4 +111,20 @@ void libvlc_event_attach_async( libvlc_event_manager_t * p_event_manager, ...@@ -111,4 +111,20 @@ void libvlc_event_attach_async( libvlc_event_manager_t * p_event_manager,
libvlc_exception_raise( p_e ); \ libvlc_exception_raise( p_e ); \
return 0; } return 0; }
static inline void clear_if_needed(libvlc_exception_t *e)
{
if (libvlc_exception_raised(e))
libvlc_exception_clear(e);
}
static inline libvlc_time_t from_mtime(mtime_t time)
{
return (time + 500ULL)/ 1000ULL;
}
static inline mtime_t to_mtime(libvlc_time_t time)
{
return time * 1000ULL;
}
#endif #endif
...@@ -147,8 +147,8 @@ static void input_item_duration_changed( const vlc_event_t *p_event, ...@@ -147,8 +147,8 @@ static void input_item_duration_changed( const vlc_event_t *p_event,
/* Construct the event */ /* Construct the event */
event.type = libvlc_MediaDurationChanged; event.type = libvlc_MediaDurationChanged;
event.u.media_duration_changed.new_duration = event.u.media_duration_changed.new_duration =
p_event->u.input_item_duration_changed.new_duration; from_mtime(p_event->u.input_item_duration_changed.new_duration);
/* Send the event */ /* Send the event */
libvlc_event_send( p_md->p_event_manager, &event ); libvlc_event_send( p_md->p_event_manager, &event );
...@@ -597,7 +597,7 @@ libvlc_media_get_duration( libvlc_media_t * p_md, libvlc_exception_t *p_e ) ...@@ -597,7 +597,7 @@ libvlc_media_get_duration( libvlc_media_t * p_md, libvlc_exception_t *p_e )
if (!input_item_IsPreparsed( p_md->p_input_item )) if (!input_item_IsPreparsed( p_md->p_input_item ))
return -1; return -1;
return input_item_GetDuration( p_md->p_input_item ) / 1000; return from_mtime(input_item_GetDuration( p_md->p_input_item ));
} }
/************************************************************************** /**************************************************************************
......
...@@ -80,12 +80,6 @@ static inline void unlock(libvlc_media_player_t *mp) ...@@ -80,12 +80,6 @@ static inline void unlock(libvlc_media_player_t *mp)
vlc_mutex_unlock(&mp->object_lock); 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. * Release the associated input thread.
* *
...@@ -287,14 +281,14 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd, ...@@ -287,14 +281,14 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
/* */ /* */
event.type = libvlc_MediaPlayerTimeChanged; event.type = libvlc_MediaPlayerTimeChanged;
event.u.media_player_time_changed.new_time = 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 ); libvlc_event_send( p_mi->p_event_manager, &event );
} }
else if( newval.i_int == INPUT_EVENT_LENGTH ) else if( newval.i_int == INPUT_EVENT_LENGTH )
{ {
event.type = libvlc_MediaPlayerLengthChanged; event.type = libvlc_MediaPlayerLengthChanged;
event.u.media_player_length_changed.new_length = 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 ); libvlc_event_send( p_mi->p_event_manager, &event );
} }
...@@ -803,10 +797,10 @@ libvlc_time_t libvlc_media_player_get_length( ...@@ -803,10 +797,10 @@ libvlc_time_t libvlc_media_player_get_length(
if( !p_input_thread ) if( !p_input_thread )
return -1; 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 ); vlc_object_release( p_input_thread );
return (i_time+500LL)/1000LL; return i_time;
} }
libvlc_time_t libvlc_media_player_get_time( libvlc_time_t libvlc_media_player_get_time(
...@@ -820,9 +814,9 @@ libvlc_time_t libvlc_media_player_get_time( ...@@ -820,9 +814,9 @@ libvlc_time_t libvlc_media_player_get_time(
if( !p_input_thread ) if( !p_input_thread )
return -1; 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 ); vlc_object_release( p_input_thread );
return (i_time+500LL)/1000LL; return i_time;
} }
void libvlc_media_player_set_time( void libvlc_media_player_set_time(
...@@ -836,7 +830,7 @@ void libvlc_media_player_set_time( ...@@ -836,7 +830,7 @@ void libvlc_media_player_set_time(
if( !p_input_thread ) if( !p_input_thread )
return; 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 ); vlc_object_release( p_input_thread );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment