summaryrefslogtreecommitdiff
path: root/src/video_out/macosx
diff options
context:
space:
mode:
authorAndre Pang <athp@users.sourceforge.net>2004-06-19 04:11:53 +0000
committerAndre Pang <athp@users.sourceforge.net>2004-06-19 04:11:53 +0000
commit40fd2791ae6b99b5f78244f5dc827b0d8af95cd6 (patch)
treea7ddefe9b933ec28304ac4b404d94932d047bf2d /src/video_out/macosx
parent73a709eeb0e188c0e911457d1ded45fd841c9435 (diff)
downloadxine-lib-40fd2791ae6b99b5f78244f5dc827b0d8af95cd6.tar.gz
xine-lib-40fd2791ae6b99b5f78244f5dc827b0d8af95cd6.tar.bz2
Run Mac OS X video driver's setVideoSize method in the main (UI) thread, rather
than xine's thread, to avoid threading problems. CVS patchset: 6701 CVS date: 2004/06/19 04:11:53
Diffstat (limited to 'src/video_out/macosx')
-rw-r--r--src/video_out/macosx/video_window.h2
-rw-r--r--src/video_out/macosx/video_window.m60
2 files changed, 42 insertions, 20 deletions
diff --git a/src/video_out/macosx/video_window.h b/src/video_out/macosx/video_window.h
index 8337ce5f8..3fb9c1eb5 100644
--- a/src/video_out/macosx/video_window.h
+++ b/src/video_out/macosx/video_window.h
@@ -50,7 +50,7 @@ typedef enum {
- (void) initTextures;
- (void) reloadTexture;
- (char *) getTextureBuffer;
-- (void) setVideoSize:(int)w height:(int)h;
+- (void) setVideoSizeInMainThread:(int)w height:(int)h;
/* Delegate methods */
- (id) delegate;
diff --git a/src/video_out/macosx/video_window.m b/src/video_out/macosx/video_window.m
index 87f51833f..348f2e314 100644
--- a/src/video_out/macosx/video_window.m
+++ b/src/video_out/macosx/video_window.m
@@ -38,7 +38,7 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification";
width = size.width;
height = size.height;
- [openGLView setVideoSize: width height: height];
+ [openGLView setVideoSizeInMainThread: width height: height];
if (keepAspectRatio)
[self setAspectRatio: size];
@@ -465,19 +465,42 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification";
return texture_buffer;
}
-- (void) setVideoSize:(int)w height:(int)h
+- (void) setVideoSizeInMainThread:(int)w height:(int)h
{
+ /* create an autorelease pool, since we're running in a xine thread that
+ * may not have a pool of its own */
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
+
+ NSSize size = NSMakeSize(w, h);
+ NSValue *sizeWrapper = [NSValue valueWithBytes:&size
+ objCType:@encode(NSSize)];
+
+ [self performSelectorOnMainThread:@selector(setVideoSize:)
+ withObject:sizeWrapper
+ waitUntilDone:NO];
+
+ [pool release];
+}
+
+- (void) setVideoSize:(NSValue *)sizeWrapper
+{
+ NSSize size;
+ int w, h;
+
+ [sizeWrapper getValue:&size];
+ w = size.width;
+ h = size.height;
+
if (w != width || h != height) {
NSSize newSize;
+ NSValue *newSizeWrapper;
newSize.width = w;
newSize.height = h;
- /* If our delegate handles xineViewWillResize:toSize:, send the
- * message to him; otherwise, just resize ourselves */
+ /* If our delegate handles xineViewWillResize:toSize:, send the
+ * message to him; otherwise, just resize ourselves */
if ([delegate respondsToSelector:@selector(xineViewWillResize:toSize:)]) {
NSSize oldSize = NSMakeSize(width, height);
NSSize proposedSize = NSMakeSize(w, h);
@@ -489,25 +512,24 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification";
height = h;
}
- [self setFrameSize:newSize];
- [self setBoundsSize:newSize];
-
- /* Post a notification that we resized, and also notify our delegate */
- NSNotification *note =
- [NSNotification notificationWithName:XineViewDidResizeNotification
- object:self];
- [[NSNotificationCenter defaultCenter] postNotification:note];
- if ([delegate respondsToSelector:@selector(xineViewDidResize:)]) {
- [delegate xineViewDidResize:note];
- }
-
+ /* Resize the window in the main (UI) thread */
+ [self setFrameSize:size];
+ [self setBoundsSize:size];
+
+ /* Post a notification that we resized and also notify our delegate */
+ NSNotification *note =
+ [NSNotification notificationWithName:XineViewDidResizeNotification
+ object:self];
+ [[NSNotificationCenter defaultCenter] postNotification:note];
+ if ([delegate respondsToSelector:@selector(xineViewDidResize:)]) {
+ [delegate xineViewDidResize:note];
+ }
+
if (isFullScreen)
[self calcFullScreenAspect];
}
[self initTextures];
-
- [pool release];
}
- (int) isFullScreen {