mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 04:20:20 +00:00
fix bug in corefoundation timer setup: unix time vs. absolute time
This commit is contained in:
parent
b375c84fc7
commit
cd1fcc0c4e
@ -101,8 +101,10 @@ int cocoa_remove_data_source(data_source_t *dataSource){
|
||||
|
||||
void cocoa_add_timer(timer_source_t * ts)
|
||||
{
|
||||
// printf("cocoa_add_timer %x\n", (int) ts);
|
||||
CFTimeInterval fireDate = ((double)ts->timeout.tv_sec) + (((double)ts->timeout.tv_usec)/1000000.0);
|
||||
// note: ts uses unix time: seconds since Jan 1st 1970, CF uses Jan 1st 2001 as reference date
|
||||
// printf("kCFAbsoluteTimeIntervalSince1970 = %f\n", kCFAbsoluteTimeIntervalSince1970);
|
||||
CFAbsoluteTime fireDate = ((double)ts->timeout.tv_sec) + (((double)ts->timeout.tv_usec)/1000000.0) - kCFAbsoluteTimeIntervalSince1970; // unix time - since Jan 1st 1970
|
||||
// printf("cocoa_add_timer %x, now %f, then %f\n", (int) ts, CFAbsoluteTimeGetCurrent(),fireDate);
|
||||
CFRunLoopTimerContext timerContext = {0, ts, NULL, NULL, NULL};
|
||||
CFRunLoopTimerRef timerRef = CFRunLoopTimerCreate (kCFAllocatorDefault,fireDate,0,0,0,theCFRunLoopTimerCallBack,&timerContext);
|
||||
|
||||
@ -113,9 +115,7 @@ void cocoa_add_timer(timer_source_t * ts)
|
||||
}
|
||||
|
||||
int cocoa_remove_timer(timer_source_t * ts){
|
||||
|
||||
// printf("cocoa_remove_timer ref %x\n", (int) ts->item.next);
|
||||
|
||||
CFRunLoopRemoveTimer(CFRunLoopGetCurrent(), (CFRunLoopTimerRef) ts->item.next, kCFRunLoopCommonModes);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user