mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 19:10:38 +02:00
Add support for more back-end sample rates
This commit is contained in:
parent
9187b4aa7d
commit
cb5bded7c1
1 changed files with 13 additions and 11 deletions
|
@ -365,24 +365,26 @@ bool adjustedFormatForAudioDevice(const QAudioDeviceInfo& audioDevice,
|
||||||
const QAudioFormat& desiredAudioFormat,
|
const QAudioFormat& desiredAudioFormat,
|
||||||
QAudioFormat& adjustedAudioFormat) {
|
QAudioFormat& adjustedAudioFormat) {
|
||||||
|
|
||||||
// FIXME: directly using 24khz has a bug somewhere that causes channels to be swapped.
|
|
||||||
// Continue using our internal resampler, for now.
|
|
||||||
qCDebug(audioclient) << "The desired format for audio I/O is" << desiredAudioFormat;
|
qCDebug(audioclient) << "The desired format for audio I/O is" << desiredAudioFormat;
|
||||||
|
|
||||||
const int FORTY_FOUR = 44100;
|
|
||||||
const int FORTY_EIGHT = 48000;
|
|
||||||
adjustedAudioFormat = desiredAudioFormat;
|
adjustedAudioFormat = desiredAudioFormat;
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
adjustedAudioFormat.setSampleRate(FORTY_FOUR);
|
adjustedAudioFormat.setSampleRate(44100);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
if (audioDevice.supportedSampleRates().contains(FORTY_EIGHT)) {
|
//
|
||||||
// use 48000, which is a simple downsample, upsample
|
// Attempt to set the device sample rate in decreasing order of preference.
|
||||||
adjustedAudioFormat.setSampleRate(FORTY_EIGHT);
|
// On Windows, using WASAPI shared mode, only a match with the hardware sample rate will succeed.
|
||||||
} else if (audioDevice.supportedSampleRates().contains(FORTY_FOUR)) {
|
//
|
||||||
// use 44100, resample
|
if (audioDevice.supportedSampleRates().contains(48000)) {
|
||||||
adjustedAudioFormat.setSampleRate(FORTY_FOUR);
|
adjustedAudioFormat.setSampleRate(48000);
|
||||||
|
} else if (audioDevice.supportedSampleRates().contains(44100)) {
|
||||||
|
adjustedAudioFormat.setSampleRate(44100);
|
||||||
|
} else if (audioDevice.supportedSampleRates().contains(32000)) {
|
||||||
|
adjustedAudioFormat.setSampleRate(32000);
|
||||||
|
} else if (audioDevice.supportedSampleRates().contains(24000)) {
|
||||||
|
adjustedAudioFormat.setSampleRate(24000);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue