AudioManager - increased pool size to reduce dropouts. Change startFrame locks to non-blocking - improves FPS a bit and dropout rate goes down.

--HG--
branch : nfb
This commit is contained in:
Peter Courtemanche
2014-01-14 19:12:51 -08:00
parent ca1af8dd3e
commit cae949c259
2 changed files with 17 additions and 4 deletions

View File

@@ -1491,7 +1491,19 @@ void KRAudioManager::setGlobalAmbientGain(float gain)
void KRAudioManager::startFrame(float deltaTime) 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 ----====---- // ----====---- Determine Ambient Zone Contributions ----====----
m_ambient_zone_weights.clear(); m_ambient_zone_weights.clear();

View File

@@ -40,9 +40,10 @@
#include "KRMat4.h" #include "KRMat4.h"
#include "KRAudioSource.h" #include "KRAudioSource.h"
const int KRENGINE_AUDIO_MAX_POOL_SIZE = 40; //32; const int KRENGINE_AUDIO_MAX_POOL_SIZE = 60; //32;
// for Circa we play a maximum of 7 mono audio streams at once + cross fading with ambient // 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 10 streams, which would be 33 buffers // 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 const int KRENGINE_AUDIO_MAX_BUFFER_SIZE = 5120; // in bytes
// this is the buffer for our decoded audio (not the source file data) // this is the buffer for our decoded audio (not the source file data)