blob: bddc7bb93d798b5bf15d9b0632a4c6f3e74015f2 [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
Dave Chapman0a7ded32006-08-13 09:19:24 +000022#if MEM > 1
Brandon Low413da2a2006-02-07 20:38:55 +000023#define PCMBUF_TARGET_CHUNK 32768 /* This is the target fill size of chunks
24 on the pcm buffer */
Brandon Lowddaf5f02006-05-08 11:03:19 +000025#define PCMBUF_MINAVG_CHUNK 24576 /* This is the minimum average size of
26 chunks on the pcm buffer (or we run out
27 of buffer descriptors, which is
28 non-fatal) */
Tomasz Malesinski28910e72006-08-12 23:01:52 +000029#else
30#define PCMBUF_TARGET_CHUNK 16384
31#define PCMBUF_MINAVG_CHUNK 12288
32#endif
33
Brandon Low413da2a2006-02-07 20:38:55 +000034#define PCMBUF_MIN_CHUNK 4096 /* We try to never feed a chunk smaller than
35 this to the DMA */
Brandon Lowf3bc1ef2006-04-22 14:40:13 +000036#define PCMBUF_MIX_CHUNK 8192 /* This is the maximum size of one packet
Brandon Low413da2a2006-02-07 20:38:55 +000037 for mixing (crossfade or voice) */
Miika Pekkarinen20b38972005-07-13 12:48:22 +000038
Brandon Low413da2a2006-02-07 20:38:55 +000039/* Returns true if the buffer needs to change size */
Michael Sevakise1dd10d2007-03-19 22:04:17 +000040bool pcmbuf_is_same_size(void);
41size_t pcmbuf_init(unsigned char *bufend);
Brandon Low413da2a2006-02-07 20:38:55 +000042/* Size in bytes used by the pcmbuffer */
43size_t pcmbuf_get_bufsize(void);
Michael Sevakise1dd10d2007-03-19 22:04:17 +000044#ifdef ROCKBOX_HAS_LOGF
45/* just used for logging for now */
46unsigned char * pcmbuf_get_meminfo(size_t *length);
47#endif
Brandon Low413da2a2006-02-07 20:38:55 +000048size_t get_pcmbuf_descsize(void);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000049
Brandon Low413da2a2006-02-07 20:38:55 +000050void pcmbuf_pause(bool pause);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000051void pcmbuf_play_stop(void);
52bool pcmbuf_is_crossfade_active(void);
53
54/* These functions are for playing chained buffers of PCM data */
Brandon Low413da2a2006-02-07 20:38:55 +000055#if defined(HAVE_ADJUSTABLE_CPU_FREQ) && !defined(SIMULATOR)
Miika Pekkarinen29aad552005-08-28 14:16:03 +000056void pcmbuf_boost(bool state);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000057void pcmbuf_set_boost_mode(bool state);
Miika Pekkarinen65d43a22005-08-28 19:55:30 +000058#else
Brandon Low413da2a2006-02-07 20:38:55 +000059#define pcmbuf_boost(state) do { } while(0)
Miika Pekkarinen65d43a22005-08-28 19:55:30 +000060#define pcmbuf_set_boost_mode(state) do { } while(0)
61#endif
Miika Pekkarinen20b38972005-07-13 12:48:22 +000062bool pcmbuf_is_lowdata(void);
Miika Pekkarinen159c52d2005-08-20 11:13:19 +000063void pcmbuf_play_start(void);
Miika Pekkarinena4f8d1c2006-01-27 16:25:44 +000064bool pcmbuf_crossfade_init(bool manual_skip);
Brandon Low413da2a2006-02-07 20:38:55 +000065void pcmbuf_set_event_handler(void (*callback)(void));
66void pcmbuf_set_position_callback(void (*callback)(size_t size));
Brandon Low6c0908b2006-04-23 22:54:34 +000067size_t pcmbuf_free(void);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000068unsigned int pcmbuf_get_latency(void);
Miika Pekkarinen4408b6b2006-02-07 19:17:51 +000069void pcmbuf_set_low_latency(bool state);
Michael Sevakisaba6ca02007-02-07 00:51:50 +000070void pcmbuf_write_complete(int count);
71void* pcmbuf_request_buffer(int *count);
72void* pcmbuf_request_voice_buffer(int *count, bool mix);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000073bool pcmbuf_is_crossfade_enabled(void);
74void pcmbuf_crossfade_enable(bool on_off);
Michael Sevakise1dd10d2007-03-19 22:04:17 +000075void pcmbuf_crossfade_enable_finished(void);
Miika Pekkarinen159c52d2005-08-20 11:13:19 +000076int pcmbuf_usage(void);
Brandon Lowf3bc1ef2006-04-22 14:40:13 +000077int pcmbuf_mix_free(void);
Brandon Low9535a9a2006-02-22 01:56:44 +000078void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude);
Michael Sevakisaba6ca02007-02-07 00:51:50 +000079void pcmbuf_mix_voice(int count);
Brandon Low413da2a2006-02-07 20:38:55 +000080
81int pcmbuf_used_descs(void);
82int pcmbuf_descs(void);
Miika Pekkarinen159c52d2005-08-20 11:13:19 +000083
Miika Pekkarinen20b38972005-07-13 12:48:22 +000084#endif