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.

pcm_mixer: remove mixer_sampr

Change-Id: I693b3c2ab639f09e918790dd6a06977991f872cc

mojyack 498a9fff e2040cc9

+20 -23
+20 -23
firmware/pcm_mixer.c
··· 33 33 before the last samples are sent to the codec and so things are done in 34 34 parallel (as much as possible) with sending-out data. */ 35 35 36 - static unsigned int mixer_sampr = -1U; 37 36 static unsigned int mix_frame_size = MIX_FRAME_SAMPLES*4; 38 37 39 38 /* Define this to nonzero to add a marker pulse at each frame start */ ··· 75 74 static struct mixer_channel * active_channels[PCM_MIXER_NUM_CHANNELS+1] IBSS_ATTR; 76 75 77 76 /* Number of silence frames to play after all data has played */ 78 - #define MAX_IDLE_FRAMES (mixer_sampr*3 / (mix_frame_size / 4)) 79 77 static unsigned int idle_counter = 0; 80 78 79 + #ifdef CONFIG_SAMPR_TYPES 80 + #define SAMPR_NUM(sampr) (sampr & ~SAMPR_TYPE_MASK) 81 + #else 82 + #define SAMPR_NUM(sampr) (sampr) 83 + #endif 84 + 85 + static inline unsigned int max_idle_frames(void) 86 + { 87 + return SAMPR_NUM(pcm_get_frequency()) * 3 / (mix_frame_size / 4); 88 + } 89 + 81 90 /** Mixing routines, CPU optmized **/ 82 91 #include "asm/pcm-mixer.c" 83 92 ··· 233 242 goto fill_frame; 234 243 } 235 244 } 236 - else if (idle_counter++ < MAX_IDLE_FRAMES) 245 + else if (idle_counter++ < max_idle_frames()) 237 246 { 238 247 /* Pad incomplete frames with silence */ 239 248 if (idle_counter <= 3) ··· 265 274 return; 266 275 #endif 267 276 268 - /* Requires a shared global sample rate for all channels */ 269 - if (mixer_sampr == -1U) 270 - mixer_sampr = pcm_get_frequency(); 271 - else 272 - pcm_set_frequency(mixer_sampr); 273 - 274 277 /* Prepare initial frames and set up the double buffer */ 275 278 mixer_buffer_callback(PCM_DMAST_STARTED); 276 279 ··· 454 457 /* Set output samplerate */ 455 458 void mixer_set_frequency(unsigned int samplerate) 456 459 { 457 - pcm_set_frequency(samplerate); 458 - samplerate = pcm_get_frequency(); 460 + if(pcm_get_frequency() == samplerate) 461 + return; 459 462 460 - #ifdef CONFIG_SAMPR_TYPES 461 - samplerate &= ~SAMPR_TYPE_MASK; 462 - #endif 463 - 464 - if (samplerate == mixer_sampr) 465 - return; 466 - mixer_sampr = samplerate; 463 + pcm_set_frequency(samplerate); 467 464 468 465 for (size_t i = 0; i < ARRAYLEN(active_channels) && active_channels[i]; i += 1) 469 466 { ··· 474 471 { 475 472 if (chan->play_cbs->sampr_changed) 476 473 { 477 - chan->play_cbs->sampr_changed(samplerate); 474 + chan->play_cbs->sampr_changed(SAMPR_NUM(samplerate)); 478 475 } 479 476 if (chan->play_cbs->get_more) 480 477 { ··· 496 493 { 497 494 if (chan->buf_cbs->sampr_changed) 498 495 { 499 - chan->buf_cbs->sampr_changed(samplerate); 496 + chan->buf_cbs->sampr_changed(SAMPR_NUM(samplerate)); 500 497 } 501 498 } 502 499 } 503 500 504 501 /* Work out how much space we really need */ 505 - if (samplerate > SAMPR_96) 502 + if (SAMPR_NUM(samplerate) > SAMPR_96) 506 503 mix_frame_size = 4; 507 - else if (samplerate > SAMPR_48) 504 + else if (SAMPR_NUM(samplerate) > SAMPR_48) 508 505 mix_frame_size = 2; 509 506 else 510 507 mix_frame_size = 1; ··· 518 515 /* Get output samplerate */ 519 516 unsigned int mixer_get_frequency(void) 520 517 { 521 - return mixer_sampr; 518 + return pcm_get_frequency(); 522 519 }