summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio
diff options
context:
space:
mode:
authorJøger Hansegård <joger.hansegard@qt.io>2024-03-03 00:07:55 +0100
committerJøger Hansegård <joger.hansegard@qt.io>2024-03-08 17:56:42 +0100
commit32f6952b03ba0e550db3e9dc358c366bf52c54a9 (patch)
tree168a58c5d578ac4d5ff42d6e5a7796a657aed6de /src/multimedia/audio
parent024bafe4a13a44b172304d2ba71c35596d03997b (diff)
Simplify lifetime management of QPlatformAudioResampler
QPlatformMediaIntegration creates various objects, and return them as QMaybe<Type*>. This moves responsibility of ownership to the caller. This patch makes the createAudioResampler function return the resampler as QMaybe<std::unique_ptr<Type>> which simplifies lifetime management. This introduces an asymmetry with other factory functions, but this is a step in the right direction Pick-to: 6.7 6.6 6.5 Change-Id: Id2f67597c8d8271b184321d138e126edff5f3202 Reviewed-by: Tim Blechmann <tim@klingt.org> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Lars Sutterud <lars.sutterud@qt.io> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Diffstat (limited to 'src/multimedia/audio')
-rw-r--r--src/multimedia/audio/qsoundeffect.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/multimedia/audio/qsoundeffect.cpp b/src/multimedia/audio/qsoundeffect.cpp
index fbd0eecfa..935777cc6 100644
--- a/src/multimedia/audio/qsoundeffect.cpp
+++ b/src/multimedia/audio/qsoundeffect.cpp
@@ -127,14 +127,14 @@ void QSoundEffectPrivate::sampleReady()
<< audioDevice.channelConfiguration();
auto outputFormat = sampleFormat;
outputFormat.setChannelConfig(audioDevice.channelConfiguration());
- if (auto maybeResampler = QPlatformMediaIntegration::instance()->createAudioResampler(
- m_sample->format(), outputFormat)) {
- std::unique_ptr<QPlatformAudioResampler> resampler(maybeResampler.value());
- m_audioBuffer =
- resampler->resample(m_sample->data().constData(), m_sample->data().size());
- } else {
+
+ const auto resampler = QPlatformMediaIntegration::instance()->createAudioResampler(
+ m_sample->format(), outputFormat);
+ if (resampler)
+ m_audioBuffer = resampler.value()->resample(m_sample->data().constData(),
+ m_sample->data().size());
+ else
qCDebug(qLcSoundEffect) << "Cannot create resampler for channels mapping";
- }
}
if (!m_audioBuffer.isValid())