From dc76bcfbbac43eef40e3d2651536360b8f91e7eb Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 6 Jun 2004 04:33:25 +0000 Subject: [PATCH] track Mix() call count for previous IOproc and last few Mix() durations --- .../src/arch/Sound/RageSoundDriver_CA.cpp | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp b/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp index c8aab195a4..25df3ad408 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp @@ -19,7 +19,11 @@ static AudioConverter *gConverter; /* temporary hack: */ static float g_fLastIOProcTime = 0; +static const int NUM_MIX_TIMES = 16; +static float g_fLastMixTimes[NUM_MIX_TIMES]; +static int g_fLastMixTimePos = 0; static int g_iNumIOProcCalls = 0; +static int g_iNumMixCallsForLastIOProc = 0; static CString FormatToString( int fmt ) { @@ -241,7 +245,15 @@ int64_t RageSound_CA::GetPosition(const RageSoundBase *sound) const void RageSound_CA::FillConverter( void *data, UInt32 frames ) { + RageTimer tm; + this->Mix( (int16_t *)data, frames, mDecodePos, int64_t(mNow->mSampleTime) ); + + g_fLastMixTimes[g_fLastMixTimePos] = tm.GetDeltaTime(); + ++g_fLastMixTimePos; + wrap( g_fLastMixTimePos, NUM_MIX_TIMES ); + + ++g_iNumMixCallsForLastIOProc; } OSStatus RageSound_CA::GetData(AudioDeviceID inDevice, @@ -253,6 +265,7 @@ OSStatus RageSound_CA::GetData(AudioDeviceID inDevice, void *inClientData) { RageTimer tm; + g_iNumMixCallsForLastIOProc = 0; RageSound_CA *This = (RageSound_CA *)inClientData; UInt32 dataPackets = outOutputData->mBuffers[0].mDataByteSize; @@ -275,8 +288,15 @@ OSStatus RageSound_CA::OverloadListener(AudioDeviceID inDevice, AudioDevicePropertyID inPropertyID, void *inData) { - LOG->Warn( "Audio overload. Last IOProc time: %f IOProc calls: %i", - g_fLastIOProcTime, g_iNumIOProcCalls ); + CString Output; + for( int i = 0; i < NUM_MIX_TIMES; ++i ) + { + int pos = (g_fLastMixTimePos+i) % NUM_MIX_TIMES; + Output += ssprintf( "%.4f ", g_fLastMixTimes[pos] ); + } + + LOG->Warn( "Audio overload. Last IOProc time: %f IOProc calls: %i (%s) %i", + g_fLastIOProcTime, g_iNumIOProcCalls, Output.c_str(), g_iNumMixCallsForLastIOProc ); g_iNumIOProcCalls = 0; return noErr; }