Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

playback: do not hardcode pcm sink in audio_set_playback_frequency

make audio_set_playback_frequency() can be used for non-builtin pcm
sinks.

Change-Id: I9d1110f28753e912b84515594a1361cd17fa5e74

mojyack 76d63246 ea570c57

+5 -15
+5 -15
apps/playback.c
··· 27 27 #include "panic.h" 28 28 #include "core_alloc.h" 29 29 #include "sound.h" 30 + #include "pcm_sink.h" 30 31 #include "codecs.h" 31 32 #include "codec_thread.h" 32 33 #include "voice_thread.h" ··· 4282 4283 4283 4284 void audio_set_playback_frequency(unsigned int sample_rate_hz) 4284 4285 { 4285 - /* sample_rate_hz == 0 is "automatic", and also a sentinel */ 4286 - #if HAVE_PLAY_FREQ >= 192 4287 - static const unsigned int play_sampr[] = {SAMPR_44, SAMPR_48, SAMPR_88, SAMPR_96, SAMPR_176, SAMPR_192, 0 }; 4288 - #elif HAVE_PLAY_FREQ >= 96 4289 - static const unsigned int play_sampr[] = {SAMPR_44, SAMPR_48, SAMPR_88, SAMPR_96, 0 }; 4290 - #elif HAVE_PLAY_FREQ >= 48 4291 - static const unsigned int play_sampr[] = {SAMPR_44, SAMPR_48, 0 }; 4292 - #else 4293 - #error "HAVE_PLAY_FREQ < 48 ??" 4294 - #endif 4295 - const unsigned int *p_sampr = play_sampr; 4296 4286 unsigned int sampr = 0; 4297 4287 4298 - while (*p_sampr != 0) 4288 + const struct pcm_sink_caps* caps = pcm_sink_caps(pcm_current_sink()); 4289 + for (size_t i = 0; i < caps->num_samprs; i += 1) 4299 4290 { 4300 - if (*p_sampr == sample_rate_hz) 4291 + if (caps->samprs[i] == sample_rate_hz) 4301 4292 { 4302 - sampr = *p_sampr; 4293 + sampr = caps->samprs[i]; 4303 4294 break; 4304 4295 } 4305 - p_sampr++; 4306 4296 } 4307 4297 4308 4298 if (sampr == 0)