go back to original version with recent Mac audio interface changes

This commit is contained in:
Volker Fischer 2020-04-14 19:30:15 +02:00
parent 33f6cb300c
commit 802e688443
2 changed files with 11 additions and 29 deletions

View File

@ -254,14 +254,12 @@ void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID,
} }
} }
bool CSound::CountChannels ( AudioDeviceID devID, int CSound::CountChannels ( AudioDeviceID devID,
bool isInput, bool isInput )
int& iNumChannels )
{ {
OSStatus err; OSStatus err;
bool bIsError = true;
UInt32 propSize; UInt32 propSize;
iNumChannels = 0; int result = 0;
AudioObjectPropertyScope theScope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; 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 // 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. // and the interleaved flag. For non interleaved formats, mNumberChannels is always 1.
// For interleaved formats, mNumberChannels is equal to mChannelsPerFrame. // For interleaved formats, mNumberChannels is equal to mChannelsPerFrame.
iNumChannels += buflist->mBuffers[i].mNumberChannels; result += buflist->mBuffers[i].mNumberChannels;
} }
bIsError = false;
} }
free ( buflist ); free ( buflist );
return bIsError; return result;
} }
QString CSound::LoadAndInitializeDriver ( int iDriverIdx ) QString CSound::LoadAndInitializeDriver ( int iDriverIdx )
@ -453,9 +449,6 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx )
"not compatible with this software." ); "not compatible with this software." );
} }
// store the input number of channels for this stream
const int iNumInChanPerFrame = CurDevStreamFormat.mChannelsPerFrame;
// check the output // check the output
AudioObjectGetPropertyData ( outputStreamID, AudioObjectGetPropertyData ( outputStreamID,
&stPropertyAddress, &stPropertyAddress,
@ -474,19 +467,9 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx )
"not compatible with this software." ); "not compatible with this software." );
} }
// store the output number of channels for this stream // store the input and out number of channels for this device
const int iNumOutChanPerFrame = CurDevStreamFormat.mChannelsPerFrame; iNumInChan = CountChannels ( audioInputDevice[iDriverIdx], true );
iNumOutChan = CountChannels ( audioOutputDevice[iDriverIdx], false );
// 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;
}
// clip the number of input/output channels to our allowed maximum // clip the number of input/output channels to our allowed maximum
if ( iNumInChan > MAX_NUM_IN_OUT_CHANNELS ) if ( iNumInChan > MAX_NUM_IN_OUT_CHANNELS )
@ -728,7 +711,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize )
} }
// store buffer size // store buffer size
iCoreAudioBufferSizeMono = iActualMonoBufferSize; iCoreAudioBufferSizeMono = iActualMonoBufferSize;
// init base class // init base class
CSoundBase::Init ( iCoreAudioBufferSizeMono ); CSoundBase::Init ( iCoreAudioBufferSizeMono );

View File

@ -78,9 +78,8 @@ protected:
virtual QString LoadAndInitializeDriver ( int iIdx ); virtual QString LoadAndInitializeDriver ( int iIdx );
QString CheckDeviceCapabilities ( const int iDriverIdx ); QString CheckDeviceCapabilities ( const int iDriverIdx );
bool CountChannels ( AudioDeviceID devID, OSStatus CountChannels ( AudioDeviceID devID,
bool isInput, bool isInput );
int& iNumChannels );
UInt32 SetBufferSize ( AudioDeviceID& audioDeviceID, UInt32 SetBufferSize ( AudioDeviceID& audioDeviceID,
const bool bIsInput, const bool bIsInput,