Jelajahi Sumber

Update CocoaCore for latest Core specs, SoundManager will now explicitly write silence to buffer when there are no sounds to mix

Ivan Safrin 10 tahun lalu
induk
melakukan
83d8862093
4 mengubah file dengan 12 tambahan dan 12 penghapusan
  1. 2 2
      include/polycode/core/PolyCocoaCore.h
  2. TEMPAT SAMPAH
      lib/osx/libPolycore.a
  3. 9 10
      src/core/PolyCocoaCore.mm
  4. 1 0
      src/core/PolySoundManager.cpp

+ 2 - 2
include/polycode/core/PolyCocoaCore.h

@@ -48,6 +48,8 @@ namespace Polycode {
 	
 	
 	class _PolyExport PosixMutex : public CoreMutex {
 	class _PolyExport PosixMutex : public CoreMutex {
 	public:
 	public:
+        void lock();
+        void unlock();
 		pthread_mutex_t pMutex;
 		pthread_mutex_t pMutex;
 	};
 	};
 	
 	
@@ -149,8 +151,6 @@ namespace Polycode {
 		
 		
 		void makeApplicationMain();
 		void makeApplicationMain();
 		
 		
-		void lockMutex(CoreMutex *mutex);
-		void unlockMutex(CoreMutex *mutex);
 		CoreMutex *createMutex();		
 		CoreMutex *createMutex();		
 		
 		
 		void checkEvents();		
 		void checkEvents();		

TEMPAT SAMPAH
lib/osx/libPolycore.a


+ 9 - 10
src/core/PolyCocoaCore.mm

@@ -39,6 +39,15 @@
 
 
 using namespace Polycode;
 using namespace Polycode;
 
 
+void PosixMutex::lock() {
+    pthread_mutex_lock(&pMutex);    
+}
+
+void PosixMutex::unlock() {
+    pthread_mutex_unlock(&pMutex);
+}
+
+
 static bool DisplayModeIs32Bit(CGDisplayModeRef displayMode)
 static bool DisplayModeIs32Bit(CGDisplayModeRef displayMode)
 {
 {
 	bool is32Bit = false;
 	bool is32Bit = false;
@@ -344,16 +353,6 @@ void CocoaCore::createThread(Threaded *target) {
 	pthread_create( &thread, NULL, ManagedThreadFunc, (void*)target);
 	pthread_create( &thread, NULL, ManagedThreadFunc, (void*)target);
 }
 }
 
 
-void CocoaCore::lockMutex(CoreMutex *mutex) {
-	PosixMutex *m = (PosixMutex*) mutex;
-	pthread_mutex_lock(&m->pMutex);	
-}
-
-void CocoaCore::unlockMutex(CoreMutex *mutex) {
-	PosixMutex *m = (PosixMutex*) mutex;
-	pthread_mutex_unlock(&m->pMutex);
-}
-
 CoreMutex *CocoaCore::createMutex() {
 CoreMutex *CocoaCore::createMutex() {
 	PosixMutex *mutex = new PosixMutex();	
 	PosixMutex *mutex = new PosixMutex();	
 	pthread_mutex_init(&mutex->pMutex, NULL);
 	pthread_mutex_init(&mutex->pMutex, NULL);

+ 1 - 0
src/core/PolySoundManager.cpp

@@ -164,6 +164,7 @@ void AudioMixer::mixIntoBuffer(int16_t *buffer, unsigned int numSamples) {
 	mixerMutex->lock();
 	mixerMutex->lock();
 
 
 	if (sounds.size() == 0) {
 	if (sounds.size() == 0) {
+        memset(buffer, 0, sizeof(int16_t) * numSamples * POLY_NUM_CHANNELS);
 		mixerMutex->unlock();
 		mixerMutex->unlock();
 		return;
 		return;
 	}
 	}