diff options
Diffstat (limited to 'firmware/pcm.c')
-rw-r--r-- | firmware/pcm.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/firmware/pcm.c b/firmware/pcm.c index 8080823077..72fe23cb16 100644 --- a/firmware/pcm.c +++ b/firmware/pcm.c @@ -361,8 +361,24 @@ void pcm_set_frequency(unsigned int samplerate) { logf("pcm_set_frequency"); - int index = round_value_to_list32(samplerate, hw_freq_sampr, - HW_NUM_FREQ, false); + int index; + +#ifdef CONFIG_SAMPR_TYPES + unsigned int type = samplerate & SAMPR_TYPE_MASK; + samplerate &= ~SAMPR_TYPE_MASK; + +#ifdef SAMPR_TYPE_REC + /* For now, supported targets have direct conversion when configured with + * CONFIG_SAMPR_TYPES. + * Some hypothetical target with independent rates would need slightly + * different handling throughout this source. */ + if (type == SAMPR_TYPE_REC) + samplerate = pcm_sampr_type_rec_to_play(samplerate); +#endif +#endif /* CONFIG_SAMPR_TYPES */ + + index = round_value_to_list32(samplerate, hw_freq_sampr, + HW_NUM_FREQ, false); if (samplerate != hw_freq_sampr[index]) index = HW_FREQ_DEFAULT; /* Invalid = default */ |