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.

plugins: test_sampr: remove hw_freq_sampr usage

Change-Id: Iaf9f7f495364fd87db8e25f4ce147540b370f82b

authored by

mojyack and committed by
Solomon Peachy
f81126bc 086c2926

+22 -21
+22 -21
apps/plugins/test_sampr.c
··· 29 29 */ 30 30 31 31 32 - static int hw_freq IDATA_ATTR = HW_FREQ_DEFAULT; 33 - static unsigned long hw_sampr IDATA_ATTR = HW_SAMPR_DEFAULT; 32 + static int hw_freq IDATA_ATTR; 33 + static unsigned long hw_sampr IDATA_ATTR; 34 34 35 35 static int gen_thread_stack[DEFAULT_STACK_SIZE/sizeof(int)] IBSS_ATTR; 36 36 static bool gen_quit IBSS_ATTR; ··· 161 161 /* Called to switch samplerate on the fly */ 162 162 static void set_frequency(int index) 163 163 { 164 + /* FIXME: pcm sink may have been switched */ 165 + const struct pcm_sink_caps* caps = rb->pcm_current_sink_caps(); 166 + 164 167 hw_freq = index; 165 - hw_sampr = rb->hw_freq_sampr[index]; 168 + hw_sampr = caps->samprs[index]; 166 169 167 170 output_clear(); 168 171 update_gen_step(); ··· 188 191 189 192 static void play_tone(bool volume_set) 190 193 { 191 - static struct opt_items names[HW_NUM_FREQ] = 194 + /* generate frequency list */ 195 + static struct opt_items names[SAMPR_NUM_FREQ]; 196 + static char label_storage[SAMPR_NUM_FREQ][8 + 1]; /* at most 8 bytes: "???.?kHz" */ 197 + 198 + const struct pcm_sink_caps* caps = rb->pcm_current_sink_caps(); 199 + for(size_t i = 0; i < caps->num_samprs; i += 1) 192 200 { 193 - HW_HAVE_192_([HW_FREQ_192] = { "192kHz", -1 },) 194 - HW_HAVE_176_([HW_FREQ_176] = { "176.4kHz", -1 },) 195 - HW_HAVE_96_([HW_FREQ_96] = { "96kHz", -1 },) 196 - HW_HAVE_88_([HW_FREQ_88] = { "88.2kHz", -1 },) 197 - HW_HAVE_64_([HW_FREQ_64] = { "64kHz", -1 },) 198 - HW_HAVE_48_([HW_FREQ_48] = { "48kHz", -1 },) 199 - HW_HAVE_44_([HW_FREQ_44] = { "44.1kHz", -1 },) 200 - HW_HAVE_32_([HW_FREQ_32] = { "32kHz", -1 },) 201 - HW_HAVE_24_([HW_FREQ_24] = { "24kHz", -1 },) 202 - HW_HAVE_22_([HW_FREQ_22] = { "22.05kHz", -1 },) 203 - HW_HAVE_16_([HW_FREQ_16] = { "16kHz", -1 },) 204 - HW_HAVE_12_([HW_FREQ_12] = { "12kHz", -1 },) 205 - HW_HAVE_11_([HW_FREQ_11] = { "11.025kHz", -1 },) 206 - HW_HAVE_8_( [HW_FREQ_8 ] = { "8kHz", -1 },) 207 - }; 201 + uint16_t val = caps->samprs[i] / 100; 202 + rb->snprintf(label_storage[i], 8 + 1, "%d.%dkHz", val / 10, val % 10); 203 + names[i].string = label_storage[i]; 204 + names[i].voice_id = -1; 205 + } 206 + 207 + hw_freq = caps->default_freq; 208 + hw_sampr = caps->samprs[hw_freq]; 208 209 209 210 int freq = hw_freq; 210 211 ··· 219 220 rb->cpu_boost(true); 220 221 #endif 221 222 222 - rb->mixer_set_frequency(rb->hw_freq_sampr[freq]); 223 + rb->mixer_set_frequency(hw_sampr); 223 224 224 225 #if INPUT_SRC_CAPS != 0 225 226 /* Recordable targets can play back from other sources */ ··· 251 252 #endif /* HAVE_VOLUME_IN_LIST */ 252 253 { 253 254 rb->set_option("Sample Rate", &freq, RB_INT, names, 254 - HW_NUM_FREQ, set_frequency); 255 + caps->num_samprs, set_frequency); 255 256 (void)volume_set; 256 257 } 257 258