summaryrefslogtreecommitdiff
path: root/firmware/export/pcm.h
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2012-02-23 08:14:46 -0500
committerMichael Sevakis <jethead71@rockbox.org>2012-03-03 07:23:38 +0100
commit286a4c5caa1945c8d1cb365a3d90fb09d5700cb2 (patch)
tree4835f46d16ec78d035ec9f49333079fe618384c1 /firmware/export/pcm.h
parent3f82f3aca14eb954e55f761721ffdd2684f0e812 (diff)
downloadrockbox-286a4c5caa1945c8d1cb365a3d90fb09d5700cb2.tar.gz
rockbox-286a4c5caa1945c8d1cb365a3d90fb09d5700cb2.zip
Revise the PCM callback system after adding multichannel audio.
Additional status callback is added to pcm_play/rec_data instead of using a special function to set it. Status includes DMA error reporting to the status callback. Playback and recording callback become more alike except playback uses "const void **addr" (because the data should not be altered) and recording uses "void **addr". "const" is put in place throughout where appropriate. Most changes are fairly trivial. One that should be checked in particular because it isn't so much is telechips, if anyone cares to bother. PP5002 is not so trivial either but that tested as working. Change-Id: I4928d69b3b3be7fb93e259f81635232df9bd1df2 Reviewed-on: http://gerrit.rockbox.org/166 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested-by: Michael Sevakis <jethead71@rockbox.org>
Diffstat (limited to 'firmware/export/pcm.h')
-rw-r--r--firmware/export/pcm.h31
1 files changed, 18 insertions, 13 deletions
diff --git a/firmware/export/pcm.h b/firmware/export/pcm.h
index 4a7a5b3193..df82c6092d 100644
--- a/firmware/export/pcm.h
+++ b/firmware/export/pcm.h
@@ -24,17 +24,23 @@
24#include <string.h> /* size_t */ 24#include <string.h> /* size_t */
25#include "config.h" 25#include "config.h"
26 26
27#define DMA_REC_ERROR_DMA (-1) 27enum pcm_dma_status
28{
28#ifdef HAVE_SPDIF_REC 29#ifdef HAVE_SPDIF_REC
29#define DMA_REC_ERROR_SPDIF (-2) 30 PCM_DMAST_ERR_SPDIF = -2,
30#endif 31#endif
32 PCM_DMAST_ERR_DMA = -1,
33 PCM_DMAST_OK = 0,
34 PCM_DMAST_STARTED = 1,
35};
31 36
32/** RAW PCM routines used with playback and recording **/ 37/** RAW PCM routines used with playback and recording **/
33 38
34/* Typedef for registered callbacks */ 39/* Typedef for registered data callback */
35typedef void (*pcm_play_callback_type)(unsigned char **start, 40typedef void (*pcm_play_callback_type)(const void **start, size_t *size);
36 size_t *size); 41
37typedef void (*pcm_rec_callback_type)(int status, void **start, size_t *size); 42/* Typedef for registered status callback */
43typedef enum pcm_dma_status (*pcm_status_callback_type)(enum pcm_dma_status status);
38 44
39/* set the pcm frequency - use values in hw_sampr_list 45/* set the pcm frequency - use values in hw_sampr_list
40 * when CONFIG_SAMPR_TYPES is #defined, or-in SAMPR_TYPE_* fields with 46 * when CONFIG_SAMPR_TYPES is #defined, or-in SAMPR_TYPE_* fields with
@@ -62,7 +68,8 @@ bool pcm_is_initialized(void);
62 68
63/* This is for playing "raw" PCM data */ 69/* This is for playing "raw" PCM data */
64void pcm_play_data(pcm_play_callback_type get_more, 70void pcm_play_data(pcm_play_callback_type get_more,
65 unsigned char* start, size_t size); 71 pcm_status_callback_type status_cb,
72 const void *start, size_t size);
66 73
67void pcm_calculate_peaks(int *left, int *right); 74void pcm_calculate_peaks(int *left, int *right);
68const void* pcm_get_peak_buffer(int* count); 75const void* pcm_get_peak_buffer(int* count);
@@ -73,12 +80,13 @@ void pcm_play_pause(bool play);
73bool pcm_is_paused(void); 80bool pcm_is_paused(void);
74bool pcm_is_playing(void); 81bool pcm_is_playing(void);
75 82
76void pcm_play_set_dma_started_callback(void (* callback)(void));
77
78#ifdef HAVE_RECORDING 83#ifdef HAVE_RECORDING
79 84
80/** RAW PCM recording routines **/ 85/** RAW PCM recording routines **/
81 86
87/* Typedef for registered data callback */
88typedef void (*pcm_rec_callback_type)(void **start, size_t *size);
89
82/* Reenterable locks for locking and unlocking the recording interrupt */ 90/* Reenterable locks for locking and unlocking the recording interrupt */
83void pcm_rec_lock(void); 91void pcm_rec_lock(void);
84void pcm_rec_unlock(void); 92void pcm_rec_unlock(void);
@@ -90,6 +98,7 @@ void pcm_close_recording(void);
90 98
91/* Start recording "raw" PCM data */ 99/* Start recording "raw" PCM data */
92void pcm_record_data(pcm_rec_callback_type more_ready, 100void pcm_record_data(pcm_rec_callback_type more_ready,
101 pcm_status_callback_type status_cb,
93 void *start, size_t size); 102 void *start, size_t size);
94 103
95/* Stop tranferring data into supplied buffer */ 104/* Stop tranferring data into supplied buffer */
@@ -98,10 +107,6 @@ void pcm_stop_recording(void);
98/* Is pcm currently recording? */ 107/* Is pcm currently recording? */
99bool pcm_is_recording(void); 108bool pcm_is_recording(void);
100 109
101/* Called by bottom layer ISR when transfer is complete. Returns non-zero
102 * size if successful. Setting start to NULL forces stop. */
103void pcm_rec_more_ready_callback(int status, void **start, size_t *size);
104
105void pcm_calculate_rec_peaks(int *left, int *right); 110void pcm_calculate_rec_peaks(int *left, int *right);
106 111
107#endif /* HAVE_RECORDING */ 112#endif /* HAVE_RECORDING */