From 73808cd8f0dd30e4cf361fc4bce20cb347e65172 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 28 Sep 2013 14:53:55 +0200 Subject: cocoa_common: fix deadlock After rebasing my dev branch it turned out that the code deadlocked on recursive calls of `vo_control`. Make the locking code a little bit smarter by making always skip locking/unlocking if we are executing a chunck of code that is already synchronized with `dispatch_sync`. --- video/out/cocoa_common.m | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'video') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 612ea27c73..b15ffd3d36 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -353,8 +353,7 @@ static void vo_cocoa_resize_redraw(struct vo *vo, int width, int height) if (!s->resize_redraw) return; - if (!s->inside_sync_section) - vo_cocoa_set_current_context(vo, true); + vo_cocoa_set_current_context(vo, true); [s->gl_ctx update]; @@ -367,9 +366,7 @@ static void vo_cocoa_resize_redraw(struct vo *vo, int width, int height) } [s->gl_ctx flushBuffer]; - - if (!s->inside_sync_section) - vo_cocoa_set_current_context(vo, false); + vo_cocoa_set_current_context(vo, false); } int vo_cocoa_config_window(struct vo *vo, uint32_t d_width, @@ -428,6 +425,11 @@ int vo_cocoa_config_window(struct vo *vo, uint32_t d_width, void vo_cocoa_set_current_context(struct vo *vo, bool current) { struct vo_cocoa_state *s = vo->cocoa; + + if (s->inside_sync_section) { + return; + } + if (current) { [s->lock lock]; [s->gl_ctx makeCurrentContext]; -- cgit v1.2.3