summaryrefslogtreecommitdiff
path: root/firmware/pcm.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-06-29 06:37:04 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-06-29 06:37:04 +0000
commita2b6703a369f6cdbfec1f150c408dadc877631fb (patch)
tree3145a8c1372c44711d38feefeba39c7d4098f139 /firmware/pcm.c
parent8411614b8a068a4f274c3841aa55aab1df1bc246 (diff)
downloadrockbox-a2b6703a369f6cdbfec1f150c408dadc877631fb.tar.gz
rockbox-a2b6703a369f6cdbfec1f150c408dadc877631fb.zip
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
Diffstat (limited to 'firmware/pcm.c')
-rw-r--r--firmware/pcm.c18
1 files changed, 16 insertions, 2 deletions
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 @@
28#include "audio.h" 28#include "audio.h"
29#include "sound.h" 29#include "sound.h"
30#include "general.h" 30#include "general.h"
31#include "pcm-internal.h"
32#include "pcm_mixer.h"
31 33
32/** 34/**
33 * Aspects implemented in the target-specific portion: 35 * Aspects implemented in the target-specific portion:
@@ -78,8 +80,8 @@
78 */ 80 */
79 81
80/* the registered callback function to ask for more mp3 data */ 82/* the registered callback function to ask for more mp3 data */
81static volatile pcm_play_callback_type pcm_callback_for_more 83static pcm_play_callback_type pcm_callback_for_more SHAREDBSS_ATTR = NULL;
82 SHAREDBSS_ATTR = NULL; 84void (* pcm_play_dma_started)(void) SHAREDBSS_ATTR = NULL;
83/* PCM playback state */ 85/* PCM playback state */
84volatile bool pcm_playing SHAREDBSS_ATTR = false; 86volatile bool pcm_playing SHAREDBSS_ATTR = false;
85/* PCM paused state. paused implies playing */ 87/* PCM paused state. paused implies playing */
@@ -95,6 +97,7 @@ int pcm_fsel SHAREDBSS_ATTR = HW_FREQ_DEFAULT;
95static void pcm_play_stopped(void) 97static void pcm_play_stopped(void)
96{ 98{
97 pcm_callback_for_more = NULL; 99 pcm_callback_for_more = NULL;
100 pcm_play_dma_started = NULL;
98 pcm_paused = false; 101 pcm_paused = false;
99 pcm_playing = false; 102 pcm_playing = false;
100} 103}
@@ -404,6 +407,12 @@ void pcm_apply_settings(void)
404 } 407 }
405} 408}
406 409
410/* register callback to buffer more data */
411void pcm_play_set_dma_started_callback(void (* callback)(void))
412{
413 pcm_play_dma_started = callback;
414}
415
407#ifdef HAVE_RECORDING 416#ifdef HAVE_RECORDING
408/** Low level pcm recording apis **/ 417/** Low level pcm recording apis **/
409 418
@@ -475,6 +484,11 @@ void pcm_init_recording(void)
475{ 484{
476 logf("pcm_init_recording"); 485 logf("pcm_init_recording");
477 486
487#ifndef HAVE_PCM_FULL_DUPLEX
488 /* Stop the beasty before attempting recording */
489 mixer_reset();
490#endif
491
478 /* Recording init is locked unlike general pcm init since this is not 492 /* Recording init is locked unlike general pcm init since this is not
479 * just a one-time event at startup and it should and must be safe by 493 * just a one-time event at startup and it should and must be safe by
480 * now. */ 494 * now. */