summaryrefslogtreecommitdiffstats
path: root/firmware/pcm_mixer.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2012-05-02 20:53:07 -0400
committerMichael Sevakis <jethead71@rockbox.org>2012-05-02 20:53:07 -0400
commite189b33ff4cc530cb6e59a17b260675d7341e551 (patch)
tree948b635696cbea2eac432303fa2821cfbff13670 /firmware/pcm_mixer.c
parentc0208f0f64c68a97c67e42efc1b39df7c75bf7da (diff)
downloadrockbox-e189b33ff4cc530cb6e59a17b260675d7341e551.tar.gz
rockbox-e189b33ff4cc530cb6e59a17b260675d7341e551.tar.bz2
rockbox-e189b33ff4cc530cb6e59a17b260675d7341e551.zip
Clean up peak calculating code.
Mixer needn't keep peak data around that will never be used. Just pass pcm_peaks structure to it instead of allocating for every channel. Plugin API becomes incompatible. vu_meter digital mode was still using global peak calculation; switch it to playback channel like the rest. Remove some accumulated soil peaks inside pcm.c and make it more generic. Change-Id: Ib4d268d80b6a9d09915eea1c91eab483c1a2c009
Diffstat (limited to 'firmware/pcm_mixer.c')
-rw-r--r--firmware/pcm_mixer.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/firmware/pcm_mixer.c b/firmware/pcm_mixer.c
index 85d31ade70..cddff431ec 100644
--- a/firmware/pcm_mixer.c
+++ b/firmware/pcm_mixer.c
@@ -60,9 +60,6 @@ static size_t next_size = 0; /* Size of buffer to play next time */
/* Descriptors for all available channels */
static struct mixer_channel channels[PCM_MIXER_NUM_CHANNELS] IBSS_ATTR;
-/* History for channel peaks */
-static struct pcm_peaks channel_peaks[PCM_MIXER_NUM_CHANNELS];
-
/* Packed pointer array of all playing (active) channels in "channels" array */
static struct mixer_channel * active_channels[PCM_MIXER_NUM_CHANNELS+1] IBSS_ATTR;
@@ -389,21 +386,14 @@ const void * mixer_channel_get_buffer(enum pcm_mixer_channel channel, int *count
/* Calculate peak values for channel */
void mixer_channel_calculate_peaks(enum pcm_mixer_channel channel,
- int *left, int *right)
+ struct pcm_peaks *peaks)
{
- struct mixer_channel *chan = &channels[channel];
- struct pcm_peaks *peaks = &channel_peaks[channel];
int count;
const void *addr = mixer_channel_get_buffer(channel, &count);
- pcm_do_peak_calculation(peaks, chan->status == CHANNEL_PLAYING,
+ pcm_do_peak_calculation(peaks,
+ channels[channel].status == CHANNEL_PLAYING,
addr, count);
-
- if (left)
- *left = peaks->val[0];
-
- if (right)
- *right = peaks->val[1];
}
/* Adjust channel pointer by a given offset to support movable buffers */