summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2022-11-01 14:28:17 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-11-03 11:14:36 +0000
commitbe0fb82e46d3b8ada9353b5e54f421aec84dcce0 (patch)
tree8897b681ae957762512a40aae95b6f0bd0e23e26
parent3582462ff943447013e0d271eda39598b6a7c96f (diff)
downloadqtmultimedia-be0fb82e46d3b8ada9353b5e54f421aec84dcce0.tar.gz
Fix redundant warning output on macOS
Redundant warnings were reproduced with specific installed sowtware, e.g. Soundflower. The software is able to create 64 audio channels and customize them. Basically, all the channels have unknown label, so we should filter the warnings. The logic of channels detection is not changed: only a little bit refactored. See dump of audio channels on client's PC: bugreports.qt.io/secure/attachment/132568/dump_audio_res2.txt Task-number: QTBUG-107678 Change-Id: I85b63d39b71aa09b28d47bf5bf7d40d1e8a1328b Reviewed-by: Doris Verria <doris.verria@qt.io> (cherry picked from commit 68ab44b57d23ac4ecbd663233b9c978b17cd0e98) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/multimedia/audio/qaudiodevice_p.h2
-rw-r--r--src/multimedia/darwin/qcoreaudioutils.mm28
2 files changed, 19 insertions, 11 deletions
diff --git a/src/multimedia/audio/qaudiodevice_p.h b/src/multimedia/audio/qaudiodevice_p.h
index ff9d061da..575a9edc5 100644
--- a/src/multimedia/audio/qaudiodevice_p.h
+++ b/src/multimedia/audio/qaudiodevice_p.h
@@ -40,7 +40,7 @@ public:
int minimumChannelCount = 0;
int maximumChannelCount = 0;
QList<QAudioFormat::SampleFormat> supportedSampleFormats;
- QAudioFormat::ChannelConfig channelConfiguration;
+ QAudioFormat::ChannelConfig channelConfiguration = QAudioFormat::ChannelConfigUnknown;
QAudioDevice create() { return QAudioDevice(this); }
};
diff --git a/src/multimedia/darwin/qcoreaudioutils.mm b/src/multimedia/darwin/qcoreaudioutils.mm
index f8095b2b9..369adad24 100644
--- a/src/multimedia/darwin/qcoreaudioutils.mm
+++ b/src/multimedia/darwin/qcoreaudioutils.mm
@@ -232,19 +232,27 @@ QAudioFormat::ChannelConfig CoreAudioUtils::fromAudioChannelLayout(const AudioCh
return QAudioFormat::ChannelConfigStereo;
for (uint i = 0; i < layout->mNumberChannelDescriptions; ++i) {
- bool found = false;
- for (const auto &m : channelMap) {
- if (layout->mChannelDescriptions[i].mChannelLabel == m.label) {
- channels |= QAudioFormat::channelConfig(m.pos);
- found = true;
- break;
- }
+ const auto channelLabel = layout->mChannelDescriptions[i].mChannelLabel;
+ if (channelLabel == kAudioChannelLabel_Unknown) {
+ // Any number of unknown channel labels occurs for loopback audio devices.
+ // E.g. the case is reproduced with installed software Soundflower.
+ continue;
}
- if (!found)
- qWarning() << "audio device has unknown channel" << layout->mChannelDescriptions[i].mChannelLabel;
+
+ const auto found = std::find_if(channelMap, std::end(channelMap),
+ [channelLabel](const auto &labelWithPos) {
+ return labelWithPos.label == channelLabel;
+ });
+
+ if (found == std::end(channelMap))
+ qWarning() << "audio device has unrecognized channel, index:" << i
+ << "label:" << channelLabel;
+ else
+ channels |= QAudioFormat::channelConfig(found->pos);
}
} else {
- qWarning() << "Channel layout uses unimplemented format";
+ qWarning() << "Channel layout uses unimplemented format, channelLayoutTag:"
+ << layout->mChannelLayoutTag;
}
return QAudioFormat::ChannelConfig(channels);
}