Implement rebuffering for seeking outside of buffered data boudaries
[Rockbox.git] / apps / buffering.h
bloba472f5f3362ecd176e87cc71f1c7146d8d97c7a9
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 Nicolas Pennequin
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #ifndef _BUFFERING_H_
21 #define _BUFFERING_H_
23 #include <sys/types.h>
24 #include <stdbool.h>
27 /* default point to start buffer refill */
28 #define AUDIO_DEFAULT_WATERMARK (1024*512)
29 /* amount of data to read in one read() call */
30 #define AUDIO_DEFAULT_FILECHUNK (1024*32)
31 /* point at which the file buffer will fight for CPU time */
32 #define AUDIO_FILEBUF_CRITICAL (1024*128)
33 /* amount of guess-space to allow for codecs that must hunt and peck
34 * for their correct seeek target, 32k seems a good size */
35 #define AUDIO_REBUFFER_GUESS_SIZE (1024*32)
38 enum data_type {
39 TYPE_CODEC,
40 TYPE_AUDIO,
41 TYPE_STREAM,
42 TYPE_ID3,
43 TYPE_CUESHEET,
44 TYPE_IMAGE,
45 TYPE_BUFFER,
46 TYPE_UNKNOWN,
49 enum {
50 Q_BUFFER_HANDLE = 1,
51 Q_RESET_HANDLE,
54 struct event_queue buffering_queue;
55 struct queue_sender_list buffering_queue_sender_list;
57 bool buffering_init(char *filebuf, size_t filebuflen);
58 size_t bufused(void);
59 int bufopen(char *file, size_t offset, enum data_type type);
60 int bufalloc(void *src, size_t size, enum data_type type);
61 int bufclose(int handle_id);
62 int bufseek(int handle_id, size_t newpos);
63 int bufadvance(int handle_id, off_t offset);
64 ssize_t bufread(int handle_id, size_t size, char *dest);
65 ssize_t bufgetdata(int handle_id, size_t size, unsigned char **data);
66 ssize_t get_offset(int handle_id, void *ptr);
68 #endif