]> git.sesse.net Git - vlc/commitdiff
macosx remote: Fix a leak in the Apple Remote class.
authorDerk-Jan Hartman <hartman@videolan.org>
Fri, 29 May 2009 18:42:37 +0000 (20:42 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 29 May 2009 22:32:44 +0000 (00:32 +0200)
A thank you to the Xbmc authors who had this fixed in their version of Martin Kahr's class.
(cherry picked from commit 7157ad33673305f7947fe84ca78374bdba5e64f8)

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/gui/macosx/AppleRemote.h
modules/gui/macosx/AppleRemote.m

index 28dce49d4fd61c0236d91c8bb2df233455c26ed6..8a34b9539a8723c72d9a16068b56be570c287dca 100644 (file)
@@ -86,6 +86,7 @@ The class is not thread safe
     IOHIDQueueInterface**  queue;
     NSMutableArray*        allCookies;
     NSMutableDictionary*   cookieToButtonMapping;
+    CFRunLoopSourceRef     eventSource;
 
     BOOL openInExclusiveMode;
     BOOL simulatePlusMinusHold;
index 2440120553e4c39a6fecdd18243a70e8dd02bc97..9790de2aa3e654c1daa25acda70eef0da4380c26 100644 (file)
@@ -231,6 +231,11 @@ cleanup:
 }
 
 - (IBAction) stopListening: (id) sender {
+    if (eventSource != NULL) {
+        CFRunLoopRemoveSource(CFRunLoopGetCurrent(), eventSource, kCFRunLoopDefaultMode);
+        CFRelease(eventSource);
+        eventSource = NULL;
+    }
     if (queue != NULL) {
         (*queue)->stop(queue);
 
@@ -619,7 +624,6 @@ static void QueueCallbackFunction(void* target,  IOReturn result, void* refcon,
             }
 
             // add callback for async events
-            CFRunLoopSourceRef eventSource;
             ioReturnValue = (*queue)->createAsyncEventSource(queue, &eventSource);
             if (ioReturnValue == KERN_SUCCESS) {
                 ioReturnValue = (*queue)->setEventCallout(queue,QueueCallbackFunction, self, NULL);