[Scummvm-cvs-logs] SF.net SVN: scummvm: [29951] scummvm/trunk/backends/platform/iphone/ osys_iphone.cpp

vinterstum at users.sourceforge.net vinterstum at users.sourceforge.net
Sat Dec 22 12:53:05 CET 2007


Revision: 29951
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29951&view=rev
Author:   vinterstum
Date:     2007-12-22 03:53:04 -0800 (Sat, 22 Dec 2007)

Log Message:
-----------
Fixed mutex handling, and reverted sound callbacks to be from another thread again

Modified Paths:
--------------
    scummvm/trunk/backends/platform/iphone/osys_iphone.cpp

Modified: scummvm/trunk/backends/platform/iphone/osys_iphone.cpp
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_iphone.cpp	2007-12-22 11:34:10 UTC (rev 29950)
+++ scummvm/trunk/backends/platform/iphone/osys_iphone.cpp	2007-12-22 11:53:04 UTC (rev 29951)
@@ -562,7 +562,6 @@
 
 bool OSystem_IPHONE::pollEvent(Common::Event &event) {
 	//printf("pollEvent()\n");
-	CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
 
 	long curTime = getMillis();
 	
@@ -876,36 +875,41 @@
 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 @@
 	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;
 	}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list