From f57f631e220282142e35b48c59559051d36a39cb Mon Sep 17 00:00:00 2001 From: dezeroex Date: Thu, 14 Apr 2005 05:34:35 +0000 Subject: [PATCH] An unfinished attempt at porting the SDL consumer to OS X. What remains is a bug in libSDL where the SDL screen object becomes a NULL pointer when it shouldn't. This also affects 'ffplay' and the SDL test program 'threadwin -threaded' I think. git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@709 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/modules/sdl/consumer_sdl.c | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/src/modules/sdl/consumer_sdl.c b/src/modules/sdl/consumer_sdl.c index 35c39c8..91925c9 100644 --- a/src/modules/sdl/consumer_sdl.c +++ b/src/modules/sdl/consumer_sdl.c @@ -29,6 +29,13 @@ #include #include +#ifdef __DARWIN__ +# include "consumer_sdl_osx_hack.h" +# import +# import +#endif + + /** This classes definition. */ @@ -81,6 +88,16 @@ static void consumer_sdl_event( mlt_listener listener, mlt_properties owner, mlt mlt_consumer consumer_sdl_init( char *arg ) { +#ifdef __DARWIN__ + // Initialize Cocoa + NSApplicationLoad(); + [NSApplication sharedApplication]; + + // Spawn a fake thread so that cocoa knows to be multithreaded + DummyThread *dummy = [[DummyThread alloc] init]; + [NSThread detachNewThreadSelector:@selector(startThread:) toTarget:dummy withObject:nil]; +#endif + // Create the consumer object consumer_sdl this = calloc( sizeof( struct consumer_sdl_s ), 1 ); @@ -535,6 +552,10 @@ static void *video_thread( void *arg ) // Identify the arg consumer_sdl this = arg; +#ifdef __DARWIN__ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; +#endif + // Obtain time of thread start struct timeval now; int64_t start = 0; @@ -618,6 +639,10 @@ static void *video_thread( void *arg ) mlt_consumer_stopped( &this->parent ); +#ifdef __DARWIN__ + [pool release]; +#endif + return NULL; } @@ -629,6 +654,10 @@ static void *consumer_thread( void *arg ) // Identify the arg consumer_sdl this = arg; +#ifdef __DARWIN__ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; +#endif + // Get the consumer mlt_consumer consumer = &this->parent; @@ -738,6 +767,10 @@ static void *consumer_thread( void *arg ) this->sdl_overlay = NULL; this->audio_avail = 0; +#ifdef __DARWIN__ + [pool release]; +#endif + return NULL; } @@ -754,6 +787,7 @@ static int consumer_get_dimensions( int *width, int *height ) // Lock the display sdl_lock_display(); +#ifndef __DARWIN__ // Get the wm structure if ( SDL_GetWMInfo( &wm ) == 1 ) { @@ -778,6 +812,7 @@ static int consumer_get_dimensions( int *width, int *height ) *height = attr.height; } } +#endif // Unlock the display sdl_lock_display(); -- 1.7.4.4