mirror of https://code.videolan.org/videolan/vlc
lib/media_player: fix time type/unit used by the timer API
My bad, libvlc_time_t is in ms. The timer API should use the sane unit than libvlc_clock(), that is us in int64_t. Also add missing vlc_tick_t <-> us conversion (no harm since 1 tick = 1 us for now).
This commit is contained in:
parent
9a48e2d01a
commit
95cbcf0e59
|
@ -2671,19 +2671,19 @@ typedef struct libvlc_media_player_time_point_t
|
|||
double position;
|
||||
/** Rate of the player */
|
||||
double rate;
|
||||
/** Valid time >= 0 or -1 */
|
||||
libvlc_time_t ts;
|
||||
/** Valid length >= 1 or 0 */
|
||||
libvlc_time_t length;
|
||||
/** Valid time, in us >= 0 or -1 */
|
||||
int64_t ts_us;
|
||||
/** Valid length, in us >= 1 or 0 */
|
||||
int64_t length_us;
|
||||
/**
|
||||
* System date of this record (always valid).
|
||||
* System date, in us, of this record (always valid).
|
||||
* Based on libvlc_clock(). This date can be in the future or in the past.
|
||||
* The special value of INT64_MAX mean that the clock was paused when this
|
||||
* point was updated. In that case,
|
||||
* libvlc_media_player_time_point_interpolate() will return the current
|
||||
* ts/pos of this point (there is nothing to interpolate).
|
||||
* */
|
||||
libvlc_time_t system_date;
|
||||
int64_t system_date_us;
|
||||
} libvlc_media_player_time_point_t;
|
||||
|
||||
/**
|
||||
|
@ -2715,13 +2715,13 @@ typedef void (*libvlc_media_player_watch_time_on_update)(
|
|||
*
|
||||
* \warning It is forbidden to call any Media Player functions from here.
|
||||
*
|
||||
* \param system_date system date of this event, only valid (> 0) when paused. It
|
||||
* can be used to interpolate the last updated point to this date in order
|
||||
* to get the last paused ts/position.
|
||||
* \param system_date_us system date, in us, of this event, only valid (> 0)
|
||||
* when paused. It can be used to interpolate the last updated point to this
|
||||
* date in order to get the last paused ts/position.
|
||||
* \param data opaque pointer set by libvlc_media_player_watch_time()
|
||||
*/
|
||||
typedef void (*libvlc_media_player_watch_time_on_discontinuity)(
|
||||
libvlc_time_t system_date, void *data);
|
||||
int64_t system_date_us, void *data);
|
||||
|
||||
/**
|
||||
* Watch for times updates
|
||||
|
@ -2731,9 +2731,9 @@ typedef void (*libvlc_media_player_watch_time_on_discontinuity)(
|
|||
* in-between) will fail.
|
||||
*
|
||||
* \param p_mi the media player
|
||||
* \param min_period corresponds to the minimum period between each updates,
|
||||
* use it to avoid flood from too many source updates, set it to 0 to receive
|
||||
* all updates.
|
||||
* \param min_period_us corresponds to the minimum period, in us, between each
|
||||
* updates, use it to avoid flood from too many source updates, set it to 0 to
|
||||
* receive all updates.
|
||||
* \param on_update callback to listen to update events (must not be NULL)
|
||||
* \param on_discontinuity callback to listen to discontinuity events (can be
|
||||
* be NULL)
|
||||
|
@ -2743,7 +2743,7 @@ typedef void (*libvlc_media_player_watch_time_on_discontinuity)(
|
|||
*/
|
||||
LIBVLC_API int
|
||||
libvlc_media_player_watch_time(libvlc_media_player_t *p_mi,
|
||||
libvlc_time_t min_period,
|
||||
int64_t min_period_us,
|
||||
libvlc_media_player_watch_time_on_update on_update,
|
||||
libvlc_media_player_watch_time_on_discontinuity on_discontinuity,
|
||||
void *cbs_data);
|
||||
|
@ -2762,9 +2762,8 @@ libvlc_media_player_unwatch_time(libvlc_media_player_t *p_mi);
|
|||
|
||||
* \param point time update obtained via the
|
||||
* libvlc_media_player_watch_time_on_update() callback
|
||||
* \param system_now current system date, returned by libvlc_clock()
|
||||
* \param out_ts pointer where to set the interpolated ts, subtract this time
|
||||
* with VLC_TICK_0 to get the original value.
|
||||
* \param system_now_us current system date, in us, returned by libvlc_clock()
|
||||
* \param out_ts_us pointer where to set the interpolated ts, in us
|
||||
* \param out_pos pointer where to set the interpolated position
|
||||
* \return 0 in case of success, -1 if the interpolated ts is negative (could
|
||||
* happen during the buffering step)
|
||||
|
@ -2772,8 +2771,8 @@ libvlc_media_player_unwatch_time(libvlc_media_player_t *p_mi);
|
|||
*/
|
||||
LIBVLC_API int
|
||||
libvlc_media_player_time_point_interpolate(const libvlc_media_player_time_point_t *point,
|
||||
libvlc_time_t system_now,
|
||||
libvlc_time_t *out_ts, double *out_pos);
|
||||
int64_t system_now_us,
|
||||
int64_t *out_ts_us, double *out_pos);
|
||||
|
||||
/**
|
||||
* Get the date of the next interval
|
||||
|
@ -2787,20 +2786,20 @@ libvlc_media_player_time_point_interpolate(const libvlc_media_player_time_point_
|
|||
*
|
||||
* \param point time update obtained via the
|
||||
* libvlc_media_player_watch_time_on_update()
|
||||
* \param system_now same system date used by
|
||||
* \param system_now_us same system date used by
|
||||
* libvlc_media_player_time_point_interpolate()
|
||||
* \param interpolated_ts ts returned by
|
||||
* \param interpolated_ts_us ts returned by
|
||||
* libvlc_media_player_time_point_interpolate()
|
||||
* \param next_interval next interval
|
||||
* \return the absolute system date of the next interval, use libvlc_delay() to
|
||||
* get a relative delay.
|
||||
* \param next_interval_us next interval, in us
|
||||
* \return the absolute system date, in us, of the next interval,
|
||||
* use libvlc_delay() to get a relative delay.
|
||||
* \version LibVLC 4.0.0 or later
|
||||
*/
|
||||
LIBVLC_API libvlc_time_t
|
||||
LIBVLC_API int64_t
|
||||
libvlc_media_player_time_point_get_next_date(const libvlc_media_player_time_point_t *point,
|
||||
libvlc_time_t system_now,
|
||||
libvlc_time_t interpolated_ts,
|
||||
libvlc_time_t next_interval);
|
||||
int64_t system_now_us,
|
||||
int64_t interpolated_ts_us,
|
||||
int64_t next_interval_us);
|
||||
|
||||
/** @} libvlc_media_player_watch_time */
|
||||
|
||||
|
|
|
@ -2212,17 +2212,17 @@ int libvlc_media_player_get_role(libvlc_media_player_t *mp)
|
|||
#define PLAYER_TIME_CORE_TO_LIB(point) { \
|
||||
.position = point->position, \
|
||||
.rate = point->rate, \
|
||||
.ts = US_FROM_VLC_TICK(point->ts), \
|
||||
.length = US_FROM_VLC_TICK(point->length), \
|
||||
.system_date = US_FROM_VLC_TICK(point->system_date), \
|
||||
.ts_us = US_FROM_VLC_TICK(point->ts), \
|
||||
.length_us = US_FROM_VLC_TICK(point->length), \
|
||||
.system_date_us = US_FROM_VLC_TICK(point->system_date), \
|
||||
}
|
||||
|
||||
#define PLAYER_TIME_LIB_TO_CORE(point) { \
|
||||
.position = point->position, \
|
||||
.rate = point->rate, \
|
||||
.ts = VLC_TICK_FROM_US(point->ts), \
|
||||
.length = VLC_TICK_FROM_US(point->length), \
|
||||
.system_date = VLC_TICK_FROM_US(point->system_date), \
|
||||
.ts = VLC_TICK_FROM_US(point->ts_us), \
|
||||
.length = VLC_TICK_FROM_US(point->length_us), \
|
||||
.system_date = VLC_TICK_FROM_US(point->system_date_us), \
|
||||
}
|
||||
|
||||
static void player_timer_on_update(const struct vlc_player_timer_point *point,
|
||||
|
@ -2242,12 +2242,13 @@ static void player_timer_on_discontinuity(vlc_tick_t system_date, void *data)
|
|||
if (p_mi->timer.on_discontinuity == NULL)
|
||||
return;
|
||||
|
||||
p_mi->timer.on_discontinuity(system_date, p_mi->timer.cbs_data);
|
||||
p_mi->timer.on_discontinuity(US_FROM_VLC_TICK(system_date),
|
||||
p_mi->timer.cbs_data);
|
||||
}
|
||||
|
||||
int
|
||||
libvlc_media_player_watch_time(libvlc_media_player_t *p_mi,
|
||||
libvlc_time_t min_period,
|
||||
int64_t min_period_us,
|
||||
libvlc_media_player_watch_time_on_update on_update,
|
||||
libvlc_media_player_watch_time_on_discontinuity on_discontinuity,
|
||||
void *cbs_data)
|
||||
|
@ -2274,7 +2275,8 @@ libvlc_media_player_watch_time(libvlc_media_player_t *p_mi,
|
|||
p_mi->timer.on_discontinuity = on_discontinuity;
|
||||
p_mi->timer.cbs_data = cbs_data;
|
||||
|
||||
p_mi->timer.id = vlc_player_AddTimer(player, min_period, &player_timer_cbs, p_mi);
|
||||
p_mi->timer.id = vlc_player_AddTimer(player, VLC_TICK_FROM_US(min_period_us),
|
||||
&player_timer_cbs, p_mi);
|
||||
vlc_player_Unlock(player);
|
||||
|
||||
if (unlikely(p_mi->timer.id == NULL))
|
||||
|
@ -2299,24 +2301,33 @@ libvlc_media_player_unwatch_time(libvlc_media_player_t *p_mi)
|
|||
|
||||
int
|
||||
libvlc_media_player_time_point_interpolate(const libvlc_media_player_time_point_t *libpoint,
|
||||
libvlc_time_t system_now,
|
||||
libvlc_time_t *out_ts, double *out_pos)
|
||||
int64_t system_now_us,
|
||||
int64_t *out_ts_us, double *out_pos)
|
||||
{
|
||||
const struct vlc_player_timer_point point = PLAYER_TIME_LIB_TO_CORE(libpoint);
|
||||
|
||||
return vlc_player_timer_point_Interpolate(&point, system_now, out_ts, out_pos);
|
||||
vlc_tick_t out_ts;
|
||||
int ret = vlc_player_timer_point_Interpolate(&point,
|
||||
VLC_TICK_FROM_US(system_now_us),
|
||||
&out_ts, out_pos);
|
||||
*out_ts_us = US_FROM_VLC_TICK(out_ts);
|
||||
return ret;
|
||||
}
|
||||
|
||||
libvlc_time_t
|
||||
int64_t
|
||||
libvlc_media_player_time_point_get_next_date(const libvlc_media_player_time_point_t *libpoint,
|
||||
libvlc_time_t system_now,
|
||||
libvlc_time_t interpolated_ts,
|
||||
libvlc_time_t next_interval)
|
||||
int64_t system_now_us,
|
||||
int64_t interpolated_ts_us,
|
||||
int64_t next_interval_us)
|
||||
{
|
||||
const struct vlc_player_timer_point point = PLAYER_TIME_LIB_TO_CORE(libpoint);
|
||||
|
||||
return vlc_player_timer_point_GetNextIntervalDate(&point, system_now,
|
||||
interpolated_ts, next_interval);
|
||||
vlc_tick_t date =
|
||||
vlc_player_timer_point_GetNextIntervalDate(&point,
|
||||
VLC_TICK_FROM_US(system_now_us),
|
||||
VLC_TICK_FROM_US(interpolated_ts_us),
|
||||
VLC_TICK_FROM_US(next_interval_us));
|
||||
return US_FROM_VLC_TICK(date);
|
||||
}
|
||||
|
||||
#include <vlc_vout_display.h>
|
||||
|
|
Loading…
Reference in New Issue