/*****************************************************************************
* Local prototypes.
*****************************************************************************/
-int ExecuteOnMainThread( id target, SEL sel, void * p_arg );
unsigned int CocoaKeyToVLC( unichar i_key );
#define VLCIntf [[VLCMain sharedInstance] getIntf]
return NULL;
}
-int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
-{
- int i_ret = 0;
-
- //NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
-
- if( [target respondsToSelector: @selector(performSelectorOnMainThread:
- withObject:waitUntilDone:)] )
- {
- [target performSelectorOnMainThread: sel
- withObject: [NSValue valueWithPointer: p_arg]
- waitUntilDone: NO];
- }
- else if( NSApp != nil && [[VLCMain sharedInstance] respondsToSelector: @selector(getIntf)] )
- {
- NSValue * o_v1;
- NSValue * o_v2;
- NSArray * o_array;
- NSPort * o_recv_port;
- NSInvocation * o_inv;
- NSPortMessage * o_msg;
- intf_thread_t * p_intf;
- NSConditionLock * o_lock;
- NSMethodSignature * o_sig;
-
- id * val[] = { &o_lock, &o_v2 };
-
- p_intf = (intf_thread_t *)VLCIntf;
-
- o_recv_port = [[NSPort port] retain];
- o_v1 = [NSValue valueWithPointer: val];
- o_v2 = [NSValue valueWithPointer: p_arg];
-
- o_sig = [target methodSignatureForSelector: sel];
- o_inv = [NSInvocation invocationWithMethodSignature: o_sig];
- [o_inv setArgument: &o_v1 atIndex: 2];
- [o_inv setTarget: target];
- [o_inv setSelector: sel];
-
- o_array = [NSArray arrayWithObject:
- [NSData dataWithBytes: &o_inv length: sizeof(o_inv)]];
- o_msg = [[NSPortMessage alloc]
- initWithSendPort: p_intf->p_sys->o_sendport
- receivePort: o_recv_port components: o_array];
-
- o_lock = [[NSConditionLock alloc] initWithCondition: 0];
- [o_msg sendBeforeDate: [NSDate distantPast]];
- [o_lock lockWhenCondition: 1];
- [o_lock unlock];
- [o_lock release];
-
- [o_msg release];
- [o_recv_port release];
- }
- else
- {
- i_ret = 1;
- }
-
- //[o_pool release];
-
- return( i_ret );
-}
-
/*****************************************************************************
* playlistChanged: Callback triggered by the intf-change playlist
* variable, to let the intf update the playlist.