From 6222af090dc7b4a98a24f143e86c21bc5c627fb6 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald" Date: Wed, 28 Oct 2009 22:16:25 +0000 Subject: [PATCH] store run loop not socket in cocoa run loops --- TODO.txt | 8 ++++---- src/run_loop_cocoa.m | 11 +++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/TODO.txt b/TODO.txt index 68d27ba30..47f8e59a0 100644 --- a/TODO.txt +++ b/TODO.txt @@ -2,6 +2,7 @@ NEXT: - prepend all source files with 'new BSD' copyright header +- figure out how to add BTstack logo to Cydia repository list == Release Version 0.1 @@ -9,6 +10,9 @@ NEXT: when phone gets locked - some trick - use Cocoa run loop for background app? + - see iPhone imsomnia project at http://code.google.com/p/iphone-insomnia/ + - can we get willGoToSleep event, should we turn off Bluetooth? + - would be nice, if we could get woken up by Bluetooth data - create - add timeouts to cocoa run loop - implement rest of L2CAP state machine @@ -17,10 +21,6 @@ NEXT: - commands and events - RFCOMM implementation - use switch on RFCOMM control field in rfcomm.c packet handler -- detect and handle iPhone sleep mode - - see iPhone imsomnia project at http://code.google.com/p/iphone-insomnia/ - - can we get willGoToSleep event, should we turn off Bluetooth? - - would be nice, if we could get woken up by Bluetooth data - CocoaTouch User Interface Components - Provide BTstack class - Warning and shutdown of Apple's stack diff --git a/src/run_loop_cocoa.m b/src/run_loop_cocoa.m index 0cbf86ec0..e8c7e74d2 100644 --- a/src/run_loop_cocoa.m +++ b/src/run_loop_cocoa.m @@ -40,16 +40,19 @@ void cocoa_add_data_source(data_source_t *dataSource){ socketDataCallback, &socketContext ); - // hack: store CFSocketRef in next pointer of linked_item - dataSource->item.next = (void *) socket; - // create run loop source and add to run loop + // create run loop source CFRunLoopSourceRef socketRunLoop = CFSocketCreateRunLoopSource ( kCFAllocatorDefault, socket, 0); + + // hack: store CFSocketRef in next pointer of linked_item + dataSource->item.next = (void *) socketRunLoop; + + // add to run loop CFRunLoopAddSource( CFRunLoopGetCurrent(), socketRunLoop, kCFRunLoopDefaultMode); } int cocoa_remove_data_source(data_source_t *dataSource){ - CFRunLoopRemoveSource( CFRunLoopGetCurrent(), dataSource->item.next, kCFRunLoopCommonModes); + CFRunLoopRemoveSource( CFRunLoopGetCurrent(), (CFRunLoopSourceRef) dataSource->item.next, kCFRunLoopCommonModes); return 0; }