next try to fix the Mac audio interface issue
This commit is contained in:
parent
e4752f4d96
commit
9f7877af88
2 changed files with 46 additions and 27 deletions
|
@ -255,12 +255,23 @@ void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID,
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSound::CountChannels ( AudioDeviceID devID,
|
int CSound::CountChannels ( AudioDeviceID devID,
|
||||||
|
const int iNumChanPerFrame,
|
||||||
bool isInput )
|
bool isInput )
|
||||||
{
|
{
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
UInt32 propSize;
|
UInt32 propSize;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
|
// check for the case the we have interleaved format, in that case we assume
|
||||||
|
// that only the very first buffer contains all our channels
|
||||||
|
if ( iNumChanPerFrame > 1 )
|
||||||
|
{
|
||||||
|
result = iNumChanPerFrame;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// it seems we have multiple buffers where each buffer has only one channel,
|
||||||
|
// in that case we assume that each input channel has its own buffer
|
||||||
AudioObjectPropertyScope theScope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
AudioObjectPropertyScope theScope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
||||||
|
|
||||||
AudioObjectPropertyAddress theAddress = { kAudioDevicePropertyStreamConfiguration,
|
AudioObjectPropertyAddress theAddress = { kAudioDevicePropertyStreamConfiguration,
|
||||||
|
@ -284,6 +295,7 @@ int CSound::CountChannels ( AudioDeviceID devID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free ( buflist );
|
free ( buflist );
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -449,6 +461,9 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx )
|
||||||
"not compatible with this software." );
|
"not compatible with this software." );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// store the input number of channels per frame for this stream
|
||||||
|
const int iNumInChanPerFrame = CurDevStreamFormat.mChannelsPerFrame;
|
||||||
|
|
||||||
// check the output
|
// check the output
|
||||||
AudioObjectGetPropertyData ( outputStreamID,
|
AudioObjectGetPropertyData ( outputStreamID,
|
||||||
&stPropertyAddress,
|
&stPropertyAddress,
|
||||||
|
@ -467,9 +482,12 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx )
|
||||||
"not compatible with this software." );
|
"not compatible with this software." );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// store the output number of channels per frame for this stream
|
||||||
|
const int iNumOutChanPerFrame = CurDevStreamFormat.mChannelsPerFrame;
|
||||||
|
|
||||||
// store the input and out number of channels for this device
|
// store the input and out number of channels for this device
|
||||||
iNumInChan = CountChannels ( audioInputDevice[iDriverIdx], true );
|
iNumInChan = CountChannels ( audioInputDevice[iDriverIdx], iNumInChanPerFrame, true );
|
||||||
iNumOutChan = CountChannels ( audioOutputDevice[iDriverIdx], false );
|
iNumOutChan = CountChannels ( audioOutputDevice[iDriverIdx], iNumOutChanPerFrame, false );
|
||||||
|
|
||||||
// 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 )
|
||||||
|
@ -813,7 +831,7 @@ OSStatus CSound::callbackIO ( AudioDeviceID inDevice,
|
||||||
const int iSelOutputLeftChannel = pSound->iSelOutputLeftChannel;
|
const int iSelOutputLeftChannel = pSound->iSelOutputLeftChannel;
|
||||||
const int iSelOutputRightChannel = pSound->iSelOutputRightChannel;
|
const int iSelOutputRightChannel = pSound->iSelOutputRightChannel;
|
||||||
|
|
||||||
if ( inDevice == pSound->CurrentAudioInputDeviceID )
|
if ( ( inDevice == pSound->CurrentAudioInputDeviceID ) && inInputData )
|
||||||
{
|
{
|
||||||
// check size (float32 has four bytes)
|
// check size (float32 has four bytes)
|
||||||
if ( inInputData->mBuffers[0].mDataByteSize ==
|
if ( inInputData->mBuffers[0].mDataByteSize ==
|
||||||
|
@ -879,7 +897,7 @@ if ( iNumInChan == 4 )
|
||||||
pSound->ProcessCallback ( pSound->vecsTmpAudioSndCrdStereo );
|
pSound->ProcessCallback ( pSound->vecsTmpAudioSndCrdStereo );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( inDevice == pSound->CurrentAudioOutputDeviceID )
|
if ( ( inDevice == pSound->CurrentAudioOutputDeviceID ) && outOutputData )
|
||||||
{
|
{
|
||||||
// check size (float32 has four bytes)
|
// check size (float32 has four bytes)
|
||||||
if ( outOutputData->mBuffers[0].mDataByteSize ==
|
if ( outOutputData->mBuffers[0].mDataByteSize ==
|
||||||
|
|
|
@ -78,7 +78,8 @@ protected:
|
||||||
virtual QString LoadAndInitializeDriver ( int iIdx );
|
virtual QString LoadAndInitializeDriver ( int iIdx );
|
||||||
|
|
||||||
QString CheckDeviceCapabilities ( const int iDriverIdx );
|
QString CheckDeviceCapabilities ( const int iDriverIdx );
|
||||||
OSStatus CountChannels ( AudioDeviceID devID,
|
int CountChannels ( AudioDeviceID devID,
|
||||||
|
const int iNumChanPerFrame,
|
||||||
bool isInput );
|
bool isInput );
|
||||||
|
|
||||||
UInt32 SetBufferSize ( AudioDeviceID& audioDeviceID,
|
UInt32 SetBufferSize ( AudioDeviceID& audioDeviceID,
|
||||||
|
|
Loading…
Reference in a new issue