From 020e8018bb1e5d787937e043ff9d5670ee7b004e Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Tue, 26 Sep 2017 12:36:53 +0200 Subject: 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 --- src/multimedia/audio/qsoundeffect_pulse_p.cpp | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/multimedia/audio') 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; -- cgit v1.2.1