Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 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 Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 22 | #define PCMBUF_TARGET_CHUNK 32768 /* This is the target fill size of chunks |
| 23 | on the pcm buffer */ |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 24 | #define PCMBUF_MIN_CHUNK 4096 /* We try to never feed a chunk smaller than |
| 25 | this to the DMA */ |
Brandon Low | f3bc1ef | 2006-04-22 14:40:13 +0000 | [diff] [blame] | 26 | #define PCMBUF_MIX_CHUNK 8192 /* This is the maximum size of one packet |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 27 | for mixing (crossfade or voice) */ |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 28 | |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 29 | /* Returns true if the buffer needs to change size */ |
| 30 | bool pcmbuf_is_same_size(size_t bufsize); |
| 31 | void pcmbuf_init(size_t bufsize); |
| 32 | /* Size in bytes used by the pcmbuffer */ |
| 33 | size_t pcmbuf_get_bufsize(void); |
| 34 | size_t get_pcmbuf_descsize(void); |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 35 | |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 36 | void pcmbuf_pause(bool pause); |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 37 | void pcmbuf_play_stop(void); |
| 38 | bool pcmbuf_is_crossfade_active(void); |
| 39 | |
| 40 | /* These functions are for playing chained buffers of PCM data */ |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 41 | #if defined(HAVE_ADJUSTABLE_CPU_FREQ) && !defined(SIMULATOR) |
Miika Pekkarinen | 29aad55 | 2005-08-28 14:16:03 +0000 | [diff] [blame] | 42 | void pcmbuf_boost(bool state); |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 43 | void pcmbuf_set_boost_mode(bool state); |
Miika Pekkarinen | 65d43a2 | 2005-08-28 19:55:30 +0000 | [diff] [blame] | 44 | #else |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 45 | #define pcmbuf_boost(state) do { } while(0) |
Miika Pekkarinen | 65d43a2 | 2005-08-28 19:55:30 +0000 | [diff] [blame] | 46 | #define pcmbuf_set_boost_mode(state) do { } while(0) |
| 47 | #endif |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 48 | bool pcmbuf_is_lowdata(void); |
Miika Pekkarinen | 159c52d | 2005-08-20 11:13:19 +0000 | [diff] [blame] | 49 | void pcmbuf_play_start(void); |
Miika Pekkarinen | a4f8d1c | 2006-01-27 16:25:44 +0000 | [diff] [blame] | 50 | bool pcmbuf_crossfade_init(bool manual_skip); |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 51 | void pcmbuf_set_event_handler(void (*callback)(void)); |
| 52 | void pcmbuf_set_position_callback(void (*callback)(size_t size)); |
Brandon Low | 6c0908b | 2006-04-23 22:54:34 +0000 | [diff] [blame] | 53 | size_t pcmbuf_free(void); |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 54 | unsigned int pcmbuf_get_latency(void); |
Miika Pekkarinen | 4408b6b | 2006-02-07 19:17:51 +0000 | [diff] [blame] | 55 | void pcmbuf_set_low_latency(bool state); |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 56 | void pcmbuf_write_complete(size_t length); |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 57 | void* pcmbuf_request_buffer(size_t length, size_t *realsize); |
| 58 | void* pcmbuf_request_voice_buffer(size_t length, size_t *realsize, bool mix); |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 59 | bool pcmbuf_is_crossfade_enabled(void); |
| 60 | void pcmbuf_crossfade_enable(bool on_off); |
| 61 | |
Miika Pekkarinen | 159c52d | 2005-08-20 11:13:19 +0000 | [diff] [blame] | 62 | int pcmbuf_usage(void); |
Brandon Low | f3bc1ef | 2006-04-22 14:40:13 +0000 | [diff] [blame] | 63 | int pcmbuf_mix_free(void); |
Brandon Low | 9535a9a | 2006-02-22 01:56:44 +0000 | [diff] [blame] | 64 | void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude); |
Brandon Low | f3bc1ef | 2006-04-22 14:40:13 +0000 | [diff] [blame] | 65 | void pcmbuf_mix_voice(size_t length); |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 66 | |
| 67 | int pcmbuf_used_descs(void); |
| 68 | int pcmbuf_descs(void); |
Miika Pekkarinen | 159c52d | 2005-08-20 11:13:19 +0000 | [diff] [blame] | 69 | |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 70 | #endif |