[vlc-devel] commit: macosx remote: Fix a leak in the Apple Remote class. ( Derk-Jan Hartman )

git version control git at videolan.org
Fri May 29 20:48:50 CEST 2009


vlc | branch: 1.0-bugfix | Derk-Jan Hartman <hartman at videolan.org> | Fri May 29 20:42:37 2009 +0200| [7157ad33673305f7947fe84ca78374bdba5e64f8] | committer: Derk-Jan Hartman 

macosx remote: Fix a leak in the Apple Remote class.

A thank you to the Xbmc authors who had this fixed in their version of Martin Kahr's class.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7157ad33673305f7947fe84ca78374bdba5e64f8
---

 modules/gui/macosx/AppleRemote.h |    1 +
 modules/gui/macosx/AppleRemote.m |    6 +++++-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/modules/gui/macosx/AppleRemote.h b/modules/gui/macosx/AppleRemote.h
index 28dce49..8a34b95 100644
--- a/modules/gui/macosx/AppleRemote.h
+++ b/modules/gui/macosx/AppleRemote.h
@@ -86,6 +86,7 @@ The class is not thread safe
     IOHIDQueueInterface**  queue;
     NSMutableArray*        allCookies;
     NSMutableDictionary*   cookieToButtonMapping;
+    CFRunLoopSourceRef     eventSource;
 
     BOOL openInExclusiveMode;
     BOOL simulatePlusMinusHold;
diff --git a/modules/gui/macosx/AppleRemote.m b/modules/gui/macosx/AppleRemote.m
index 2440120..9790de2 100644
--- a/modules/gui/macosx/AppleRemote.m
+++ b/modules/gui/macosx/AppleRemote.m
@@ -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);




More information about the vlc-devel mailing list