mirror of
https://github.com/mpv-player/mpv
synced 2025-03-25 04:38:01 +00:00
timer: rename mp_time_us_to_timespec to reflect what it actually does
This commit is contained in:
parent
381386330b
commit
da4c4d2ebd
@ -2557,7 +2557,7 @@ static void *demux_thread(void *pctx)
|
||||
if (thread_work(in))
|
||||
continue;
|
||||
pthread_cond_signal(&in->wakeup);
|
||||
struct timespec until = mp_time_us_to_timespec(in->next_cache_update);
|
||||
struct timespec until = mp_time_us_to_realtime(in->next_cache_update);
|
||||
pthread_cond_timedwait(&in->wakeup, &in->lock, &until);
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ void mp_dispatch_queue_process(struct mp_dispatch_queue *queue, double timeout)
|
||||
item->completed = true;
|
||||
}
|
||||
} else if (queue->wait > 0 && !queue->interrupted) {
|
||||
struct timespec ts = mp_time_us_to_timespec(queue->wait);
|
||||
struct timespec ts = mp_time_us_to_realtime(queue->wait);
|
||||
if (pthread_cond_timedwait(&queue->cond, &queue->lock, &ts))
|
||||
queue->wait = 0;
|
||||
} else {
|
||||
|
@ -85,7 +85,7 @@ static void get_realtime(struct timespec *out_ts)
|
||||
#endif
|
||||
}
|
||||
|
||||
struct timespec mp_time_us_to_timespec(int64_t time_us)
|
||||
struct timespec mp_time_us_to_realtime(int64_t time_us)
|
||||
{
|
||||
struct timespec ts;
|
||||
get_realtime(&ts);
|
||||
@ -112,7 +112,7 @@ struct timespec mp_time_us_to_timespec(int64_t time_us)
|
||||
|
||||
struct timespec mp_rel_time_to_timespec(double timeout_sec)
|
||||
{
|
||||
return mp_time_us_to_timespec(mp_add_timeout(mp_time_us(), timeout_sec));
|
||||
return mp_time_us_to_realtime(mp_add_timeout(mp_time_us(), timeout_sec));
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -137,7 +137,7 @@ int main(void) {
|
||||
#if TEST_SLEEP
|
||||
mp_sleep_us(delay);
|
||||
#else
|
||||
struct timespec ts = mp_time_us_to_timespec(r + delay);
|
||||
struct timespec ts = mp_time_us_to_realtime(r + delay);
|
||||
pthread_cond_timedwait(&cnd, &mtx, &ts);
|
||||
#endif
|
||||
j = (mp_time_us() - r) - delay;
|
||||
|
@ -55,7 +55,7 @@ void mp_end_hires_timers(int resolution_ms);
|
||||
int64_t mp_add_timeout(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_timespec(int64_t time_us);
|
||||
struct timespec mp_time_us_to_realtime(int64_t time_us);
|
||||
|
||||
// Convert the relative timeout in seconds to a timespec.
|
||||
// The timespec is absolute, using CLOCK_REALTIME.
|
||||
|
@ -363,7 +363,7 @@ static int wait_wakeup(struct mpv_handle *ctx, int64_t end)
|
||||
pthread_mutex_unlock(&ctx->lock);
|
||||
pthread_mutex_lock(&ctx->wakeup_lock);
|
||||
if (!ctx->need_wakeup) {
|
||||
struct timespec ts = mp_time_us_to_timespec(end);
|
||||
struct timespec ts = mp_time_us_to_realtime(end);
|
||||
r = pthread_cond_timedwait(&ctx->wakeup, &ctx->wakeup_lock, &ts);
|
||||
}
|
||||
if (r == 0)
|
||||
|
@ -111,5 +111,5 @@ void mp_set_avdict(AVDictionary **dict, char **kv) {};
|
||||
void mp_add_timeout(void) {};
|
||||
void mp_rel_time_to_timespec(void) {};
|
||||
void mp_time_us(void) {};
|
||||
void mp_time_us_to_timespec(void) {};
|
||||
void mp_time_us_to_realtime(void) {};
|
||||
#endif
|
||||
|
@ -62,5 +62,5 @@ void mp_set_avdict(AVDictionary **dict, char **kv);
|
||||
void mp_add_timeout(void);
|
||||
void mp_rel_time_to_timespec(void);
|
||||
void mp_time_us(void);
|
||||
void mp_time_us_to_timespec(void);
|
||||
void mp_time_us_to_realtime(void);
|
||||
#endif
|
||||
|
@ -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_timespec(mp_add_timeout(mp_time_us(), 0.1));
|
||||
struct timespec e = mp_time_us_to_realtime(mp_add_timeout(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;
|
||||
|
@ -719,7 +719,7 @@ void vo_wait_default(struct vo *vo, int64_t until_time)
|
||||
|
||||
pthread_mutex_lock(&in->lock);
|
||||
if (!in->need_wakeup) {
|
||||
struct timespec ts = mp_time_us_to_timespec(until_time);
|
||||
struct timespec ts = mp_time_us_to_realtime(until_time);
|
||||
pthread_cond_timedwait(&in->wakeup, &in->lock, &ts);
|
||||
}
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
@ -867,7 +867,7 @@ void vo_wait_frame(struct vo *vo)
|
||||
static void wait_until(struct vo *vo, int64_t target)
|
||||
{
|
||||
struct vo_internal *in = vo->in;
|
||||
struct timespec ts = mp_time_us_to_timespec(target);
|
||||
struct timespec ts = mp_time_us_to_realtime(target);
|
||||
pthread_mutex_lock(&in->lock);
|
||||
while (target > mp_time_us()) {
|
||||
if (in->queued_events & VO_EVENT_LIVE_RESIZING)
|
||||
|
Loading…
Reference in New Issue
Block a user