summaryrefslogtreecommitdiff
path: root/src/multimedia/audio
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2017-09-26 12:36:53 +0200
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2017-09-26 15:12:57 +0000
commit020e8018bb1e5d787937e043ff9d5670ee7b004e (patch)
tree83156d3d60d1adbf2377cd3163a492c64d605219 /src/multimedia/audio
parent2972eaa1330f377a7c3b1f583a643dbfbfc9531e (diff)
downloadqtmultimedia-020e8018bb1e5d787937e043ff9d5670ee7b004e.tar.gz
PulseAudio: Support 24 bit frames
Applied 24 bits frames support and also stronger restrictions for supported formats: https://freedesktop.org/software/pulseaudio/doxygen/sample.html Task-number: QTBUG-63427 Change-Id: If5372217cbf16c1152db55748adcfbd61263403d Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src/multimedia/audio')
-rw-r--r--src/multimedia/audio/qsoundeffect_pulse_p.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
index 5dbc1a0c9..bf647ea1f 100644
--- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp
+++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
@@ -73,20 +73,23 @@ inline pa_sample_spec audioFormatToSampleSpec(const QAudioFormat &format)
spec.rate = format.sampleRate();
spec.channels = format.channelCount();
-
- if (format.sampleSize() == 8)
- spec.format = PA_SAMPLE_U8;
- else if (format.sampleSize() == 16) {
- switch (format.byteOrder()) {
- case QAudioFormat::BigEndian: spec.format = PA_SAMPLE_S16BE; break;
- case QAudioFormat::LittleEndian: spec.format = PA_SAMPLE_S16LE; break;
- }
- }
- else if (format.sampleSize() == 32) {
- switch (format.byteOrder()) {
- case QAudioFormat::BigEndian: spec.format = PA_SAMPLE_S32BE; break;
- case QAudioFormat::LittleEndian: spec.format = PA_SAMPLE_S32LE; break;
+ spec.format = PA_SAMPLE_INVALID;
+ const bool isBigEndian = (format.byteOrder() == QAudioFormat::BigEndian);
+
+ if (format.sampleType() == QAudioFormat::UnSignedInt) {
+ if (format.sampleSize() == 8)
+ spec.format = PA_SAMPLE_U8;
+ } else if (format.sampleType() == QAudioFormat::SignedInt) {
+ if (format.sampleSize() == 16) {
+ spec.format = isBigEndian ? PA_SAMPLE_S16BE : PA_SAMPLE_S16LE;
+ } else if (format.sampleSize() == 24) {
+ spec.format = isBigEndian ? PA_SAMPLE_S24BE : PA_SAMPLE_S24LE;
+ } else if (format.sampleSize() == 32) {
+ spec.format = isBigEndian ? PA_SAMPLE_S32BE : PA_SAMPLE_S32LE;
}
+ } else if (format.sampleType() == QAudioFormat::Float) {
+ if (format.sampleSize() == 32)
+ spec.format = isBigEndian ? PA_SAMPLE_FLOAT32BE : PA_SAMPLE_FLOAT32LE;
}
return spec;