summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorJøger Hansegård <joger.hansegard@qt.io>2024-02-28 13:36:27 +0100
committerJøger Hansegård <joger.hansegard@qt.io>2024-02-28 17:46:29 +0100
commit05f5c32cb176f263fdc1c07a9fc0790a453daf23 (patch)
tree10ceabfc38263ca09b93281b69e6b83431236383 /src/multimedia
parentfac12d3c236c7f5e146c0eaad34d6238da3d1fbf (diff)
Play entire sound with resampled data in QSoundEffect
If FFmpeg resampler is used to convert an audio signal from mono to stereo in QSoundEffect, the number of bytes of data doubles. This patch makes sure that the byte count of the resampled buffer is used instead of the number of bytes in the raw sample buffer. Before this patch, QSoundEffect could only play the first half of a WAV file if the file contained mono signals. This change makes sense for both the QSoundEffectPrivate size() and bytesAvailable() functions because QSoundEffectPrivate can only read data from the resampled audio buffer, never from the raw sample buffer. Amends: f0016c4763361292c3eaf153e184b9b110f44c61 Fixes: QTBUG-122750 Pick-to: 6.7 6.6 6.5 Change-Id: Icbfa6f5c4b5f85d02dca875e76f01a046ce49143 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/audio/qsoundeffect.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/multimedia/audio/qsoundeffect.cpp b/src/multimedia/audio/qsoundeffect.cpp
index c793cf36b..fbd0eecfa 100644
--- a/src/multimedia/audio/qsoundeffect.cpp
+++ b/src/multimedia/audio/qsoundeffect.cpp
@@ -51,13 +51,14 @@ public:
qint64 size() const override {
if (m_sample->state() != QSample::Ready)
return 0;
- return m_loopCount == QSoundEffect::Infinite ? 0 : m_loopCount * m_sample->data().size();
+ return m_loopCount == QSoundEffect::Infinite ? 0 : m_loopCount * m_audioBuffer.byteCount();
}
qint64 bytesAvailable() const override {
if (m_sample->state() != QSample::Ready)
return 0;
- return m_loopCount == QSoundEffect::Infinite
- ? std::numeric_limits<qint64>::max() : m_runningCount * m_sample->data().size() - m_offset;
+ if (m_loopCount == QSoundEffect::Infinite)
+ return std::numeric_limits<qint64>::max();
+ return m_runningCount * m_audioBuffer.byteCount() - m_offset;
}
bool isSequential() const override {
return m_loopCount == QSoundEffect::Infinite;