mirror of https://github.com/mpv-player/mpv
timer: remove microsecond timer functions
With the previous series of commits, all internal usage has been replaced by the nanosecond functions. There's not really any point in keeping these around anymore plus there are macros for unit conversions now so we can just axe them. It's worth noting that mpv_get_time_us() obviously still needs to work for API reasons, but we can just divide mp_time_ns() by 1000 to get the same thing.
This commit is contained in:
parent
bb036c67f4
commit
8f432b2e37
|
@ -48,11 +48,6 @@ void mp_time_init(void)
|
||||||
pthread_once(&timer_init_once, do_timer_init);
|
pthread_once(&timer_init_once, do_timer_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t mp_time_us(void)
|
|
||||||
{
|
|
||||||
return mp_time_ns() / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t mp_time_ns(void)
|
int64_t mp_time_ns(void)
|
||||||
{
|
{
|
||||||
uint64_t r = mp_raw_time_ns() - raw_time_offset;
|
uint64_t r = mp_raw_time_ns() - raw_time_offset;
|
||||||
|
@ -66,18 +61,6 @@ double mp_time_sec(void)
|
||||||
return mp_time_ns() / 1e9;
|
return mp_time_ns() / 1e9;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t mp_time_us_add(int64_t time_us, double timeout_sec)
|
|
||||||
{
|
|
||||||
assert(time_us > 0); // mp_time_us() returns strictly positive values
|
|
||||||
double t = MPCLAMP(timeout_sec * 1e6, -0x1p63, 0x1p63);
|
|
||||||
int64_t ti = t == 0x1p63 ? INT64_MAX : (int64_t)t;
|
|
||||||
if (ti > INT64_MAX - time_us)
|
|
||||||
return INT64_MAX;
|
|
||||||
if (ti <= -time_us)
|
|
||||||
return 1;
|
|
||||||
return time_us + ti;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t mp_time_ns_add(int64_t time_ns, double timeout_sec)
|
int64_t mp_time_ns_add(int64_t time_ns, double timeout_sec)
|
||||||
{
|
{
|
||||||
assert(time_ns > 0); // mp_time_ns() returns strictly positive values
|
assert(time_ns > 0); // mp_time_ns() returns strictly positive values
|
||||||
|
@ -106,11 +89,6 @@ static int get_realtime(struct timespec *out_ts)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct timespec mp_time_us_to_realtime(int64_t time_us)
|
|
||||||
{
|
|
||||||
return mp_time_ns_to_realtime(MPMIN(INT64_MAX / 1000, time_us) * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct timespec mp_time_ns_to_realtime(int64_t time_ns)
|
struct timespec mp_time_ns_to_realtime(int64_t time_ns)
|
||||||
{
|
{
|
||||||
struct timespec ts = {0};
|
struct timespec ts = {0};
|
||||||
|
|
|
@ -23,9 +23,6 @@
|
||||||
// Initialize timer, must be called at least once at start.
|
// Initialize timer, must be called at least once at start.
|
||||||
void mp_time_init(void);
|
void mp_time_init(void);
|
||||||
|
|
||||||
// Return time in microseconds. Never wraps. Never returns 0 or negative values.
|
|
||||||
int64_t mp_time_us(void);
|
|
||||||
|
|
||||||
// Return time in nanoseconds. Never wraps. Never returns 0 or negative values.
|
// Return time in nanoseconds. Never wraps. Never returns 0 or negative values.
|
||||||
int64_t mp_time_ns(void);
|
int64_t mp_time_ns(void);
|
||||||
|
|
||||||
|
@ -60,17 +57,10 @@ void mp_end_hires_timers(int resolution_ms);
|
||||||
#define MP_TIME_NS_TO_MS(ns) ((ns) / (double)1000000)
|
#define MP_TIME_NS_TO_MS(ns) ((ns) / (double)1000000)
|
||||||
#define MP_TIME_NS_TO_US(ns) ((ns) / (double)1000)
|
#define MP_TIME_NS_TO_US(ns) ((ns) / (double)1000)
|
||||||
|
|
||||||
// Add a time in seconds to the given time in microseconds, and return it.
|
|
||||||
// Takes care of possible overflows. Never returns a negative or 0 time.
|
|
||||||
int64_t mp_time_us_add(int64_t time_us, double timeout_sec);
|
|
||||||
|
|
||||||
// Add a time in seconds to the given time in nanoseconds, and return it.
|
// Add a time in seconds to the given time in nanoseconds, and return it.
|
||||||
// Takes care of possible overflows. Never returns a negative or 0 time.
|
// Takes care of possible overflows. Never returns a negative or 0 time.
|
||||||
int64_t mp_time_ns_add(int64_t time_ns, double timeout_sec);
|
int64_t mp_time_ns_add(int64_t time_ns, double timeout_sec);
|
||||||
|
|
||||||
// Convert the mp time in microseconds to a timespec using CLOCK_REALTIME.
|
|
||||||
struct timespec mp_time_us_to_realtime(int64_t time_us);
|
|
||||||
|
|
||||||
// Convert the mp time in nanoseconds to a timespec using CLOCK_REALTIME.
|
// Convert the mp time in nanoseconds to a timespec using CLOCK_REALTIME.
|
||||||
struct timespec mp_time_ns_to_realtime(int64_t time_ns);
|
struct timespec mp_time_ns_to_realtime(int64_t time_ns);
|
||||||
|
|
||||||
|
|
|
@ -2136,7 +2136,7 @@ int64_t mpv_get_time_ns(mpv_handle *ctx)
|
||||||
|
|
||||||
int64_t mpv_get_time_us(mpv_handle *ctx)
|
int64_t mpv_get_time_us(mpv_handle *ctx)
|
||||||
{
|
{
|
||||||
return mp_time_us();
|
return mp_time_ns() / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "video/out/libmpv.h"
|
#include "video/out/libmpv.h"
|
||||||
|
|
Loading…
Reference in New Issue