Reload the current playlist after reboot even if it has ended. (FS#11644)
[kugel-rb.git] / firmware / export / pcm_mixer.h
blobbe10601ffd5cbad08fe932ae5a6483249a87be68
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2011 by Michael Sevakis
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef PCM_MIXER_H
23 #define PCM_MIXER_H
25 /** Simple config **/
27 /* Length of PCM frames (always) */
28 #if CONFIG_CPU == PP5002
29 /* There's far less time to do mixing because HW FIFOs are short */
30 #define MIX_FRAME_SAMPLES 64
31 #else
32 /* Assume HW DMA engine is available or sufficient latency exists in the
33 PCM pathway */
34 #define MIX_FRAME_SAMPLES 256
35 #endif
37 /* IAUDIO_M5 is very tight on IRAM */
38 #if (defined(CPU_COLDFIRE) && !defined(IAUDIO_M5)) || defined(CPU_PP)
39 /* For Coldfire, it's just faster
40 For PortalPlayer, this also avoids more expensive cache coherency */
41 #define DOWNMIX_BUF_IBSS IBSS_ATTR
42 #else
43 /* Otherwise can't DMA from IRAM, IRAM is pointless or worse */
44 #define DOWNMIX_BUF_IBSS
45 #endif
47 #if defined(CPU_COLDFIRE) || defined(CPU_PP)
48 #define MIXER_CALLBACK_ICODE ICODE_ATTR
49 #else
50 #define MIXER_CALLBACK_ICODE
51 #endif
54 /** Definitions **/
56 /* Channels are preassigned for simplicity */
57 enum pcm_mixer_channel
59 PCM_MIXER_CHAN_PLAYBACK = 0,
60 PCM_MIXER_CHAN_VOICE,
61 #ifndef HAVE_HARDWARE_BEEP
62 PCM_MIXER_CHAN_BEEP,
63 #endif
64 /* Add new channel indexes above this line */
65 PCM_MIXER_NUM_CHANNELS,
68 /* Channel playback states */
69 enum channel_status
71 CHANNEL_STOPPED = 0,
72 CHANNEL_PLAYING,
73 CHANNEL_PAUSED,
76 #define MIX_AMP_UNITY 0x00010000
77 #define MIX_AMP_MUTE 0x00000000
80 /** Public interfaces **/
82 /* Start playback on a channel */
83 void mixer_channel_play_data(enum pcm_mixer_channel channel,
84 pcm_play_callback_type get_more,
85 unsigned char *start, size_t size);
87 /* Pause or resume a channel (when started) */
88 void mixer_channel_play_pause(enum pcm_mixer_channel channel, bool play);
90 /* Stop playback on a channel */
91 void mixer_channel_stop(enum pcm_mixer_channel channel);
93 /* Set channel's amplitude factor */
94 void mixer_channel_set_amplitude(enum pcm_mixer_channel channel,
95 unsigned int amplitude);
97 /* Return channel's playback status */
98 enum channel_status mixer_channel_status(enum pcm_mixer_channel channel);
100 /* Returns amount data remaining in channel before next callback */
101 size_t mixer_channel_get_bytes_waiting(enum pcm_mixer_channel channel);
103 /* Return pointer to channel's playing audio data and the size remaining */
104 void * mixer_channel_get_buffer(enum pcm_mixer_channel channel, int *count);
106 /* Calculate peak values for channel */
107 void mixer_channel_calculate_peaks(enum pcm_mixer_channel channel,
108 int *left, int *right);
110 /* Stop ALL channels and PCM and reset state */
111 void mixer_reset(void);
113 #endif /* PCM_MIXER_H */