timer: remove unused code

This commit is contained in:
Kacper Michajłow 2023-10-22 04:17:03 +02:00 committed by Dudemanguy
parent 751790c2b3
commit 71e888c2a0
3 changed files with 0 additions and 53 deletions

View File

@ -16,7 +16,6 @@
*/
#include <stdlib.h>
#include <pthread.h>
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
@ -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

View File

@ -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 */

View File

@ -1,7 +1,6 @@
#include "common/common.h"
#include "osdep/timer.h"
#include "test_utils.h"
#include "config.h"
#include <time.h>
#include <sys/time.h>
@ -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;
}