track Mix() call count for previous IOproc and last few Mix() durations

This commit is contained in:
Glenn Maynard
2004-06-06 04:33:25 +00:00
parent 9cb17abd2a
commit dc76bcfbba
@@ -19,7 +19,11 @@ static AudioConverter *gConverter;
/* temporary hack: */ /* temporary hack: */
static float g_fLastIOProcTime = 0; 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_iNumIOProcCalls = 0;
static int g_iNumMixCallsForLastIOProc = 0;
static CString FormatToString( int fmt ) 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 ) void RageSound_CA::FillConverter( void *data, UInt32 frames )
{ {
RageTimer tm;
this->Mix( (int16_t *)data, frames, mDecodePos, int64_t(mNow->mSampleTime) ); 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, OSStatus RageSound_CA::GetData(AudioDeviceID inDevice,
@@ -253,6 +265,7 @@ OSStatus RageSound_CA::GetData(AudioDeviceID inDevice,
void *inClientData) void *inClientData)
{ {
RageTimer tm; RageTimer tm;
g_iNumMixCallsForLastIOProc = 0;
RageSound_CA *This = (RageSound_CA *)inClientData; RageSound_CA *This = (RageSound_CA *)inClientData;
UInt32 dataPackets = outOutputData->mBuffers[0].mDataByteSize; UInt32 dataPackets = outOutputData->mBuffers[0].mDataByteSize;
@@ -275,8 +288,15 @@ OSStatus RageSound_CA::OverloadListener(AudioDeviceID inDevice,
AudioDevicePropertyID inPropertyID, AudioDevicePropertyID inPropertyID,
void *inData) void *inData)
{ {
LOG->Warn( "Audio overload. Last IOProc time: %f IOProc calls: %i", CString Output;
g_fLastIOProcTime, g_iNumIOProcCalls ); 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; g_iNumIOProcCalls = 0;
return noErr; return noErr;
} }