diff options
-rw-r--r-- | src/video_out/macosx/video_window.h | 2 | ||||
-rw-r--r-- | src/video_out/macosx/video_window.m | 60 | ||||
-rw-r--r-- | src/video_out/video_out_macosx.m | 4 |
3 files changed, 44 insertions, 22 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 { diff --git a/src/video_out/video_out_macosx.m b/src/video_out/video_out_macosx.m index c246f3c91..04151c4a5 100644 --- a/src/video_out/video_out_macosx.m +++ b/src/video_out/video_out_macosx.m @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out_macosx.m,v 1.4 2004/06/18 14:24:14 zonque Exp $ + * $Id: video_out_macosx.m,v 1.5 2004/06/19 04:11:53 athp Exp $ * * This output driver makes use of xine's objective-c video_output * classes located in the macosx folder. @@ -156,7 +156,7 @@ static void macosx_update_frame_format(vo_driver_t *vo_driver, vo_frame_t *vo_fr } - [this->view setVideoSize:width height:height]; + [this->view setVideoSizeInMainThread:width height:height]; if((format == XINE_IMGFMT_YV12 && (frame->vo_frame.base[0] == NULL |