fix: Do not guess a possible audio format

This might have some side effects on other parts of swift that needs to
be checked first. We should handle this in a different issue.

Note: This was done in pre-Qt6
This commit is contained in:
Lars Toenning
2026-06-23 20:43:40 +02:00
parent 83c7a287a4
commit 084e78e809

View File

@@ -82,39 +82,7 @@ namespace swift::sound
if (!defDevice.isFormatSupported(format))
{
// Try to find a supported format
QAudioFormat adjustedFormat = defDevice.preferredFormat();
// Try to keep as many original settings as possible
adjustedFormat.setSampleRate(format.sampleRate());
adjustedFormat.setChannelCount(format.channelCount());
adjustedFormat.setSampleFormat(format.sampleFormat());
if (defDevice.isFormatSupported(adjustedFormat))
{
format = adjustedFormat;
return defDevice;
}
// Fallback: Try with preferred format's sample rate but keep other settings
adjustedFormat = defDevice.preferredFormat();
adjustedFormat.setChannelCount(format.channelCount());
adjustedFormat.setSampleFormat(format.sampleFormat());
if (defDevice.isFormatSupported(adjustedFormat))
{
format = adjustedFormat;
return defDevice;
}
// Last resort: Use the device's preferred format entirely
if (defDevice.isFormatSupported(defDevice.preferredFormat()))
{
format = defDevice.preferredFormat();
return defDevice;
}
// Device doesn't support any reasonable format
// Device doesn't support the required format
return {};
}
return defDevice;