A couple comment changes.
[Rockbox-MoB.git] / buffering.h
blobd48986d28ea09a0ce3cfde750b9c38613c5e7b9a
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 /* Memory allocation should happen in the following order for each track:
28 TYPE_CODEC, TYPE_(>AUDIO), TYPE_AUDIO.
29 TYPE_CODEC will be released as soon as it has been closed.
30 TYPE_(>AUDIO) (the metadata types) will stay valid as long as the
31 audio buffer straight after them is kept open.
32 TYPE_AUDIO will be released as needed */
34 #if 0
35 JdGordon's thinking aloud...
37 The way this all should work is that if first_handle->data_type > TYPE_AUDIO
38 the LL will be searched for the first TYPE_AUDIO item.
39 if that item is closed then all the handles between first_handle and the found audio track
40 will be closed and dumped (or maybe they have to wait for playback to close them...),
41 either way, they will never be dumped unless the audio item is closed.
43 Now, when reading/wiritng the buffer... if (m->next && m->next->id == -1 && m->next->data_type == TYPE_AUDIO (might not need this extra check)) then it is a continuation of m. the guard fuffer will most likely be needed when the buffer is read.. but thats ok.
45 Unless im wrong it should only be possible that we have one of these "safe" sections at any one time.
47 The only problem with this system is that the MoB has to be allocated before the audio is read.
48 the id3 data should be a constant size which is ok, cuesheet will be known. image and buffer will not be known, which is where it might get tricky.
50 /end babbling
51 #endif
53 enum data_type {
54 TYPE_CODEC,
55 TYPE_AUDIO, /* TYPE_VIDEO, TYPE_BUFFERING_FILE, all the same */
56 /* the following data_types will not be unallocated unless the
57 audio next audio handle is closed. When that happens all the data
58 will be unallocated in one hit */
59 TYPE_ID3,
60 TYPE_CUESHEET,
61 TYPE_IMAGE,
62 TYPE_BUFFER,
63 TYPE_UNKNOWN,
66 enum data_state {
67 STATE_UNKNOWN,
68 STATE_OUTDATED,
69 STATE_IN_USE,
70 STATE_TO_BE_USED
73 void buffer_init(void);
74 int bufopen(char *file, size_t offset);
75 int bufclose(int handle_id);
76 int bufseek(int handle_id, size_t offset);
77 int bufadvance(int handle_id, ssize_t offset);
78 int bufread(int handle_id, size_t size, char *dest);
79 long bufgetdata(int handle_id, size_t size, unsigned char **data);
81 #endif