Rearrange things a bit in case the buffer size is dependent on the stream format--it doesn't appear to be but you never know.

This commit is contained in:
Steve Checkoway
2004-04-27 06:44:20 +00:00
parent 55975d9ba9
commit 7185797b4a
+37 -30
View File
@@ -86,38 +86,10 @@ RageSound_CA::RageSound_CA()
{
RageException::ThrowNonfatal("Couldn't create default output device.");
}
AudioStreamID sID = mOutputDevice->GetStreamByIndex( kAudioDeviceSectionOutput, 0 );
CAAudioHardwareStream stream( sID );
try
{
UInt32 frames = mOutputDevice->GetLatency(kAudioDeviceSectionOutput);
if (stream.HasProperty(0, kAudioDevicePropertyLatency))
{
UInt32 t, size = 4;
stream.GetPropertyData(0, kAudioDevicePropertyLatency, size, &t);
frames += t;
}
else
LOG->Warn("Stream reports no latency.");
mLatency = frames / 44100.0;
LOG->Info("Frames of latency: %lu\n"
"Seconds of latency: %f", frames, mLatency);
}
catch (const CAException& e)
{
delete mOutputDevice;
RageException::ThrowNonfatal("Couldn't get Latency.");
}
try
{
UInt32 bufferSize = mOutputDevice->GetIOBufferSize();
LOG->Info("I/O Buffer size: %lu", bufferSize);
}
catch (const CAException& e)
{
LOG->Warn("Could not determine buffer size.");
}
try
{
mOutputDevice->AddPropertyListener(kAudioPropertyWildcardChannel,
@@ -161,6 +133,41 @@ RageSound_CA::RageSound_CA()
}
const Desc& procFormat = FindClosestFormat( procFormats );
stream.SetCurrentIOProcFormat( procFormat );
try
{
UInt32 bufferSize = mOutputDevice->GetIOBufferSize();
LOG->Info("I/O Buffer size: %lu", bufferSize);
}
catch (const CAException& e)
{
LOG->Warn("Could not determine buffer size.");
}
try
{
UInt32 frames = mOutputDevice->GetLatency(kAudioDeviceSectionOutput);
if (stream.HasProperty(0, kAudioDevicePropertyLatency))
{
UInt32 t, size = 4;
stream.GetPropertyData(0, kAudioDevicePropertyLatency, size, &t);
frames += t;
LOG->Info("Frames of stream latency: %lu", t);
}
else
LOG->Warn("Stream reports no latency.");
mLatency = frames / 44100.0;
LOG->Info("Frames of latency: %lu\n"
"Seconds of latency: %f", frames, mLatency);
}
catch (const CAException& e)
{
delete mOutputDevice;
RageException::ThrowNonfatal("Couldn't get Latency.");
}
StartDecodeThread();