Move NSAutoreleasePool handling into the proper entry/exit points

for the real wiimote thread as for the other threads.

Turns out we use OS X bluetooth API's that were introduced in 10.5.4.
 
Remove vestiges of previously removed wiiuse_set_bluetooth_stack().

XXX We should probably have a Common equivalent of htonl and friends.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6531 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang 2010-12-05 16:18:09 +00:00
parent 5910ef259c
commit 4934cd29b3
6 changed files with 27 additions and 43 deletions

View file

@ -117,7 +117,7 @@ rev = utils.GenerateRevFile(env['flavor'], '.', None)
# OS X specifics # OS X specifics
if sys.platform == 'darwin': if sys.platform == 'darwin':
ccld = ['-arch', 'x86_64', '-arch', 'i386', '-mmacosx-version-min=10.5'] ccld = ['-arch', 'x86_64', '-arch', 'i386', '-mmacosx-version-min=10.5.4']
ccld += ['--sysroot=/Developer/SDKs/MacOSX10.5.sdk'] ccld += ['--sysroot=/Developer/SDKs/MacOSX10.5.sdk']
system = '/System/Library/Frameworks' system = '/System/Library/Frameworks'
env['CCFLAGS'] += ccld env['CCFLAGS'] += ccld

View file

@ -36,6 +36,10 @@
#pragma comment(lib, "Bthprops.lib") #pragma comment(lib, "Bthprops.lib")
#endif #endif
#ifdef __APPLE__
#import <Foundation/NSAutoreleasePool.h>
#endif
unsigned int g_wiimote_sources[MAX_WIIMOTES]; unsigned int g_wiimote_sources[MAX_WIIMOTES];
namespace WiimoteReal namespace WiimoteReal
@ -468,6 +472,10 @@ void StopWiimoteThreads()
THREAD_RETURN WiimoteThreadFunc(void* arg) THREAD_RETURN WiimoteThreadFunc(void* arg)
{ {
#ifdef __APPLE__
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
#endif
Wiimote* const wiimote = (Wiimote*)arg; Wiimote* const wiimote = (Wiimote*)arg;
{ {
@ -492,6 +500,9 @@ THREAD_RETURN WiimoteThreadFunc(void* arg)
Common::SleepCurrentThread(1); Common::SleepCurrentThread(1);
} }
#ifdef __APPLE__
[pool release];
#endif
return 0; return 0;
} }

View file

@ -84,8 +84,8 @@ elif sys.platform == 'darwin' and env['HAVE_WX']:
CFBundlePackageType = 'APPL', CFBundlePackageType = 'APPL',
CFBundleShortVersionString = CFBundleShortVersionString =
utils.GenerateRevFile('', Dir('#None').abspath, None), utils.GenerateRevFile('', Dir('#None').abspath, None),
CFBundleVersion = '2.0', CFBundleVersion = '3.0',
LSMinimumSystemVersion = '10.5.0', LSMinimumSystemVersion = '10.5.4',
LSRequiresCarbon = True, LSRequiresCarbon = True,
))) )))
else: else:

View file

