blob: 1d893f9c627796122837ff1d7393eb311901be8c [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 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Miika Pekkarinen20b38972005-07-13 12:48:22 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef PCMBUF_H
22#define PCMBUF_H
23
Brandon Low413da2a2006-02-07 20:38:55 +000024#define PCMBUF_TARGET_CHUNK 32768 /* This is the target fill size of chunks
25 on the pcm buffer */
Brandon Lowddaf5f02006-05-08 11:03:19 +000026#define PCMBUF_MINAVG_CHUNK 24576 /* This is the minimum average size of
27 chunks on the pcm buffer (or we run out
28 of buffer descriptors, which is
29 non-fatal) */
Brandon Low413da2a2006-02-07 20:38:55 +000030#define PCMBUF_MIN_CHUNK 4096 /* We try to never feed a chunk smaller than
31 this to the DMA */
Brandon Lowf3bc1ef2006-04-22 14:40:13 +000032#define PCMBUF_MIX_CHUNK 8192 /* This is the maximum size of one packet
Brandon Low413da2a2006-02-07 20:38:55 +000033 for mixing (crossfade or voice) */
Miika Pekkarinen20b38972005-07-13 12:48:22 +000034
Brandon Low413da2a2006-02-07 20:38:55 +000035/* Returns true if the buffer needs to change size */
Michael Sevakise1dd10d2007-03-19 22:04:17 +000036bool pcmbuf_is_same_size(void);
37size_t pcmbuf_init(unsigned char *bufend);
Brandon Low413da2a2006-02-07 20:38:55 +000038/* Size in bytes used by the pcmbuffer */
39size_t pcmbuf_get_bufsize(void);
Michael Sevakise1dd10d2007-03-19 22:04:17 +000040#ifdef ROCKBOX_HAS_LOGF
41/* just used for logging for now */
42unsigned char * pcmbuf_get_meminfo(size_t *length);
43#endif
Miika Pekkarinen20b38972005-07-13 12:48:22 +000044
Brandon Low413da2a2006-02-07 20:38:55 +000045void pcmbuf_pause(bool pause);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000046void pcmbuf_play_stop(void);
47bool pcmbuf_is_crossfade_active(void);
48
49/* These functions are for playing chained buffers of PCM data */
Dave Chapmanf02cba82007-05-10 13:16:08 +000050#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
Miika Pekkarinen29aad552005-08-28 14:16:03 +000051void pcmbuf_boost(bool state);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000052void pcmbuf_set_boost_mode(bool state);
Miika Pekkarinen65d43a22005-08-28 19:55:30 +000053#else
Brandon Low413da2a2006-02-07 20:38:55 +000054#define pcmbuf_boost(state) do { } while(0)
Miika Pekkarinen65d43a22005-08-28 19:55:30 +000055#define pcmbuf_set_boost_mode(state) do { } while(0)
56#endif
Miika Pekkarinen20b38972005-07-13 12:48:22 +000057bool pcmbuf_is_lowdata(void);
Miika Pekkarinen159c52d2005-08-20 11:13:19 +000058void pcmbuf_play_start(void);
Miika Pekkarinena4f8d1c2006-01-27 16:25:44 +000059bool pcmbuf_crossfade_init(bool manual_skip);
Jeffrey Goode5ce8e2c2009-11-04 03:58:33 +000060void pcmbuf_start_track_change(void);
Brandon Low6c0908b2006-04-23 22:54:34 +000061size_t pcmbuf_free(void);
Jeffrey Goode013fe352009-11-05 17:32:32 +000062unsigned long pcmbuf_get_latency(void);
Miika Pekkarinen4408b6b2006-02-07 19:17:51 +000063void pcmbuf_set_low_latency(bool state);
Michael Sevakis99617d72007-11-18 17:12:19 +000064void * pcmbuf_request_buffer(int *count);
Michael Sevakisaba6ca02007-02-07 00:51:50 +000065void pcmbuf_write_complete(int count);
Michael Sevakis99617d72007-11-18 17:12:19 +000066void * pcmbuf_request_voice_buffer(int *count);
67void pcmbuf_write_voice_complete(int count);
Miika Pekkarinen20b38972005-07-13 12:48:22 +000068bool pcmbuf_is_crossfade_enabled(void);
69void pcmbuf_crossfade_enable(bool on_off);
Michael Sevakise1dd10d2007-03-19 22:04:17 +000070void pcmbuf_crossfade_enable_finished(void);
Miika Pekkarinen159c52d2005-08-20 11:13:19 +000071int pcmbuf_usage(void);
Brandon Lowf3bc1ef2006-04-22 14:40:13 +000072int pcmbuf_mix_free(void);
Brandon Low9535a9a2006-02-22 01:56:44 +000073void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude);
Brandon Low413da2a2006-02-07 20:38:55 +000074
75int pcmbuf_used_descs(void);
76int pcmbuf_descs(void);
Miika Pekkarinen159c52d2005-08-20 11:13:19 +000077
Miika Pekkarinen20b38972005-07-13 12:48:22 +000078#endif