diff --git a/audiohandler.cpp b/audiohandler.cpp index d395003..4a51aab 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -126,6 +126,17 @@ bool audioHandler::init(audioSetup setupIn) } } + if (format.sampleType()==QAudioFormat::SignedInt) { + format.setSampleType(QAudioFormat::Float); + format.setSampleSize(32); + if (!setup.port.isFormatSupported(format)) { + qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << "Attempt to select 32bit Float failed, reverting to SignedInt"; + format.setSampleType(QAudioFormat::SignedInt); + format.setSampleSize(16); + } + + } + if (format.sampleSize() == 24) { // We can't convert this easily so use 32 bit instead. format.setSampleSize(32); @@ -134,11 +145,6 @@ bool audioHandler::init(audioSetup setupIn) format.setSampleSize(16); } } - format.setSampleType(QAudioFormat::Float); - if (!setup.port.isFormatSupported(format)) { - qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << "Attempt to select Float failed, reverting to SignedInt"; - format.setSampleType(QAudioFormat::SignedInt); - } qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Selected format: SampleSize" << format.sampleSize() << "Channel Count" << format.channelCount() << "Sample Rate" << format.sampleRate() << "Codec" << format.codec() << "Sample Type" << format.sampleType(); @@ -695,4 +701,4 @@ void audioHandler::stateChanged(QAudio::State state) void audioHandler::clearUnderrun() { isUnderrun = false; -} \ No newline at end of file +}