diff options
author | wm4 <wm4@nowhere> | 2015-05-12 22:31:22 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-05-12 22:42:06 +0200 |
commit | 29eb764fe0ae67bebfa930f88a9d7088f30561dd (patch) | |
tree | 9aa78e0b847a4d00f46077a73f453da16c8f7e2a /video/out | |
parent | 7735b297329ed730f410b0b3cb6503eeea04ee90 (diff) | |
download | mpv-29eb764fe0ae67bebfa930f88a9d7088f30561dd.tar.bz2 mpv-29eb764fe0ae67bebfa930f88a9d7088f30561dd.tar.xz |
cocoa: make live-resizing as fast as before
Interrupt video timing. This means the Cocoa event loop does not have
to up to 2 video frame durations until redrawing the frame finally has
finished.
We abuse the VO event flags for this. Eventually this should use
wait_vo() or so in the video timing wait function, but for now the
interaction this would require with the code of other VOs/backends
would cause too much of a mess.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/cocoa_common.m | 4 | ||||
-rw-r--r-- | video/out/vo.c | 17 | ||||
-rw-r--r-- | video/out/vo.h | 2 |
3 files changed, 14 insertions, 9 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 686a064eb9..b9209bd143 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -629,13 +629,15 @@ static void vo_cocoa_resize_redraw(struct vo *vo, int width, int height) s->frame_w = s->frame_h = 0; s->pending_events |= VO_EVENT_RESIZE | VO_EVENT_EXPOSE; - vo_wakeup(vo); + vo_event(vo, VO_EVENT_LIVE_RESIZING); while (s->frame_w != width && s->frame_h != height && s->vo_ready) { if (pthread_cond_timedwait(&s->resize_wakeup, &s->resize_lock, &e)) break; } + vo_query_and_reset_events(vo, VO_EVENT_LIVE_RESIZING); + pthread_mutex_unlock(&s->resize_lock); } diff --git a/video/out/vo.c b/video/out/vo.c index edde793cbf..74b4fce42f 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -484,7 +484,7 @@ static void wakeup_locked(struct vo *vo) { struct vo_internal *in = vo->in; - pthread_cond_signal(&in->wakeup); + pthread_cond_broadcast(&in->wakeup); if (vo->event_fd >= 0) wakeup_event_fd(vo); if (vo->driver->wakeup) @@ -567,14 +567,14 @@ 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); - while (1) { - int64_t now = mp_time_us(); - if (target <= now) + pthread_mutex_lock(&in->lock); + while (target > mp_time_us()) { + if (in->queued_events & VO_EVENT_LIVE_RESIZING) + break; + if (pthread_cond_timedwait(&in->wakeup, &in->lock, &ts)) break; - pthread_mutex_lock(&in->lock); - pthread_cond_timedwait(&in->wakeup, &in->lock, &ts); - pthread_mutex_unlock(&in->lock); } + pthread_mutex_unlock(&in->lock); } // needs lock @@ -722,7 +722,7 @@ static bool render_frame(struct vo *vo) in->request_redraw = false; } - pthread_cond_signal(&in->wakeup); // for vo_wait_frame() + pthread_cond_broadcast(&in->wakeup); // for vo_wait_frame() mp_input_wakeup(vo->input_ctx); pthread_mutex_unlock(&in->lock); @@ -984,6 +984,7 @@ void vo_event(struct vo *vo, int event) mp_input_wakeup(vo->input_ctx); in->queued_events |= event; in->internal_events |= event; + wakeup_locked(vo); pthread_mutex_unlock(&in->lock); } diff --git a/video/out/vo.h b/video/out/vo.h index 26df7079d8..c2aee9aedd 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -40,6 +40,8 @@ #define VO_EVENT_WIN_STATE 8 // The ambient light conditions changed and need to be reloaded #define VO_EVENT_AMBIENT_LIGHTING_CHANGED 16 +// Special mechanism for making resizing with Cocoa react faster +#define VO_EVENT_LIVE_RESIZING 32 // Set of events the player core may be interested in. #define VO_EVENTS_USER (VO_EVENT_RESIZE | VO_EVENT_WIN_STATE) |