libvlc_exception_raise( p_e ); \
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
/* Construct the event */
event.type = libvlc_MediaDurationChanged;
- event.u.media_duration_changed.new_duration =
- p_event->u.input_item_duration_changed.new_duration;
+ event.u.media_duration_changed.new_duration =
+ from_mtime(p_event->u.input_item_duration_changed.new_duration);
/* Send the event */
libvlc_event_send( p_md->p_event_manager, &event );
if (!input_item_IsPreparsed( p_md->p_input_item ))
return -1;
- return input_item_GetDuration( p_md->p_input_item ) / 1000;
+ return from_mtime(input_item_GetDuration( p_md->p_input_item ));
}
/**************************************************************************
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.
*
/* */
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 );
}
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 );
}