Some improvements to the main().
[Rockbox-MoB.git] / buffering.h
blobbd43543537cc1362b6d1bbfafc8304e6f2a7b060
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>
25 #define MAX_PATH 256
27 enum data_type {
28 TYPE_UNKNOWN,
29 TYPE_AUDIO,
30 TYPE_ID3,
31 TYPE_CUESHEET,
32 TYPE_IMAGE
35 enum data_state {
36 STATE_UNKNOWN,
37 STATE_OUTDATED,
38 STATE_IN_USE,
39 STATE_TO_BE_USED
42 struct memory_handle {
43 unsigned int id;
44 enum data_type type;
45 enum data_state state;
46 char path[MAX_PATH];
47 int fd;
48 size_t data; /* Start index of the handle's data buffer */
49 size_t buf_idx; /* Current read pointer in the handle data buffer */
50 size_t filesize; /* File total length */
51 size_t filerem; /* Remaining bytes of file NOT in buffer */
52 size_t available; /* Available bytes to read from buffer */
53 size_t offset; /* Offset at which we started reading the file */
54 struct memory_handle *next;
57 void buffer_init(void);
58 int bufopen(char *file, size_t offset);
59 int bufclose(int handle_id);
60 int bufseek(int handle_id, size_t offset);
61 int bufread(int handle_id, size_t size, char *dest);
63 #endif