diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2011-07-02 11:55:38 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2011-07-02 11:55:38 +0000 |
commit | 22b6def065ab7c2ca030f405577e34104ad20011 (patch) | |
tree | 6be548bf591d2365077b74679048737fe51792a2 /firmware/pcm_mixer.c | |
parent | 8c954e28b75b47543f69abe2c169d83ad38c26ae (diff) | |
download | rockbox-22b6def065ab7c2ca030f405577e34104ad20011.tar.gz rockbox-22b6def065ab7c2ca030f405577e34104ad20011.zip |
Use playback channel directly for peakmeters and plugins using peak calculation. Also, for now, don't allow mixer playback to overlap recording, even if full duplex works.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30119 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/pcm_mixer.c')
-rw-r--r-- | firmware/pcm_mixer.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/firmware/pcm_mixer.c b/firmware/pcm_mixer.c index 69a43cfbda..c84762938e 100644 --- a/firmware/pcm_mixer.c +++ b/firmware/pcm_mixer.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "general.h" | 23 | #include "general.h" |
24 | #include "kernel.h" | 24 | #include "kernel.h" |
25 | #include "pcm.h" | 25 | #include "pcm.h" |
26 | #include "pcm-internal.h" | ||
26 | #include "pcm_mixer.h" | 27 | #include "pcm_mixer.h" |
27 | #include "dsp.h" | 28 | #include "dsp.h" |
28 | 29 | ||
@@ -59,6 +60,9 @@ static size_t next_size = 0; /* Size of buffer to play next time */ | |||
59 | /* Descriptors for all available channels */ | 60 | /* Descriptors for all available channels */ |
60 | static struct mixer_channel channels[PCM_MIXER_NUM_CHANNELS] IBSS_ATTR; | 61 | static struct mixer_channel channels[PCM_MIXER_NUM_CHANNELS] IBSS_ATTR; |
61 | 62 | ||
63 | /* History for channel peaks */ | ||
64 | static struct pcm_peaks channel_peaks[PCM_MIXER_NUM_CHANNELS]; | ||
65 | |||
62 | /* Packed pointer array of all playing (active) channels in "channels" array */ | 66 | /* Packed pointer array of all playing (active) channels in "channels" array */ |
63 | static struct mixer_channel * active_channels[PCM_MIXER_NUM_CHANNELS+1] IBSS_ATTR; | 67 | static struct mixer_channel * active_channels[PCM_MIXER_NUM_CHANNELS+1] IBSS_ATTR; |
64 | 68 | ||
@@ -343,11 +347,14 @@ static void mixer_start_pcm(void) | |||
343 | if (pcm_is_playing()) | 347 | if (pcm_is_playing()) |
344 | return; | 348 | return; |
345 | 349 | ||
346 | #if defined(HAVE_RECORDING) && !defined(HAVE_PCM_FULL_DUPLEX) | 350 | #if defined(HAVE_RECORDING) |
347 | if (pcm_is_recording()) | 351 | if (pcm_is_recording()) |
348 | return; | 352 | return; |
349 | #endif | 353 | #endif |
350 | 354 | ||
355 | /* Requires a shared global sample rate for all channels */ | ||
356 | pcm_set_frequency(NATIVE_FREQUENCY); | ||
357 | |||
351 | /* Prepare initial frames and set up the double buffer */ | 358 | /* Prepare initial frames and set up the double buffer */ |
352 | mixer_buffer_callback(); | 359 | mixer_buffer_callback(); |
353 | 360 | ||
@@ -492,6 +499,25 @@ void * mixer_channel_get_buffer(enum pcm_mixer_channel channel, int *count) | |||
492 | return NULL; | 499 | return NULL; |
493 | } | 500 | } |
494 | 501 | ||
502 | /* Calculate peak values for channel */ | ||
503 | void mixer_channel_calculate_peaks(enum pcm_mixer_channel channel, | ||
504 | int *left, int *right) | ||
505 | { | ||
506 | struct mixer_channel *chan = &channels[channel]; | ||
507 | struct pcm_peaks *peaks = &channel_peaks[channel]; | ||
508 | int count; | ||
509 | const void *addr = mixer_channel_get_buffer(channel, &count); | ||
510 | |||
511 | pcm_do_peak_calculation(peaks, chan->status == CHANNEL_PLAYING, | ||
512 | addr, count); | ||
513 | |||
514 | if (left) | ||
515 | *left = peaks->val[0]; | ||
516 | |||
517 | if (right) | ||
518 | *right = peaks->val[1]; | ||
519 | } | ||
520 | |||
495 | /* Stop ALL channels and PCM and reset state */ | 521 | /* Stop ALL channels and PCM and reset state */ |
496 | void mixer_reset(void) | 522 | void mixer_reset(void) |
497 | { | 523 | { |