forked from len0rd/rockbox
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
This commit is contained in:
parent
c0208f0f64
commit
e189b33ff4
10 changed files with 81 additions and 78 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue