summaryrefslogtreecommitdiff
path: root/firmware/export/pcm.h
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-10-06 22:27:27 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-10-06 22:27:27 +0000
commit6077e5b7c85c0d6f5963e4aadb215faf2c4d10d2 (patch)
treea6bc91ee4168e83617e942eeaea46e5523e82420 /firmware/export/pcm.h
parentf6de0d4083a4fcb6da57f271e1f8ccaf715e571d (diff)
Unify PCM interface just above the hardware driver level for all targets including the sims. Perform lockout of audio callback when changing states. Weird new playback or recording trouble? Check before and after this revision first though things seem quite sound.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15006 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/export/pcm.h')
-rw-r--r--firmware/export/pcm.h122
1 files changed, 122 insertions, 0 deletions
diff --git a/firmware/export/pcm.h b/firmware/export/pcm.h
new file mode 100644
index 0000000000..a875479a2d
--- /dev/null
+++ b/firmware/export/pcm.h
@@ -0,0 +1,122 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2005 by Linus Nielsen Feltzing
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef PCM_PLAYBACK_H
+#define PCM_PLAYBACK_H
+
+#include <sys/types.h>
+
+/** RAW PCM routines used with playback and recording **/
+
+/* Typedef for registered callback */
+typedef void (*pcm_more_callback_type)(unsigned char **start,
+ size_t *size);
+typedef int (*pcm_more_callback_type2)(int status);
+
+/* set the pcm frequency - use values in hw_sampr_list
+ * use -1 for the default frequency
+ */
+void pcm_set_frequency(unsigned int frequency);
+/* apply settings to hardware immediately */
+void pcm_apply_settings(void);
+
+/** RAW PCM playback routines **/
+
+/* Reenterable locks for locking and unlocking the playback interrupt */
+void pcm_play_lock(void);
+void pcm_play_unlock(void);
+
+void pcm_init(void);
+void pcm_postinit(void);
+
+/* This is for playing "raw" PCM data */
+void pcm_play_data(pcm_more_callback_type get_more,
+ unsigned char* start, size_t size);
+
+void pcm_calculate_peaks(int *left, int *right);
+size_t pcm_get_bytes_waiting(void);
+
+void pcm_play_stop(void);
+void pcm_mute(bool mute);
+void pcm_play_pause(bool play);
+bool pcm_is_paused(void);
+bool pcm_is_playing(void);
+
+/** The following are for internal use between pcm.c and target-
+ specific portion **/
+
+extern unsigned long pcm_curr_sampr;
+
+/* the registered callback function to ask for more mp3 data */
+extern volatile pcm_more_callback_type pcm_callback_for_more;
+extern volatile bool pcm_playing;
+extern volatile bool pcm_paused;
+
+void pcm_play_dma_lock(void);
+void pcm_play_dma_unlock(void);
+void pcm_play_dma_init(void);
+void pcm_play_dma_start(const void *addr, size_t size);
+void pcm_play_dma_stop(void);
+void pcm_play_dma_pause(bool pause);
+void pcm_play_dma_stopped_callback(void);
+const void * pcm_play_dma_get_peak_buffer(int *count);
+
+#ifdef HAVE_RECORDING
+
+/** RAW PCM recording routines **/
+
+/* Reenterable locks for locking and unlocking the recording interrupt */
+void pcm_rec_lock(void);
+void pcm_rec_unlock(void);
+
+/* Initialize pcm recording interface */
+void pcm_init_recording(void);
+/* Uninitialze pcm recording interface */
+void pcm_close_recording(void);
+
+/* Start recording "raw" PCM data */
+void pcm_record_data(pcm_more_callback_type2 more_ready,
+ void *start, size_t size);
+
+/* Stop tranferring data into supplied buffer */
+void pcm_stop_recording(void);
+
+/* Continue transferring data in - call during interrupt handler */
+void pcm_record_more(void *start, size_t size);
+
+void pcm_calculate_rec_peaks(int *left, int *right);
+
+/** The following are for internal use between pcm.c and target-
+ specific portion **/
+extern volatile const void *pcm_rec_peak_addr;
+/* the registered callback function for when more data is available */
+extern volatile pcm_more_callback_type2 pcm_callback_more_ready;
+/* DMA transfer in is currently active */
+extern volatile bool pcm_recording;
+
+/* APIs implemented in the target-specific portion */
+void pcm_rec_dma_init(void);
+void pcm_rec_dma_close(void);
+void pcm_rec_dma_start(void *addr, size_t size);
+void pcm_rec_dma_stop(void);
+void pcm_rec_dma_stopped_callback(void);
+const void * pcm_rec_dma_get_peak_buffer(int *count);
+
+#endif /* HAVE_RECORDING */
+
+#endif /* PCM_PLAYBACK_H */