context: upsample small rates up to the default rate

When the samplerate is smaller than half of the default, try to find a
rate less than the default to upsample to.

pavucontrol now asks for a 1/144 rate, which resulted in a graph rate of
88200 before this change.

See #3320
This commit is contained in:
Wim Taymans 2023-07-05 12:41:36 +02:00
parent bec73f26a7
commit 178f452127

View file

@ -1155,12 +1155,14 @@ static uint32_t find_best_rate(const uint32_t *rates, uint32_t n_rates, uint32_t
* 8000 and [ 44100 192000 ] -> 44100 * 8000 and [ 44100 192000 ] -> 44100
* 11025 and [ 44100 48000 ] -> 44100 * 11025 and [ 44100 48000 ] -> 44100
* 44100 and [ 48000 176400 ] -> 48000 * 44100 and [ 48000 176400 ] -> 48000
* 144 and [ 44100 48000 88200 96000] -> 48000
*/ */
spa_zero(best); spa_zero(best);
/* Don't try to do excessive upsampling by limiting the max rate /* Don't try to do excessive upsampling by limiting the max rate
* for desired < default to default*2. For other rates allow * for desired < default to default*2. For other rates allow
* a x3 upsample rate max */ * a x3 upsample rate max. For values lower than half of the default,
limit = rate < def ? def*2 : rate*3; * limit to the default. */
limit = rate < def/2 ? def : rate < def ? def*2 : rate*3;
for (i = 0; i < n_rates; i++) { for (i = 0; i < n_rates; i++) {
if (info[i].rate >= rate && info[i].rate <= limit) if (info[i].rate >= rate && info[i].rate <= limit)
update_nearest_gcd(&best, &info[i]); update_nearest_gcd(&best, &info[i]);