From a2b6703a369f6cdbfec1f150c408dadc877631fb Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Wed, 29 Jun 2011 06:37:04 +0000 Subject: Commit FS#12150 - Fully-functional audio mixer - and finally whip old limitations about playback of voice and other sounds when paused. Channels are independent in state and amplitude. Fade on stop/pause is handled by the channel's volume control rather than global volume which means it now works from anywhere. Opens up the possibility of plugin sounds during music playback by merely adding an additional channel enum. If any PCM drivers were not properly modified, see one of the last comments in the task for a description of the simple change that is expected. Some params are tunable in firmware/export/pcm-mixer.h as well. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30097 a1c6a512-1295-4272-9138-f99709370657 --- firmware/pcm.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'firmware/pcm.c') diff --git a/firmware/pcm.c b/firmware/pcm.c index d15c129015..b7415f329b 100644 --- a/firmware/pcm.c +++ b/firmware/pcm.c @@ -28,6 +28,8 @@ #include "audio.h" #include "sound.h" #include "general.h" +#include "pcm-internal.h" +#include "pcm_mixer.h" /** * Aspects implemented in the target-specific portion: @@ -78,8 +80,8 @@ */ /* the registered callback function to ask for more mp3 data */ -static volatile pcm_play_callback_type pcm_callback_for_more - SHAREDBSS_ATTR = NULL; +static pcm_play_callback_type pcm_callback_for_more SHAREDBSS_ATTR = NULL; +void (* pcm_play_dma_started)(void) SHAREDBSS_ATTR = NULL; /* PCM playback state */ volatile bool pcm_playing SHAREDBSS_ATTR = false; /* PCM paused state. paused implies playing */ @@ -95,6 +97,7 @@ int pcm_fsel SHAREDBSS_ATTR = HW_FREQ_DEFAULT; static void pcm_play_stopped(void) { pcm_callback_for_more = NULL; + pcm_play_dma_started = NULL; pcm_paused = false; pcm_playing = false; } @@ -404,6 +407,12 @@ void pcm_apply_settings(void) } } +/* register callback to buffer more data */ +void pcm_play_set_dma_started_callback(void (* callback)(void)) +{ + pcm_play_dma_started = callback; +} + #ifdef HAVE_RECORDING /** Low level pcm recording apis **/ @@ -475,6 +484,11 @@ void pcm_init_recording(void) { logf("pcm_init_recording"); +#ifndef HAVE_PCM_FULL_DUPLEX + /* Stop the beasty before attempting recording */ + mixer_reset(); +#endif + /* Recording init is locked unlike general pcm init since this is not * just a one-time event at startup and it should and must be safe by * now. */ -- cgit v1.2.3