Commit cdd8da99 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/Framework/VLCEventManager.m: Directly issue events to main thread if we...

MacOSX/Framework/VLCEventManager.m: Directly issue events to main thread if we are called from main thread.
parent d8dc26ec
...@@ -98,9 +98,9 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -98,9 +98,9 @@ static void * EventDispatcherMainLoop(void * user_data)
pthread_mutex_unlock( [self queueLock] ); pthread_mutex_unlock( [self queueLock] );
if( message->type == VLCNotification ) if( message->type == VLCNotification )
[self performSelectorOnMainThread:@selector(callDelegateOfObjectAndSendNotificationWithArgs:) withObject:[dataMessage retain] waitUntilDone: NO]; [self performSelectorOnMainThread:@selector(callDelegateOfObjectAndSendNotificationWithArgs:) withObject:[dataMessage retain] /* released in the call */ waitUntilDone: NO];
else else
[self performSelectorOnMainThread:@selector(callObjectMethodWithArgs:) withObject:[dataMessage retain] waitUntilDone: NO]; [self performSelectorOnMainThread:@selector(callObjectMethodWithArgs:) withObject:[dataMessage retain] /* released in the call */ waitUntilDone: NO];
pthread_mutex_lock( [self queueLock] ); pthread_mutex_lock( [self queueLock] );
[[self messageQueue] removeLastObject]; [[self messageQueue] removeLastObject];
...@@ -155,7 +155,13 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -155,7 +155,13 @@ static void * EventDispatcherMainLoop(void * user_data)
[aNotificationName retain], [aNotificationName retain],
VLCNotification VLCNotification
}; };
if([NSThread isMainThread])
{
[self callDelegateOfObjectAndSendNotificationWithArgs:[[NSData dataWithBytes:&message length:sizeof(struct message)] retain] /* released in the call */];
return;
}
pthread_mutex_lock( [self queueLock] ); pthread_mutex_lock( [self queueLock] );
[[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(struct message)] atIndex:0]; [[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(struct message)] atIndex:0];
pthread_cond_signal( [self signalData] ); pthread_cond_signal( [self signalData] );
...@@ -167,7 +173,6 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -167,7 +173,6 @@ static void * EventDispatcherMainLoop(void * user_data)
- (void)callOnMainThreadObject:(id)aTarget withMethod:(SEL)aSelector withArgumentAsObject: (id)arg - (void)callOnMainThreadObject:(id)aTarget withMethod:(SEL)aSelector withArgumentAsObject: (id)arg
{ {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
struct message message = struct message message =
{ {
[aTarget retain], [aTarget retain],
...@@ -175,6 +180,12 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -175,6 +180,12 @@ static void * EventDispatcherMainLoop(void * user_data)
[arg retain], [arg retain],
VLCObjectMethodWithObjectArg VLCObjectMethodWithObjectArg
}; };
if([NSThread isMainThread])
{
[self callObjectMethodWithArgs:[[NSData dataWithBytes:&message length:sizeof(struct message)] retain] /* released in the call */];
return;
}
pthread_mutex_lock( [self queueLock] ); pthread_mutex_lock( [self queueLock] );
[[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(struct message)] atIndex:0]; [[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(struct message)] atIndex:0];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment