Check more carefully if an exact rate and format match should be searched for. If it fails, instead of failing completely, look for the best format at the same rate.

This commit is contained in:
Mike Brady
2026-08-02 09:36:20 +01:00
parent 63ad9f7e94
commit 4c4f18d285
+14 -5
View File
@@ -959,21 +959,30 @@ int32_t search_for_suitable_configuration(unsigned int channels, unsigned int ra
local_rate = rate; // begin with the requested rate local_rate = rate; // begin with the requested rate
debug(3, "check for an exact multiple of %u with %u channels.", rate, local_channels); debug(3, "check for an exact multiple of %u with %u channels.", rate, local_channels);
while ((local_rate <= 384000) && (local_format == SPS_FORMAT_UNKNOWN)) { while ((local_rate <= 384000) && (local_format == SPS_FORMAT_UNKNOWN)) {
// first, if we in a circumstance where no further audio processing,
// e.g. volume adjustment or convolution is required, check_
// for an exact rate and bit depth match with the same or more channels
if ( if (
// clang-format off // clang-format off
// check for the exact format only under these conditions, otherwise look for the best // check for the exact format only under these conditions, otherwise look for the best
(config.ignore_volume_control != 0) && (config.ignore_volume_control != 0) &&
(config.volume_max_db_set == 0) && (config.volume_max_db_set == 0) &&
#ifdef CONFIG_CONVOLUTION
(config.convolution_enabled == 0) &&
#endif
(config.loudness_enabled == 0) &&
(local_rate == rate) && (local_rate == rate) &&
(local_channels >= channels) && (local_channels >= channels) &&
(config.playback_mode != ST_mono) (config.playback_mode != ST_mono)
// clang-format on // clang-format on
) { ) {
// debug(1, "check exact"); // debug(1, "first, check exact rate and format");
local_format = check_configuration_with_formats( local_format = check_configuration_with_formats(
local_channels, local_rate, (sps_format_t)format, check_configuration); local_channels, local_rate, (sps_format_t)format, check_configuration);
} else { }
// debug(1, "check best");
if (local_format == SPS_FORMAT_UNKNOWN) {
// debug(1, "check best, with any format");
local_format = check_configuration_with_formats(local_channels, local_rate, local_format = check_configuration_with_formats(local_channels, local_rate,
SPS_FORMAT_S32, check_configuration); SPS_FORMAT_S32, check_configuration);
} }