CoreAudio: fix supported channel count.
We were using the number of channels actually used by audio devices as the maximum channel count. This is wrong as CoreAudio can automatically split or merge channels in order to accommodate the device. We now assume all channel configurations are valid. Task-number: QTBUG-37956 Change-Id: Ia8e8bbea8543caa7fecda305be74a2953b92fd25 Reviewed-by: Andy Nichols <andy.nichols@digia.com>
This commit is contained in:
committed by
The Qt Project
parent
b6970e2e79
commit
d2b54b360e
@@ -196,38 +196,14 @@ QList<int> CoreAudioDeviceInfo::supportedSampleRates()
|
||||
|
||||
QList<int> CoreAudioDeviceInfo::supportedChannelCounts()
|
||||
{
|
||||
QList<int> supportedChannels;
|
||||
int maxChannels = 0;
|
||||
static QList<int> supportedChannels;
|
||||
|
||||
#if defined(Q_OS_OSX)
|
||||
UInt32 propSize = 0;
|
||||
AudioObjectPropertyScope scope = m_mode == QAudio::AudioInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
||||
AudioObjectPropertyAddress streamConfigurationPropertyAddress = { kAudioDevicePropertyStreamConfiguration,
|
||||
scope,
|
||||
kAudioObjectPropertyElementMaster };
|
||||
|
||||
if (AudioObjectGetPropertyDataSize(m_deviceId, &streamConfigurationPropertyAddress, 0, NULL, &propSize) == noErr) {
|
||||
AudioBufferList* audioBufferList = static_cast<AudioBufferList*>(malloc(propSize));
|
||||
|
||||
if (audioBufferList != 0) {
|
||||
if (AudioObjectGetPropertyData(m_deviceId, &streamConfigurationPropertyAddress, 0, NULL, &propSize, audioBufferList) == noErr) {
|
||||
for (int i = 0; i < int(audioBufferList->mNumberBuffers); ++i)
|
||||
maxChannels += audioBufferList->mBuffers[i].mNumberChannels;
|
||||
}
|
||||
|
||||
free(audioBufferList);
|
||||
}
|
||||
if (supportedChannels.isEmpty()) {
|
||||
// If the number of channels is not supported by an audio device, Core Audio will
|
||||
// automatically convert the audio data.
|
||||
for (int i = 1; i <= 16; ++i)
|
||||
supportedChannels.append(i);
|
||||
}
|
||||
#else //iOS
|
||||
if (m_mode == QAudio::AudioInput)
|
||||
maxChannels = CoreAudioSessionManager::instance().inputChannelCount();
|
||||
else if (m_mode == QAudio::AudioOutput)
|
||||
maxChannels = CoreAudioSessionManager::instance().outputChannelCount();
|
||||
#endif
|
||||
|
||||
// Assume all channel configurations are supported up to the maximum number of channels
|
||||
for (int i = 1; i <= maxChannels; ++i)
|
||||
supportedChannels.append(i);
|
||||
|
||||
return supportedChannels;
|
||||
}
|
||||
|
||||
@@ -92,9 +92,6 @@ public:
|
||||
QList<QByteArray> inputDevices();
|
||||
QList<QByteArray> outputDevices();
|
||||
|
||||
int inputChannelCount();
|
||||
int outputChannelCount();
|
||||
|
||||
float currentIOBufferDuration();
|
||||
float preferredSampleRate();
|
||||
|
||||
|
||||
@@ -377,16 +377,6 @@ QList<QByteArray> CoreAudioSessionManager::outputDevices()
|
||||
return outputDevices;
|
||||
}
|
||||
|
||||
int CoreAudioSessionManager::inputChannelCount()
|
||||
{
|
||||
return [[m_sessionObserver audioSession] inputNumberOfChannels];
|
||||
}
|
||||
|
||||
int CoreAudioSessionManager::outputChannelCount()
|
||||
{
|
||||
return [[m_sessionObserver audioSession] outputNumberOfChannels];
|
||||
}
|
||||
|
||||
float CoreAudioSessionManager::currentIOBufferDuration()
|
||||
{
|
||||
return [[m_sessionObserver audioSession] IOBufferDuration];
|
||||
|
||||
Reference in New Issue
Block a user