From 3134764b8313fbb8d45f6bc4aac79628afe6c47a Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Sat, 26 Mar 2005 02:33:44 +0000 Subject: [PATCH] Attempt to support more audio hardware. (I have no way to really test this.) --- .../src/arch/Sound/RageSoundDriver_CA.cpp | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp b/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp index 3680a43293..e6d84da5d6 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp @@ -43,8 +43,8 @@ static CString FormatToString( int fmt ) /* Sanitize: */ for( int i = 0; i < 4; ++i ) - if( c[i] < 32 || c[i] >= 127 ) - return ssprintf( "0x%X", fmt ); + if( !isalpha(c[i]) ) + return ssprintf( "%#X", fmt ); return ssprintf( "%c%c%c%c", c[0], c[1], c[2], c[3] ); } @@ -66,14 +66,18 @@ CString RageSound_CA::Init() { return "Couldn't create default output device."; } + + Float64 nominalSampleRate = 44100.0; try { - mOutputDevice->SetNominalSampleRate(44100.0); + mOutputDevice->SetNominalSampleRate(nominalSampleRate); } catch (const CAException& e) { - return "Couldn't set the nominal sample rate."; + LOG->Warn("Couldn't set the nominal sample rate."); + nominalSampleRate = mOutputDevice->GetNominalSampleRate(); + LOG->Warn("Device's nominal sample rate is %f", nominalSampleRate); } AudioStreamID sID = mOutputDevice->GetStreamByIndex( kAudioDeviceSectionOutput, 0 ); CAAudioHardwareStream stream( sID ); @@ -88,15 +92,25 @@ CString RageSound_CA::Init() LOG->Warn("Could not install the overload listener."); } - const Desc CanonicalFormat(44100.0, kAudioFormatLinearPCM, 8, 1, 8, 2, 32, - kAudioFormatFlagsNativeFloatPacked); + // The canonical format + // XXX should this be nominalSampleRate or not? + Desc IOProcFormat(nominalSampleRate, kAudioFormatLinearPCM, 8, 1, 8, 2, 32, + kAudioFormatFlagsNativeFloatPacked); const Desc SMFormat(44100.0, kAudioFormatLinearPCM, kBytesPerPacket, kFramesPerPacket, kBytesPerFrame, kChannelsPerFrame, kBitsPerChannel, kFormatFlags); - stream.SetCurrentIOProcFormat(CanonicalFormat); + try + { + stream.SetCurrentIOProcFormat(IOProcFormat); + } + catch (const CAException& e) + { + LOG->Warn("Could not set the IOProc format to the canonical format."); + stream.GetCurrentIOProcFormat(IOProcFormat); + } - if (AudioConverterNew(&SMFormat, &CanonicalFormat, &mConverter)) + if (AudioConverterNew(&SMFormat, &IOProcFormat, &mConverter)) return "Couldn't create the audio converter"; try