diff --git a/mac/sound.cpp b/mac/sound.cpp index 23f6a858..2a683b19 100755 --- a/mac/sound.cpp +++ b/mac/sound.cpp @@ -254,14 +254,12 @@ void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID, } } -bool CSound::CountChannels ( AudioDeviceID devID, - bool isInput, - int& iNumChannels ) +int CSound::CountChannels ( AudioDeviceID devID, + bool isInput ) { OSStatus err; - bool bIsError = true; UInt32 propSize; - iNumChannels = 0; + int result = 0; AudioObjectPropertyScope theScope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; @@ -282,14 +280,12 @@ bool CSound::CountChannels ( AudioDeviceID devID, // The correct value mNumberChannels for an AudioBuffer can be derived from the mChannelsPerFrame // and the interleaved flag. For non interleaved formats, mNumberChannels is always 1. // For interleaved formats, mNumberChannels is equal to mChannelsPerFrame. - iNumChannels += buflist->mBuffers[i].mNumberChannels; + result += buflist->mBuffers[i].mNumberChannels; } - - bIsError = false; } free ( buflist ); - return bIsError; + return result; } QString CSound::LoadAndInitializeDriver ( int iDriverIdx ) @@ -453,9 +449,6 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx ) "not compatible with this software." ); } - // store the input number of channels for this stream - const int iNumInChanPerFrame = CurDevStreamFormat.mChannelsPerFrame; - // check the output AudioObjectGetPropertyData ( outputStreamID, &stPropertyAddress, @@ -474,19 +467,9 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx ) "not compatible with this software." ); } - // store the output number of channels for this stream - const int iNumOutChanPerFrame = CurDevStreamFormat.mChannelsPerFrame; - - // store the input and out number of channels for this device (note that in - // case the CountChannels failed, we use the number of channels per frame instead) - if ( CountChannels ( audioInputDevice[iDriverIdx], true, iNumInChan ) ) - { - iNumInChan = iNumInChanPerFrame; - } - if ( CountChannels ( audioOutputDevice[iDriverIdx], false, iNumOutChan ) ) - { - iNumOutChan = iNumOutChanPerFrame; - } + // store the input and out number of channels for this device + iNumInChan = CountChannels ( audioInputDevice[iDriverIdx], true ); + iNumOutChan = CountChannels ( audioOutputDevice[iDriverIdx], false ); // clip the number of input/output channels to our allowed maximum if ( iNumInChan > MAX_NUM_IN_OUT_CHANNELS ) @@ -728,7 +711,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize ) } // store buffer size - iCoreAudioBufferSizeMono = iActualMonoBufferSize; + iCoreAudioBufferSizeMono = iActualMonoBufferSize; // init base class CSoundBase::Init ( iCoreAudioBufferSizeMono ); diff --git a/mac/sound.h b/mac/sound.h index 3dc33674..ea78bdc0 100755 --- a/mac/sound.h +++ b/mac/sound.h @@ -78,9 +78,8 @@ protected: virtual QString LoadAndInitializeDriver ( int iIdx ); QString CheckDeviceCapabilities ( const int iDriverIdx ); - bool CountChannels ( AudioDeviceID devID, - bool isInput, - int& iNumChannels ); + OSStatus CountChannels ( AudioDeviceID devID, + bool isInput ); UInt32 SetBufferSize ( AudioDeviceID& audioDeviceID, const bool bIsInput,