store run loop not socket in cocoa run loops

This commit is contained in:
matthias.ringwald 2009-10-28 22:16:25 +00:00
parent 1602e98e14
commit 6222af090d
2 changed files with 11 additions and 8 deletions

View File

@ -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 <btstack/errors.h>
- 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

View File

@ -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;
}