timer: rename mp_add_timeout to reflect what it actually does

This commit is contained in:
Kacper Michajłow 2023-09-15 02:32:13 +02:00 committed by Dudemanguy
parent f338420fd2
commit 40e0fea6eb
9 changed files with 10 additions and 10 deletions

View File

@ -214,7 +214,7 @@ bool mp_filter_graph_run(struct mp_filter *filter)
int64_t end_time = 0;
if (isfinite(r->max_run_time))
end_time = mp_add_timeout(mp_time_us(), MPMAX(r->max_run_time, 0));
end_time = mp_time_us_add(mp_time_us(), MPMAX(r->max_run_time, 0));
// (could happen with separate filter graphs calling each other, for now
// ignore this issue as we don't use such a setup anywhere)

View File

@ -272,7 +272,7 @@ void mp_dispatch_run(struct mp_dispatch_queue *queue,
void mp_dispatch_queue_process(struct mp_dispatch_queue *queue, double timeout)
{
pthread_mutex_lock(&queue->lock);
queue->wait = timeout > 0 ? mp_add_timeout(mp_time_us(), timeout) : 0;
queue->wait = timeout > 0 ? mp_time_us_add(mp_time_us(), timeout) : 0;
assert(!queue->in_process); // recursion not allowed
queue->in_process = true;
queue->in_process_thread = pthread_self();

View File

@ -60,7 +60,7 @@ double mp_time_sec(void)
return mp_time_us() / (double)(1000 * 1000);
}
int64_t mp_add_timeout(int64_t time_us, double timeout_sec)
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 * (1000 * 1000), -0x1p63, 0x1p63);
@ -111,5 +111,5 @@ struct timespec mp_time_us_to_realtime(int64_t time_us)
struct timespec mp_rel_time_to_timespec(double timeout_sec)
{
return mp_time_us_to_realtime(mp_add_timeout(mp_time_us(), timeout_sec));
return mp_time_us_to_realtime(mp_time_us_add(mp_time_us(), timeout_sec));
}

View File

@ -52,7 +52,7 @@ void mp_end_hires_timers(int resolution_ms);
// 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_add_timeout(int64_t time_us, double timeout_sec);
int64_t mp_time_us_add(int64_t time_us, 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);

View File

@ -905,7 +905,7 @@ mpv_event *mpv_wait_event(mpv_handle *ctx, double timeout)
if (timeout < 0)
timeout = 1e20;
int64_t deadline = mp_add_timeout(mp_time_us(), timeout);
int64_t deadline = mp_time_us_add(mp_time_us(), timeout);
*event = (mpv_event){0};
talloc_free_children(event);

View File

@ -75,7 +75,7 @@ void mp_set_timeout(struct MPContext *mpctx, double sleeptime)
{
if (mpctx->sleeptime > sleeptime) {
mpctx->sleeptime = sleeptime;
int64_t abstime = mp_add_timeout(mp_time_us(), sleeptime);
int64_t abstime = mp_time_us_add(mp_time_us(), sleeptime);
mp_dispatch_adjust_timeout(mpctx->dispatch, abstime);
}
}

View File

@ -108,7 +108,7 @@ void mp_write_console_ansi(void) {};
void mp_set_avdict(AVDictionary **dict, char **kv) {};
#ifndef WIN32_TESTS
void mp_add_timeout(void) {};
void mp_time_us_add(void) {};
void mp_rel_time_to_timespec(void) {};
void mp_time_us(void) {};
void mp_time_us_to_realtime(void) {};

View File

@ -59,7 +59,7 @@ void mp_set_avdict(AVDictionary **dict, char **kv);
// import the real versions of these functions and use them. On other
// platforms, these can just be stubs for simplicity.
#ifndef WIN32_TESTS
void mp_add_timeout(void);
void mp_time_us_add(void);
void mp_rel_time_to_timespec(void);
void mp_time_us(void);
void mp_time_us_to_realtime(void);

View File

@ -786,7 +786,7 @@ static void vo_cocoa_resize_redraw(struct vo *vo, int width, int height)
// Wait until a new frame with the new size was rendered. For some reason,
// Cocoa requires this to be done before drawRect() returns.
struct timespec e = mp_time_us_to_realtime(mp_add_timeout(mp_time_us(), 0.1));
struct timespec e = mp_time_us_to_realtime(mp_time_us_add(mp_time_us(), 0.1));
while (s->frame_w != width && s->frame_h != height && s->vo_ready) {
if (pthread_cond_timedwait(&s->wakeup, &s->lock, &e))
break;