From 1f72db5efcb61bc2e0c4d4bd34029f9ccbf8470a Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Sun, 18 Jun 2006 08:28:18 +0000 Subject: [PATCH] Fix parameter order. --- .../src/arch/Sound/RageSoundDriver_CA.cpp | 55 ++++++++----------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp b/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp index 85a234f62b..69438d6c93 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_CA.cpp @@ -38,9 +38,6 @@ Desc::Desc( Float64 sampleRate, UInt32 formatID, UInt32 formatFlags, UInt32 byte mReserved = 0; } -static OSStatus SampleRateChanged( AudioDeviceID inDevice, UInt32 inChannel, Boolean isInput, - AudioDevicePropertyID inPropertyID, void *inData ); - /* temporary hack: */ static float g_fLastIOProcTime = 0; static const int NUM_MIX_TIMES = 16; @@ -55,7 +52,7 @@ RageSound_CA::RageSound_CA() : m_fLatency(0.0f), m_Converter(NULL), m_bStarted(f static inline RString FourCCToString( uint32_t num ) { - RString s( '?', 4 ); + RString s( 4, '?' ); char c; c = (num >> 24) & 0xFF; @@ -136,6 +133,14 @@ RString RageSound_CA::Init() LOG->Info( "Audio device manufacturer: %s", str ); } + AddListener( kAudioDeviceProcessorOverload, OverloadListener, "overload" ); + AddListener( kAudioDevicePropertyDeviceHasChanged, DeviceChanged, "device changed" ); + AddListener( kAudioDevicePropertyJackIsConnected, JackChanged, "jack changed" ); + AddListener( kAudioDevicePropertyStreamConfiguration, DeviceChanged, "configuration changed" ); + AddListener( kAudioDevicePropertyPreferredChannelsForStereo, DeviceChanged, "preferred channels changed" ); + AddListener( kAudioHardwarePropertyDefaultOutputDevice, DeviceChanged, "default output device changed" ); +// AddListener( kAudioDevicePropertyStreamFormat, FormatChanged, "stream format changed" ); + // Find the stereo channels UInt32 channels[2]; @@ -219,11 +224,6 @@ RString RageSound_CA::Init() } delete[] streams; - AddListener( kAudioDeviceProcessorOverload, OverloadListener, "overload" ); - AddListener( kAudioDevicePropertyDeviceHasChanged, DeviceChanged, "device changed" ); - AddListener( kAudioDevicePropertyJackIsConnected, JackChanged, "jack changed" ); - AddListener( kAudioDevicePropertyActualSampleRate, SampleRateChanged, "sample rate changed" ); - // The canonical format Desc IOProcFormat( actualSampleRate, kAudioFormatLinearPCM, kAudioFormatFlagsNativeFloatPacked, 8, 1, 8, 2, 32 ); const Desc SMFormat( actualSampleRate, kAudioFormatLinearPCM, kFormatFlags, kBytesPerPacket, @@ -329,16 +329,7 @@ RageSound_CA::~RageSound_CA() { AudioDeviceStop( m_OutputDevice, GetData ); AudioDeviceRemoveIOProc( m_OutputDevice, GetData ); - - while( m_vPropertyListeners.size() ) - { - pair& p = m_vPropertyListeners.back(); - - AudioDeviceRemovePropertyListener( m_OutputDevice, kAudioPropertyWildcardChannel, - kAudioDeviceSectionOutput, p.first, p.second ); - - m_vPropertyListeners.pop_back(); - } + RemoveListeners(); delete m_pIOThread; delete m_pNotificationThread; } @@ -365,6 +356,19 @@ void RageSound_CA::AddListener( AudioDevicePropertyID propertyID, AudioDevicePro } } +void RageSound_CA::RemoveListeners() +{ + while( m_vPropertyListeners.size() ) + { + pair& p = m_vPropertyListeners.back(); + + AudioDeviceRemovePropertyListener( m_OutputDevice, kAudioPropertyWildcardChannel, + kAudioDeviceSectionOutput, p.first, p.second ); + + m_vPropertyListeners.pop_back(); + } +} + int64_t RageSound_CA::GetPosition( const RageSoundBase *sound ) const { AudioTimeStamp time; @@ -487,19 +491,6 @@ OSStatus RageSound_CA::JackChanged( AudioDeviceID inDevice, UInt32 inChannel, Bo return noErr; } -OSStatus SampleRateChanged( AudioDeviceID inDevice, UInt32 inChannel, Boolean isInput, - AudioDevicePropertyID inPropertyID, void *inData ) -{ - if( isInput ) - return noErr; - Float64 sampleRate; - UInt32 size = sizeof( sampleRate ); - - AudioDeviceGetProperty( inDevice, inChannel, 0, inPropertyID, &size, &sampleRate ); - LOG->Warn( "Sample rate changed to %f.", sampleRate ); - return noErr; -} - void RageSound_CA::SetupDecodingThread() {