From e189b33ff4cc530cb6e59a17b260675d7341e551 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Wed, 2 May 2012 20:53:07 -0400 Subject: 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 --- firmware/export/pcm-internal.h | 7 ------- firmware/export/pcm.h | 12 +++++++++++- firmware/export/pcm_mixer.h | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) (limited to 'firmware/export') diff --git a/firmware/export/pcm-internal.h b/firmware/export/pcm-internal.h index abe3fe08dc..397cf6832f 100644 --- a/firmware/export/pcm-internal.h +++ b/firmware/export/pcm-internal.h @@ -29,13 +29,6 @@ ({ (start) = (void *)(((uintptr_t)(start) + 3) & ~3); \ (size) &= ~3; }) -struct pcm_peaks -{ - long period; - long tick; - uint16_t val[2]; -}; - void pcm_do_peak_calculation(struct pcm_peaks *peaks, bool active, const void *addr, int count); diff --git a/firmware/export/pcm.h b/firmware/export/pcm.h index df82c6092d..608129c078 100644 --- a/firmware/export/pcm.h +++ b/firmware/export/pcm.h @@ -21,7 +21,7 @@ #ifndef PCM_PLAYBACK_H #define PCM_PLAYBACK_H -#include /* size_t */ +#include /* size_t, uint32_t */ #include "config.h" enum pcm_dma_status @@ -71,6 +71,16 @@ void pcm_play_data(pcm_play_callback_type get_more, pcm_status_callback_type status_cb, const void *start, size_t size); +/* Kept internally for global PCM and used by mixer's verion of peak + calculation */ +struct pcm_peaks +{ + uint32_t left; /* Left peak value */ + uint32_t right; /* Right peak value */ + long period; /* For tracking calling period */ + long tick; /* Last tick called */ +}; + void pcm_calculate_peaks(int *left, int *right); const void* pcm_get_peak_buffer(int* count); size_t pcm_get_bytes_waiting(void); diff --git a/firmware/export/pcm_mixer.h b/firmware/export/pcm_mixer.h index 5d8deb2bbf..f6d212d8e0 100644 --- a/firmware/export/pcm_mixer.h +++ b/firmware/export/pcm_mixer.h @@ -111,7 +111,7 @@ 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); /* Adjust channel pointer by a given offset to support movable buffers */ void mixer_adjust_channel_address(enum pcm_mixer_channel channel, -- cgit v1.2.3