mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
(btdynamic.c) Add __APPLE__ ifdefs
This commit is contained in:
parent
a980c9c7c7
commit
fb805be085
@ -16,8 +16,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "../../../dynamic.h"
|
#include "../../../dynamic.h"
|
||||||
#include <CoreFoundation/CFRunLoop.h>
|
|
||||||
#include <rthreads/rthreads.h>
|
#include <rthreads/rthreads.h>
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <CoreFoundation/CFRunLoop.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define BUILDING_BTDYNAMIC
|
#define BUILDING_BTDYNAMIC
|
||||||
#include "btdynamic.h"
|
#include "btdynamic.h"
|
||||||
@ -66,7 +68,10 @@ static bool btstack_tested;
|
|||||||
static bool btstack_loaded;
|
static bool btstack_loaded;
|
||||||
|
|
||||||
static sthread_t *btstack_thread;
|
static sthread_t *btstack_thread;
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
static CFRunLoopSourceRef btstack_quit_source;
|
static CFRunLoopSourceRef btstack_quit_source;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool btstack_try_load(void)
|
bool btstack_try_load(void)
|
||||||
{
|
{
|
||||||
@ -116,20 +121,26 @@ static void btstack_thread_func(void* data)
|
|||||||
if (bt_open_ptr())
|
if (bt_open_ptr())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
CFRunLoopSourceContext ctx = { 0, 0, 0, 0, 0, 0, 0, 0, 0, btstack_thread_stop };
|
CFRunLoopSourceContext ctx = { 0, 0, 0, 0, 0, 0, 0, 0, 0, btstack_thread_stop };
|
||||||
btstack_quit_source = CFRunLoopSourceCreate(0, 0, &ctx);
|
btstack_quit_source = CFRunLoopSourceCreate(0, 0, &ctx);
|
||||||
CFRunLoopAddSource(CFRunLoopGetCurrent(), btstack_quit_source, kCFRunLoopCommonModes);
|
CFRunLoopAddSource(CFRunLoopGetCurrent(), btstack_quit_source, kCFRunLoopCommonModes);
|
||||||
|
#endif
|
||||||
|
|
||||||
RARCH_LOG("[BTstack]: Turning on...\n");
|
RARCH_LOG("[BTstack]: Turning on...\n");
|
||||||
bt_send_cmd_ptr(btstack_set_power_mode_ptr, HCI_POWER_ON);
|
bt_send_cmd_ptr(btstack_set_power_mode_ptr, HCI_POWER_ON);
|
||||||
|
|
||||||
RARCH_LOG("BTstack: Thread running...\n");
|
RARCH_LOG("BTstack: Thread running...\n");
|
||||||
|
#ifdef __APPLE__
|
||||||
CFRunLoopRun();
|
CFRunLoopRun();
|
||||||
|
#endif
|
||||||
|
|
||||||
RARCH_LOG("[BTstack]: Thread done.\n");
|
RARCH_LOG("[BTstack]: Thread done.\n");
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
CFRunLoopSourceInvalidate(btstack_quit_source);
|
CFRunLoopSourceInvalidate(btstack_quit_source);
|
||||||
CFRelease(btstack_quit_source);
|
CFRelease(btstack_quit_source);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void btstack_set_poweron(bool on)
|
void btstack_set_poweron(bool on)
|
||||||
@ -141,7 +152,9 @@ void btstack_set_poweron(bool on)
|
|||||||
btstack_thread = sthread_create(btstack_thread_func, NULL);
|
btstack_thread = sthread_create(btstack_thread_func, NULL);
|
||||||
else if (!on && btstack_thread && btstack_quit_source)
|
else if (!on && btstack_thread && btstack_quit_source)
|
||||||
{
|
{
|
||||||
|
#ifdef __APPLE__
|
||||||
CFRunLoopSourceSignal(btstack_quit_source);
|
CFRunLoopSourceSignal(btstack_quit_source);
|
||||||
|
#endif
|
||||||
sthread_join(btstack_thread);
|
sthread_join(btstack_thread);
|
||||||
btstack_thread = NULL;
|
btstack_thread = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user