diff options
Diffstat (limited to 'firmware/pcm_mixer.c')
-rw-r--r-- | firmware/pcm_mixer.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/firmware/pcm_mixer.c b/firmware/pcm_mixer.c index 34852e97e9..ceba31962e 100644 --- a/firmware/pcm_mixer.c +++ b/firmware/pcm_mixer.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include "pcm.h" | 25 | #include "pcm.h" |
26 | #include "pcm-internal.h" | 26 | #include "pcm-internal.h" |
27 | #include "pcm_mixer.h" | 27 | #include "pcm_mixer.h" |
28 | #include "dsp_core.h" /* For NATIVE_FREQUENCY */ | ||
29 | 28 | ||
30 | /* Channels use standard-style PCM callback interface but a latency of one | 29 | /* Channels use standard-style PCM callback interface but a latency of one |
31 | frame by double-buffering is introduced in order to facilitate mixing and | 30 | frame by double-buffering is introduced in order to facilitate mixing and |
@@ -33,6 +32,8 @@ | |||
33 | before the last samples are sent to the codec and so things are done in | 32 | before the last samples are sent to the codec and so things are done in |
34 | parallel (as much as possible) with sending-out data. */ | 33 | parallel (as much as possible) with sending-out data. */ |
35 | 34 | ||
35 | static unsigned int mixer_sampr = HW_SAMPR_DEFAULT; | ||
36 | |||
36 | /* Define this to nonzero to add a marker pulse at each frame start */ | 37 | /* Define this to nonzero to add a marker pulse at each frame start */ |
37 | #define FRAME_BOUNDARY_MARKERS 0 | 38 | #define FRAME_BOUNDARY_MARKERS 0 |
38 | 39 | ||
@@ -65,7 +66,7 @@ static struct mixer_channel channels[PCM_MIXER_NUM_CHANNELS] IBSS_ATTR; | |||
65 | static struct mixer_channel * active_channels[PCM_MIXER_NUM_CHANNELS+1] IBSS_ATTR; | 66 | static struct mixer_channel * active_channels[PCM_MIXER_NUM_CHANNELS+1] IBSS_ATTR; |
66 | 67 | ||
67 | /* Number of silence frames to play after all data has played */ | 68 | /* Number of silence frames to play after all data has played */ |
68 | #define MAX_IDLE_FRAMES (NATIVE_FREQUENCY*3 / MIX_FRAME_SAMPLES) | 69 | #define MAX_IDLE_FRAMES (mixer_sampr*3 / MIX_FRAME_SAMPLES) |
69 | static unsigned int idle_counter = 0; | 70 | static unsigned int idle_counter = 0; |
70 | 71 | ||
71 | /** Mixing routines, CPU optmized **/ | 72 | /** Mixing routines, CPU optmized **/ |
@@ -256,7 +257,7 @@ static void mixer_start_pcm(void) | |||
256 | #endif | 257 | #endif |
257 | 258 | ||
258 | /* Requires a shared global sample rate for all channels */ | 259 | /* Requires a shared global sample rate for all channels */ |
259 | pcm_set_frequency(NATIVE_FREQUENCY); | 260 | pcm_set_frequency(mixer_sampr); |
260 | 261 | ||
261 | /* Prepare initial frames and set up the double buffer */ | 262 | /* Prepare initial frames and set up the double buffer */ |
262 | mixer_buffer_callback(PCM_DMAST_STARTED); | 263 | mixer_buffer_callback(PCM_DMAST_STARTED); |
@@ -438,3 +439,23 @@ void mixer_reset(void) | |||
438 | 439 | ||
439 | idle_counter = 0; | 440 | idle_counter = 0; |
440 | } | 441 | } |
442 | |||
443 | /* Set output samplerate */ | ||
444 | void mixer_set_frequency(unsigned int samplerate) | ||
445 | { | ||
446 | pcm_set_frequency(samplerate); | ||
447 | samplerate = pcm_get_frequency(); | ||
448 | |||
449 | if (samplerate == mixer_sampr) | ||
450 | return; | ||
451 | |||
452 | /* All data is now invalid */ | ||
453 | mixer_reset(); | ||
454 | mixer_sampr = samplerate; | ||
455 | } | ||
456 | |||
457 | /* Get output samplerate */ | ||
458 | unsigned int mixer_get_frequency(void) | ||
459 | { | ||
460 | return mixer_sampr; | ||
461 | } | ||