diff --git a/KREngine/kraken/KRAudioManager.cpp b/KREngine/kraken/KRAudioManager.cpp index 72aa05b..9f8449a 100644 --- a/KREngine/kraken/KRAudioManager.cpp +++ b/KREngine/kraken/KRAudioManager.cpp @@ -1491,7 +1491,19 @@ void KRAudioManager::setGlobalAmbientGain(float gain) void KRAudioManager::startFrame(float deltaTime) { - m_mutex.lock(); + static unsigned long trackCount = 0; + static unsigned long trackMissed = 0; + trackCount++; + if (trackCount > 200) { +// printf("Missed %ld out of 200 try_lock attempts on audio startFrame\n", trackMissed); + trackCount = 0; + trackMissed = 0; + } + + if (!m_mutex.try_lock()) { + trackMissed++; + return; // if we are rendering audio don't update audio state + } // NOTE: this misses anywhere from 0 to to 30 times out of 200 on the iPad2 // ----====---- Determine Ambient Zone Contributions ----====---- m_ambient_zone_weights.clear(); diff --git a/KREngine/kraken/KRAudioManager.h b/KREngine/kraken/KRAudioManager.h index 132e662..c19697c 100644 --- a/KREngine/kraken/KRAudioManager.h +++ b/KREngine/kraken/KRAudioManager.h @@ -40,9 +40,10 @@ #include "KRMat4.h" #include "KRAudioSource.h" -const int KRENGINE_AUDIO_MAX_POOL_SIZE = 40; //32; - // for Circa we play a maximum of 7 mono audio streams at once + cross fading with ambient - // so we could safely say a maximum of 10 streams, which would be 33 buffers +const int KRENGINE_AUDIO_MAX_POOL_SIZE = 60; //32; + // for Circa we play a maximum of 11 mono audio streams at once + cross fading with ambient + // so we could safely say a maximum of 12 or 13 streams, which would be 39 buffers + // do the WAV files for the reverb use the same buffer pool ??? const int KRENGINE_AUDIO_MAX_BUFFER_SIZE = 5120; // in bytes // this is the buffer for our decoded audio (not the source file data)