@ -34,10 +34,7 @@
#import <CoreServices/CoreServices.h> #import <CoreServices/CoreServices.h>
extern "C" OSErr UpdateSystemActivity(UInt8 activity); extern "C" OSErr UpdateSystemActivity(UInt8 activity);
#define BLUETOOTH_VERSION_USE_CURRENT #define BLUETOOTH_VERSION_USE_CURRENT
#import <IOBluetooth/objc/IOBluetoothDevice.h> #import <IOBluetooth/IOBluetooth.h>
#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
#import <IOBluetooth/objc/IOBluetoothHostController.h>
#import <IOBluetooth/objc/IOBluetoothL2CAPChannel.h>
#include "Common.h" #include "Common.h"
#include "wiiuse_internal.h" #include "wiiuse_internal.h"
@ -116,7 +113,7 @@ volatile int reader, writer, outstanding, watermark;
CFRunLoopStop(CFRunLoopGetCurrent()); CFRunLoopStop(CFRunLoopGetCurrent());
UpdateSystemActivity(1); (void)UpdateSystemActivity(1);
} }
- (void) l2capChannelClosed: (IOBluetoothL2CAPChannel *) l2capChannel - (void) l2capChannelClosed: (IOBluetoothL2CAPChannel *) l2capChannel
@ -151,7 +148,6 @@ volatile int reader, writer, outstanding, watermark;
*/ */
int wiiuse_find(struct wiimote_t **wm, int max_wiimotes, int timeout) int wiiuse_find(struct wiimote_t **wm, int max_wiimotes, int timeout)
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
IOBluetoothHostController *bth; IOBluetoothHostController *bth;
IOBluetoothDeviceInquiry *bti; IOBluetoothDeviceInquiry *bti;
SearchBT *sbt; SearchBT *sbt;
@ -199,7 +195,6 @@ int wiiuse_find(struct wiimote_t **wm, int max_wiimotes, int timeout)
[bth release]; [bth release];
[bti release]; [bti release];
[sbt release]; [sbt release];
[pool release];
return found_devices; return found_devices;
} }
@ -247,7 +242,6 @@ int wiiuse_connect(struct wiimote_t **wm, int wiimotes)
*/ */
static int wiiuse_connect_single(struct wiimote_t *wm, char *address) static int wiiuse_connect_single(struct wiimote_t *wm, char *address)
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
ConnectBT *cbt = [[ConnectBT alloc] init]; ConnectBT *cbt = [[ConnectBT alloc] init];
if (wm == NULL || WIIMOTE_IS_CONNECTED(wm)) if (wm == NULL || WIIMOTE_IS_CONNECTED(wm))
@ -268,7 +262,6 @@ static int wiiuse_connect_single(struct wiimote_t *wm, char *address)
wiiuse_set_report_type(wm); wiiuse_set_report_type(wm);
[cbt release]; [cbt release];
[pool release];
return 1; return 1;
} }
@ -284,8 +277,6 @@ static int wiiuse_connect_single(struct wiimote_t *wm, char *address)
*/ */
void wiiuse_disconnect(struct wiimote_t *wm) void wiiuse_disconnect(struct wiimote_t *wm)
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (wm == NULL) if (wm == NULL)
return; return;
@ -297,7 +288,6 @@ void wiiuse_disconnect(struct wiimote_t *wm)
[cchan closeChannel]; [cchan closeChannel];
[ichan closeChannel]; [ichan closeChannel];
[btd closeConnection]; [btd closeConnection];
[pool release];
} }
int wiiuse_io_read(struct wiimote_t *wm) int wiiuse_io_read(struct wiimote_t *wm)

View file

@ -300,7 +300,11 @@ int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte
#endif #endif
/* the offset is in big endian */ /* the offset is in big endian */
*(int*)(buf) = Common::swap32(addr); /* XXX only if little-endian */ #ifdef __BIG_ENDIAN__
*(int*)(buf) = addr;
#else
*(int*)(buf) = Common::swap32(addr);
#endif
/* length */ /* length */
*(byte*)(buf + 4) = len; *(byte*)(buf + 4) = len;
@ -366,26 +370,6 @@ int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len) {
} }
/**
* @brief Set the bluetooth stack type to use.
*
* @param wm Array of wiimote_t structures.
* @param wiimotes Number of objects in the wm array.
* @param type The type of bluetooth stack to use.
*/
void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type) {
#ifdef _WIN32
int i;
if (!wm) return;
for (i = 0; i < wiimotes; ++i)
wm[i]->stack = type;
#endif
}
/** /**
* @brief Set the normal and expansion handshake timeouts. * @brief Set the normal and expansion handshake timeouts.
* *

View file

@ -42,9 +42,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include <CoreFoundation/CoreFoundation.h> #import <IOBluetooth/IOBluetooth.h>
#include <IOBluetooth/IOBluetoothUserLib.h>
#include <string.h>
#elif defined(__linux__) #elif defined(__linux__)
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
@ -154,16 +152,17 @@ typedef struct wiimote_t {
WCONST int unid; /**< user specified id */ WCONST int unid; /**< user specified id */
#if defined(__APPLE__) #if defined(__APPLE__)
WCONST IOBluetoothDeviceRef *device; WCONST IOBluetoothDevice *btd;
WCONST char bdaddr_str[18]; WCONST IOBluetoothL2CAPChannel *ichan;
WCONST IOBluetoothL2CAPChannel *cchan;
#elif defined(__linux__) && HAVE_BLUEZ #elif defined(__linux__) && HAVE_BLUEZ
WCONST bdaddr_t bdaddr; /**< bt address (linux) */ WCONST bdaddr_t bdaddr; /**< bt address (linux) */
WCONST char bdaddr_str[18]; /**< readable bt address */ WCONST char bdaddr_str[18]; /**< readable bt address */
WCONST int out_sock; /**< output socket */ WCONST int out_sock; /**< output socket */
WCONST int in_sock; /**< input socket */ WCONST int in_sock; /**< input socket */
#elif defined(_WIN32) #elif defined(_WIN32)
WCONST char devicepath[255]; /**< unique wiimote reference */ WCONST char devicepath[255]; /**< unique wiimote reference */
//WCONST ULONGLONG btaddr; /**< bt address (windows) */ //WCONST ULONGLONG btaddr; /**< bt address (windows) */
WCONST HANDLE dev_handle; /**< HID handle */ WCONST HANDLE dev_handle; /**< HID handle */
WCONST OVERLAPPED hid_overlap; /**< overlap handle */ WCONST OVERLAPPED hid_overlap; /**< overlap handle */
WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */ WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */