aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorOystein Eftevaag2007-12-22 11:53:04 +0000
committerOystein Eftevaag2007-12-22 11:53:04 +0000
commitf00ebbf8d908b6865c67edcd59eba55d99d223b0 (patch)
tree89e6658c7a634c9c078d3234886f4a7e757e9d7f /backends/platform
parent337db5d4c785df251f79b8778e74e6b9294c7383 (diff)
downloadscummvm-rg350-f00ebbf8d908b6865c67edcd59eba55d99d223b0.tar.gz
scummvm-rg350-f00ebbf8d908b6865c67edcd59eba55d99d223b0.tar.bz2
scummvm-rg350-f00ebbf8d908b6865c67edcd59eba55d99d223b0.zip
Fixed mutex handling, and reverted sound callbacks to be from another thread again
svn-id: r29951
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/iphone/osys_iphone.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/backends/platform/iphone/osys_iphone.cpp b/backends/platform/iphone/osys_iphone.cpp
index 83aa27c0c3..24cd44ac69 100644
--- a/backends/platform/iphone/osys_iphone.cpp
+++ b/backends/platform/iphone/osys_iphone.cpp
@@ -562,7 +562,6 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot
bool OSystem_IPHONE::pollEvent(Common::Event &event) {
//printf("pollEvent()\n");
- CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
long curTime = getMillis();
@@ -876,36 +875,41 @@ uint32 OSystem_IPHONE::getMillis() {
void OSystem_IPHONE::delayMillis(uint msecs) {
//printf("delayMillis(%d)\n", msecs);
usleep(msecs * 1000);
- CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
}
OSystem::MutexRef OSystem_IPHONE::createMutex(void) {
- // pthread_mutex_t *mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
- // if (pthread_mutex_init(mutex, NULL) != 0) {
- // printf("pthread_mutex_init() failed!\n");
- // }
- // return (MutexRef)mutex;
- return NULL;
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+
+ pthread_mutex_t *mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
+ if (pthread_mutex_init(mutex, &attr) != 0) {
+ printf("pthread_mutex_init() failed!\n");
+ free(mutex);
+ return NULL;
+ }
+
+ return (MutexRef)mutex;
}
void OSystem_IPHONE::lockMutex(MutexRef mutex) {
- // if (pthread_mutex_lock((pthread_mutex_t *) mutex) != 0) {
- // printf("pthread_mutex_lock() failed!\n");
- // }
+ if (pthread_mutex_lock((pthread_mutex_t *) mutex) != 0) {
+ printf("pthread_mutex_lock() failed!\n");
+ }
}
void OSystem_IPHONE::unlockMutex(MutexRef mutex) {
- // if (pthread_mutex_unlock((pthread_mutex_t *) mutex) != 0) {
- // printf("pthread_mutex_unlock() failed!\n");
- // }
+ if (pthread_mutex_unlock((pthread_mutex_t *) mutex) != 0) {
+ printf("pthread_mutex_unlock() failed!\n");
+ }
}
void OSystem_IPHONE::deleteMutex(MutexRef mutex) {
- // if (pthread_mutex_destroy((pthread_mutex_t *) mutex) != 0) {
- // printf("pthread_mutex_destroy() failed!\n");
- // } else {
- // free(mutex);
- // }
+ if (pthread_mutex_destroy((pthread_mutex_t *) mutex) != 0) {
+ printf("pthread_mutex_destroy() failed!\n");
+ } else {
+ free(mutex);
+ }
}
void OSystem_IPHONE::AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB) {
@@ -933,7 +937,7 @@ bool OSystem_IPHONE::setSoundCallback(SoundProc proc, void *param) {
s_AudioQueue.dataFormat.mBitsPerChannel = 16;
s_AudioQueue.frameCount = WAVE_BUFFER_SIZE;
- if (AudioQueueNewOutput(&s_AudioQueue.dataFormat, AQBufferCallback, &s_AudioQueue, CFRunLoopGetCurrent(), kCFRunLoopCommonModes, 0, &s_AudioQueue.queue)) {
+ if (AudioQueueNewOutput(&s_AudioQueue.dataFormat, AQBufferCallback, &s_AudioQueue, 0, kCFRunLoopCommonModes, 0, &s_AudioQueue.queue)) {
printf("Couldn't set the AudioQueue callback!\n");
return false;
}