summaryrefslogtreecommitdiffstats
path: root/firmware/pcm_mixer.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-07-02 11:55:38 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-07-02 11:55:38 +0000
commit22b6def065ab7c2ca030f405577e34104ad20011 (patch)
tree6be548bf591d2365077b74679048737fe51792a2 /firmware/pcm_mixer.c
parent8c954e28b75b47543f69abe2c169d83ad38c26ae (diff)
downloadrockbox-22b6def065ab7c2ca030f405577e34104ad20011.tar.gz
rockbox-22b6def065ab7c2ca030f405577e34104ad20011.tar.bz2
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.c28
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 @@
#include "general.h"
#include "kernel.h"
#include "pcm.h"
+#include "pcm-internal.h"
#include "pcm_mixer.h"
#include "dsp.h"
@@ -59,6 +60,9 @@ 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;
@@ -343,11 +347,14 @@ static void mixer_start_pcm(void)
if (pcm_is_playing())
return;
-#if defined(HAVE_RECORDING) && !defined(HAVE_PCM_FULL_DUPLEX)
+#if defined(HAVE_RECORDING)
if (pcm_is_recording())
return;
#endif
+ /* Requires a shared global sample rate for all channels */
+ pcm_set_frequency(NATIVE_FREQUENCY);
+
/* Prepare initial frames and set up the double buffer */
mixer_buffer_callback();
@@ -492,6 +499,25 @@ void * mixer_channel_get_buffer(enum pcm_mixer_channel channel, int *count)
return NULL;
}
+/* Calculate peak values for channel */
+void mixer_channel_calculate_peaks(enum pcm_mixer_channel channel,
+ int *left, int *right)
+{
+ 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,
+ addr, count);
+
+ if (left)
+ *left = peaks->val[0];
+
+ if (right)
+ *right = peaks->val[1];
+}
+
/* Stop ALL channels and PCM and reset state */
void mixer_reset(void)
{