Skip to content

Commit

Permalink
timer: rename mp_add_timeout to reflect what it actually does
Browse files Browse the repository at this point in the history
  • Loading branch information
kasper93 authored and Dudemanguy committed Sep 29, 2023
1 parent f338420 commit 40e0fea
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion filters/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion misc/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions osdep/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
2 changes: 1 addition & 1 deletion osdep/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion player/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion player/playloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {};
Expand Down
2 changes: 1 addition & 1 deletion test/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion video/out/cocoa_common.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 40e0fea

Please sign in to comment.