[vlc-commits] macosx vout: reliably set the window level

David Fuhrmann git at videolan.org
Tue Feb 28 17:12:53 CET 2012


vlc/vlc-2.0 | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Tue Feb 28 15:26:07 2012 +0100| [f692f4564795d2b5761bd168e70abbfcb3390377] | committer: Felix Paul Kühne

macosx vout: reliably set the window level

setLevel: seems to be not thread-safe, therefore we set this on the main thread to ensure its functionality

Signed-off-by: Felix Paul Kühne <fkuehne at videolan.org>
(cherry picked from commit e33b79f2f7d90dedae32adad27e4c452a8ec278a)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=f692f4564795d2b5761bd168e70abbfcb3390377
---

 modules/video_output/macosx.m |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 8ce6e50..599da24 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -320,11 +320,10 @@ static int Control (vout_display_t *vd, int query, va_list ap)
         }
         case VOUT_DISPLAY_CHANGE_WINDOW_STATE:
         {
+            NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
             unsigned state = va_arg (ap, unsigned);
-            if( (state & VOUT_WINDOW_STATE_ABOVE) != 0)
-                [[sys->glView window] setLevel: NSStatusWindowLevel];
-            else
-                [[sys->glView window] setLevel: NSNormalWindowLevel];
+            [sys->glView performSelectorOnMainThread:@selector(setWindowLevel:) withObject:[NSNumber numberWithUnsignedInt:state] waitUntilDone:NO];
+            [o_pool release];
             return VLC_SUCCESS;
         }
         case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
@@ -713,4 +712,12 @@ static void OpenglSwap(vlc_gl_t *gl)
 {
     return YES;
 }
+
+- (void)setWindowLevel:(NSNumber*)state
+{
+    if( [state unsignedIntValue] & VOUT_WINDOW_STATE_ABOVE )
+        [[self window] setLevel: NSStatusWindowLevel];
+    else
+        [[self window] setLevel: NSNormalWindowLevel];
+}
 @end



More information about the vlc-commits mailing list