summaryrefslogtreecommitdiff
path: root/apps/tagcache.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-08-14 15:13:00 +0000
committerThomas Martitz <kugel@rockbox.org>2011-08-14 15:13:00 +0000
commitd1322b71595336740eb5e18e5deed056ddb71c7a (patch)
tree812db6a9c2e9d78405ec0ed38465fd88dc5be748 /apps/tagcache.c
parent9b9bd73dfb212d4192fccc5fc5e269fc6499139c (diff)
downloadrockbox-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 'apps/tagcache.c')
-rw-r--r--apps/tagcache.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 6aa7709c00..0a491c58b5 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -107,7 +107,7 @@ static char curpath[TAG_MAXLEN+32];
107/* Used when removing duplicates. */ 107/* Used when removing duplicates. */
108static char *tempbuf; /* Allocated when needed. */ 108static char *tempbuf; /* Allocated when needed. */
109static long tempbufidx; /* Current location in buffer. */ 109static long tempbufidx; /* Current location in buffer. */
110static long tempbuf_size; /* Buffer size (TEMPBUF_SIZE). */ 110static size_t tempbuf_size; /* Buffer size (TEMPBUF_SIZE). */
111static long tempbuf_left; /* Buffer space left. */ 111static long tempbuf_left; /* Buffer space left. */
112static long tempbuf_pos; 112static long tempbuf_pos;
113 113
@@ -3089,9 +3089,7 @@ static void allocate_tempbuf(void)
3089 tempbuf_size = 32*1024*1024; 3089 tempbuf_size = 32*1024*1024;
3090 tempbuf = malloc(tempbuf_size); 3090 tempbuf = malloc(tempbuf_size);
3091#else 3091#else
3092 tempbuf = (char *)(((long)audiobuf & ~0x03) + 0x04); 3092 buffer_get_buffer(&tempbuf_size);
3093 tempbuf_size = (long)audiobufend - (long)audiobuf - 4;
3094 audiobuf += tempbuf_size;
3095#endif 3093#endif
3096} 3094}
3097 3095
@@ -3103,7 +3101,7 @@ static void free_tempbuf(void)
3103#ifdef __PCTOOL__ 3101#ifdef __PCTOOL__
3104 free(tempbuf); 3102 free(tempbuf);
3105#else 3103#else
3106 audiobuf -= tempbuf_size; 3104 buffer_release_buffer(0);
3107#endif 3105#endif
3108 tempbuf = NULL; 3106 tempbuf = NULL;
3109 tempbuf_size = 0; 3107 tempbuf_size = 0;