Преглед на файлове

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

Ivan Safrin преди 10 години
родител
ревизия
83d8862093
променени са 4 файла, в които са добавени 12 реда и са изтрити 12 реда
  1. 2 2
      include/polycode/core/PolyCocoaCore.h
  2. BIN
      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 {
 	public:
+        void lock();
+        void unlock();
 		pthread_mutex_t pMutex;
 	};
 	
@@ -149,8 +151,6 @@ namespace Polycode {
 		
 		void makeApplicationMain();
 		
-		void lockMutex(CoreMutex *mutex);
-		void unlockMutex(CoreMutex *mutex);
 		CoreMutex *createMutex();		
 		
 		void checkEvents();		

BIN
lib/osx/libPolycore.a


+ 9 - 10
src/core/PolyCocoaCore.mm

@@ -39,6 +39,15 @@
 
 using namespace Polycode;
 
+void PosixMutex::lock() {
+    pthread_mutex_lock(&pMutex);    
+}
+
+void PosixMutex::unlock() {
+    pthread_mutex_unlock(&pMutex);
+}
+
+
 static bool DisplayModeIs32Bit(CGDisplayModeRef displayMode)
 {
 	bool is32Bit = false;
@@ -344,16 +353,6 @@ void CocoaCore::createThread(Threaded *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() {
 	PosixMutex *mutex = new PosixMutex();	
 	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();
 
 	if (sounds.size() == 0) {
+        memset(buffer, 0, sizeof(int16_t) * numSamples * POLY_NUM_CHANNELS);
 		mixerMutex->unlock();
 		return;
 	}