From 71e888c2a0f0c816fe87d9b197878fb189adceed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 22 Oct 2023 04:17:03 +0200 Subject: [PATCH] timer: remove unused code --- osdep/timer.c | 30 ------------------------------ osdep/timer.h | 7 ------- test/timer.c | 16 ---------------- 3 files changed, 53 deletions(-) diff --git a/osdep/timer.c b/osdep/timer.c index 17921c1665..d0a8a92f8a 100644 --- a/osdep/timer.c +++ b/osdep/timer.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include @@ -66,32 +65,3 @@ int64_t mp_time_ns_add(int64_t time_ns, double timeout_sec) return 1; return time_ns + ti; } - -#if !HAVE_WIN32_THREADS - -struct timespec mp_time_ns_to_realtime(int64_t time_ns) -{ - struct timespec ts = {0}; - if (clock_gettime(CLOCK_REALTIME, &ts) != 0) - return ts; - int64_t time_rel = time_ns - mp_time_ns(); - - // clamp to 1000 days in the future - time_rel = MPMIN(time_rel, 1000 * 24 * 60 * 60 * INT64_C(1000000000)); - ts.tv_sec += time_rel / INT64_C(1000000000); - ts.tv_nsec += time_rel % INT64_C(1000000000); - - if (ts.tv_nsec >= INT64_C(1000000000)) { - ts.tv_sec++; - ts.tv_nsec -= INT64_C(1000000000); - } - - return ts; -} - -struct timespec mp_rel_time_to_timespec(double timeout_sec) -{ - return mp_time_ns_to_realtime(mp_time_ns_add(mp_time_ns(), timeout_sec)); -} - -#endif diff --git a/osdep/timer.h b/osdep/timer.h index ba7e22d6c5..3a925caec3 100644 --- a/osdep/timer.h +++ b/osdep/timer.h @@ -60,11 +60,4 @@ void mp_end_hires_timers(int resolution_ms); // 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 nanoseconds to a timespec using CLOCK_REALTIME. -struct timespec mp_time_ns_to_realtime(int64_t time_ns); - -// Convert the relative timeout in seconds to a timespec. -// The timespec is absolute, using CLOCK_REALTIME. -struct timespec mp_rel_time_to_timespec(double timeout_sec); - #endif /* MPLAYER_TIMER_H */ diff --git a/test/timer.c b/test/timer.c index f89fd7e310..f85009c1e7 100644 --- a/test/timer.c +++ b/test/timer.c @@ -1,7 +1,6 @@ #include "common/common.h" #include "osdep/timer.h" #include "test_utils.h" -#include "config.h" #include #include @@ -38,20 +37,5 @@ int main(void) assert_int_equal(mp_time_ns_add(test2, 20.44), INT64_MAX); } -#if !HAVE_WIN32_THREADS - /* conversion */ - { - struct timeval tv; - struct timespec ts; - gettimeofday(&tv, NULL); - ts = mp_time_ns_to_realtime(mp_time_ns()); - assert_true(llabs(tv.tv_sec - ts.tv_sec) <= 1); - - gettimeofday(&tv, NULL); - ts = mp_rel_time_to_timespec(0.0); - assert_true(llabs(tv.tv_sec - ts.tv_sec) <= 1); - } -#endif - return 0; }