diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-08-14 15:13:00 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-08-14 15:13:00 +0000 |
commit | d1322b71595336740eb5e18e5deed056ddb71c7a (patch) | |
tree | 812db6a9c2e9d78405ec0ed38465fd88dc5be748 /firmware/include | |
parent | 9b9bd73dfb212d4192fccc5fc5e269fc6499139c (diff) | |
download | rockbox-d1322b71595336740eb5e18e5deed056ddb71c7a.tar.gz rockbox-d1322b71595336740eb5e18e5deed056ddb71c7a.zip |
GSoC/Buflib: Replace all direct accesses to audiobuf with buffer API functions.
Namely, introduce buffer_get_buffer() and buffer_release_buffer().
buffer_get_buffer() aquires all available and grabs a lock, attempting to
call buffer_alloc() or buffer_get_buffer() while this lock is locked will cause
a panicf() (doesn't actually happen, but is for debugging purpose).
buffer_release_buffer() unlocks that lock and can additionally increment the
audiobuf buffer to make an allocation. Pass 0 to only unlock if buffer was
used temporarily only.
buffer_available() is a replacement function to query audiobuflen, i.e. what's
left in the buffer.
Buffer init is moved up in the init chain and handles ipodvideo64mb internally.
Further changes happened to mp3data.c and talk.c as to not call the above API
functions, but get the buffer from callers. The caller is the audio system
which has the buffer lock while mp3data.c and talk mess with the buffer.
mpeg.c now implements some buffer related functions of playback.h, especially
audio_get_buffer(), allowing to reduce #ifdef hell a tiny bit.
audiobuf and audiobufend are local to buffer.c now.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30308 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/include')
-rw-r--r-- | firmware/include/buffer.h | 18 | ||||
-rw-r--r-- | firmware/include/dircache.h | 3 |
2 files changed, 7 insertions, 14 deletions
diff --git a/firmware/include/buffer.h b/firmware/include/buffer.h index 18f53f0000..bdf91bcb3f 100644 --- a/firmware/include/buffer.h +++ b/firmware/include/buffer.h | |||
@@ -22,21 +22,13 @@ | |||
22 | #define BUFFER_H | 22 | #define BUFFER_H |
23 | 23 | ||
24 | #include "config.h" | 24 | #include "config.h" |
25 | /* defined in linker script */ | ||
26 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | ||
27 | #if defined(IPOD_VIDEO) | ||
28 | extern unsigned char *audiobufend_lds[]; | ||
29 | unsigned char *audiobufend; | ||
30 | #else | ||
31 | extern unsigned char audiobufend[]; | ||
32 | #endif | ||
33 | #else | ||
34 | extern unsigned char *audiobufend; | ||
35 | #endif | ||
36 | |||
37 | extern unsigned char *audiobuf; | ||
38 | 25 | ||
39 | void buffer_init(void) INIT_ATTR; | 26 | void buffer_init(void) INIT_ATTR; |
27 | |||
28 | void* buffer_get_buffer(size_t *size); | ||
29 | void buffer_release_buffer(size_t size); | ||
30 | size_t buffer_available(void); | ||
31 | |||
40 | void *buffer_alloc(size_t size); | 32 | void *buffer_alloc(size_t size); |
41 | 33 | ||
42 | #ifdef BUFFER_ALLOC_DEBUG | 34 | #ifdef BUFFER_ALLOC_DEBUG |
diff --git a/firmware/include/dircache.h b/firmware/include/dircache.h index 0ac937df84..6beeeb6c23 100644 --- a/firmware/include/dircache.h +++ b/firmware/include/dircache.h | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include "config.h" | 24 | #include "config.h" |
25 | #include "dir_uncached.h" | 25 | #include "dir_uncached.h" |
26 | #include <string.h> /* size_t */ | ||
26 | 27 | ||
27 | #ifdef HAVE_DIRCACHE | 28 | #ifdef HAVE_DIRCACHE |
28 | 29 | ||
@@ -65,7 +66,7 @@ void dircache_init(void) INIT_ATTR; | |||
65 | int dircache_load(void); | 66 | int dircache_load(void); |
66 | int dircache_save(void); | 67 | int dircache_save(void); |
67 | int dircache_build(int last_size); | 68 | int dircache_build(int last_size); |
68 | void* dircache_steal_buffer(long *size); | 69 | void* dircache_steal_buffer(size_t *size); |
69 | bool dircache_is_enabled(void); | 70 | bool dircache_is_enabled(void); |
70 | bool dircache_is_initializing(void); | 71 | bool dircache_is_initializing(void); |
71 | void dircache_set_appflag(long mask); | 72 | void dircache_set_appflag(long mask); |