summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-10-11 15:19:14 -0500
committerDudemanguy <random342@airmail.cc>2023-10-16 15:38:59 +0000
commit8f432b2e37bd2d421c21f828e41973710dfb8118 (patch)
tree522cf8da9821426f9a33d19114efa782ee2dcfed
parentbb036c67f4708e2bc10e7a382e447d40681208b8 (diff)
downloadmpv-8f432b2e37bd2d421c21f828e41973710dfb8118.tar.bz2
mpv-8f432b2e37bd2d421c21f828e41973710dfb8118.tar.xz
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.
-rw-r--r--osdep/timer.c22
-rw-r--r--osdep/timer.h10
-rw-r--r--player/client.c2
3 files changed, 1 insertions, 33 deletions
diff --git a/osdep/timer.c b/osdep/timer.c
index 3e48329ba2..e939ef5dd5 100644
--- a/osdep/timer.c
+++ b/osdep/timer.c
@@ -48,11 +48,6 @@ void mp_time_init(void)
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)
{
uint64_t r = mp_raw_time_ns() - raw_time_offset;
@@ -66,18 +61,6 @@ double mp_time_sec(void)
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)
{
assert(time_ns > 0); // mp_time_ns() returns strictly positive values
@@ -106,11 +89,6 @@ static int get_realtime(struct timespec *out_ts)
}
#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 ts = {0};
diff --git a/osdep/timer.h b/osdep/timer.h
index 3d25055ff0..265e161ef2 100644
--- a/osdep/timer.h
+++ b/osdep/timer.h
@@ -23,9 +23,6 @@
// Initialize timer, must be called at least once at start.
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.
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_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.
// 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);
-// 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.
struct timespec mp_time_ns_to_realtime(int64_t time_ns);
diff --git a/player/client.c b/player/client.c
index 7117235852..cd0264e646 100644
--- a/player/client.c
+++ b/player/client.c
@@ -2136,7 +2136,7 @@ int64_t mpv_get_time_ns(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"