From 7185797b4a7fa5b8ede8346d2c381e8bb78e4edd Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Tue, 27 Apr 2004 06:44:20 +0000 Subject: [PATCH] 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. --- .../src/arch/Sound/RageSoundDriver_CA.cpp | 67 ++++++++++--------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp b/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp index f732a5c168..6376cb9630 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp @@ -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();