blob: b659e8fa4e84dee4ac7301d30f63e0450c6beb6f [file] [log] [blame]
Miika Pekkarinen20b38972005-07-13 12:48:22 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Miika Pekkarinen
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef PCMBUF_H
20#define PCMBUF_H
21
Brandon Low413da2a2006-02-07 20:38:55 +000022#define PCMBUF_TARGET_CHUNK 32768 /* This is the target fill size of chunks
23 on the pcm buffer */
24#define PCMBUF_MINAVG_CHUNK 24576 /* This is the minimum average size of
25 chunks on the pcm buffer (or we run out
26 of buffer descriptors, which is
27 non-fatal) */
28#define PCMBUF_MIN_CHUNK 4096 /* We try to never feed a chunk smaller than
29 this to the DMA */
30#define PCMBUF_FADE_CHUNK 8192 /* This is the maximum size of one packet
31 for mixing (crossfade or voice) */
Miika Pekkarinen20b38972005-07-13 12:48:22 +000032
Brandon Low413da2a2006-02-07 20:38:55 +000033/* Returns true if the buffer needs to change size */
34bool pcmbuf_is_same_size(size_t bufsize);
35void pcmbuf_init(size_t bufsize);
36/* Size in bytes used by the pcmbuffer */
37size_t pcmbuf_get_bufsize(void);
38size_t get_pcmbuf_descsize(void);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000039
Brandon Low413da2a2006-02-07 20:38:55 +000040void pcmbuf_pause(bool pause);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000041void pcmbuf_play_stop(void);
42bool pcmbuf_is_crossfade_active(void);
43
44/* These functions are for playing chained buffers of PCM data */
Brandon Low413da2a2006-02-07 20:38:55 +000045#if defined(HAVE_ADJUSTABLE_CPU_FREQ) && !defined(SIMULATOR)
Miika Pekkarinen29aad552005-08-28 14:16:03 +000046void pcmbuf_boost(bool state);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000047void pcmbuf_set_boost_mode(bool state);
Miika Pekkarinen65d43a22005-08-28 19:55:30 +000048#else
Brandon Low413da2a2006-02-07 20:38:55 +000049#define pcmbuf_boost(state) do { } while(0)
Miika Pekkarinen65d43a22005-08-28 19:55:30 +000050#define pcmbuf_set_boost_mode(state) do { } while(0)
51#endif
Miika Pekkarinen20b38972005-07-13 12:48:22 +000052bool pcmbuf_is_lowdata(void);
Miika Pekkarinen159c52d2005-08-20 11:13:19 +000053void pcmbuf_play_start(void);
Miika Pekkarinena4f8d1c2006-01-27 16:25:44 +000054bool pcmbuf_crossfade_init(bool manual_skip);
Brandon Low413da2a2006-02-07 20:38:55 +000055void pcmbuf_set_event_handler(void (*callback)(void));
56void pcmbuf_set_position_callback(void (*callback)(size_t size));
Miika Pekkarinen20b38972005-07-13 12:48:22 +000057unsigned int pcmbuf_get_latency(void);
Miika Pekkarinen4408b6b2006-02-07 19:17:51 +000058void pcmbuf_set_low_latency(bool state);
Brandon Low413da2a2006-02-07 20:38:55 +000059bool pcmbuf_insert_buffer(const char *buf, size_t length);
60void pcmbuf_write_complete(size_t length);
Brandon Low413da2a2006-02-07 20:38:55 +000061void* pcmbuf_request_buffer(size_t length, size_t *realsize);
62void* pcmbuf_request_voice_buffer(size_t length, size_t *realsize, bool mix);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000063bool pcmbuf_is_crossfade_enabled(void);
64void pcmbuf_crossfade_enable(bool on_off);
65
Miika Pekkarinen159c52d2005-08-20 11:13:19 +000066int pcmbuf_usage(void);
67int pcmbuf_mix_usage(void);
Brandon Low9535a9a2006-02-22 01:56:44 +000068void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude);
Miika Pekkarinen159c52d2005-08-20 11:13:19 +000069void pcmbuf_reset_mixpos(void);
Brandon Low413da2a2006-02-07 20:38:55 +000070void pcmbuf_mix(char *buf, size_t length);
71
72int pcmbuf_used_descs(void);
73int pcmbuf_descs(void);
Miika Pekkarinen159c52d2005-08-20 11:13:19 +000074
Miika Pekkarinen20b38972005-07-13 12:48:22 +000075#endif