summaryrefslogtreecommitdiffstats
path: root/src/multimedia/platform
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2024-01-22 12:28:18 +0100
committerArtem Dyomin <artem.dyomin@qt.io>2024-01-23 10:04:28 +0000
commitf0016c4763361292c3eaf153e184b9b110f44c61 (patch)
treee77001551e3e7308d4917cd34b0e200c92c20f7f /src/multimedia/platform
parentdf061284787515c6ce27bba42912dcb8da882469 (diff)
Implement audio resampling in QSoundEffect
The resampling in QSoundEffect is needed to align the audio playback functionality with QMediaPlayer, otherwise, we get different volume levels when channels configurations of the source file and the audiodevice are different. QMediaPlayer uses ffmpeg resampling, so QSoundEffect is supposed to use it too. FFmpeg implementation is to be added in the following commits. Pick-to: 6.7 6.6 6.5 Task-number: QTBUG-118099 Change-Id: I24d0ca394635d53e8fdd4b09f328725dd4f51027 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Diffstat (limited to 'src/multimedia/platform')
-rw-r--r--src/multimedia/platform/qplatformaudioresampler_p.h33
-rw-r--r--src/multimedia/platform/qplatformmediaintegration_p.h7
2 files changed, 40 insertions, 0 deletions
diff --git a/src/multimedia/platform/qplatformaudioresampler_p.h b/src/multimedia/platform/qplatformaudioresampler_p.h
new file mode 100644
index 000000000..fd8edc2be
--- /dev/null
+++ b/src/multimedia/platform/qplatformaudioresampler_p.h
@@ -0,0 +1,33 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QPLATFORMAUDIORESAMPLER_P_H
+#define QPLATFORMAUDIORESAMPLER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qtmultimediaglobal_p.h>
+#include <qaudiobuffer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformAudioResampler
+{
+public:
+ virtual ~QPlatformAudioResampler() = default;
+
+ virtual QAudioBuffer resample(const char *data, size_t size) = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLATFORMAUDIORESAMPLER_P_H
diff --git a/src/multimedia/platform/qplatformmediaintegration_p.h b/src/multimedia/platform/qplatformmediaintegration_p.h
index cc40627d0..21891b866 100644
--- a/src/multimedia/platform/qplatformmediaintegration_p.h
+++ b/src/multimedia/platform/qplatformmediaintegration_p.h
@@ -37,6 +37,7 @@ class QPlatformMediaDevices;
class QPlatformMediaCaptureSession;
class QPlatformMediaPlayer;
class QPlatformAudioDecoder;
+class QPlatformAudioResampler;
class QPlatformCamera;
class QPlatformSurfaceCapture;
class QPlatformMediaRecorder;
@@ -69,6 +70,12 @@ public:
virtual QPlatformSurfaceCapture *createWindowCapture(QWindowCapture *) { return nullptr; }
virtual QMaybe<QPlatformAudioDecoder *> createAudioDecoder(QAudioDecoder *) { return notAvailable; }
+ virtual QMaybe<QPlatformAudioResampler *>
+ createAudioResampler(const QAudioFormat & /*inputFormat*/,
+ const QAudioFormat & /*outputFormat*/)
+ {
+ return notAvailable;
+ }
virtual QMaybe<QPlatformMediaCaptureSession *> createCaptureSession() { return notAvailable; }
virtual QMaybe<QPlatformMediaPlayer *> createPlayer(QMediaPlayer *) { return notAvailable; }
virtual QMaybe<QPlatformMediaRecorder *> createRecorder(QMediaRecorder *) { return notAvailable; }