From ff66409da5afaa1f3dc6366bcefa48584b04d6c1 Mon Sep 17 00:00:00 2001 From: jethead71 Date: Sun, 6 Mar 2011 02:03:37 +0000 Subject: [PATCH] Remove malloc_buf references from playback.c since it's no longer used for anything and align the codec slack space buffer that is now use as the malloc buffer. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29533 a1c6a512-1295-4272-9138-f99709370657 --- apps/codec_thread.c | 11 ++++++++--- apps/playback.c | 23 ++++++++--------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/apps/codec_thread.c b/apps/codec_thread.c index 6f15ba1fb..9b17d7cf4 100644 --- a/apps/codec_thread.c +++ b/apps/codec_thread.c @@ -193,10 +193,15 @@ void codec_thread_do_callback(void (*fn)(void), unsigned int *id) static void* codec_get_buffer(size_t *size) { - if (codec_size >= CODEC_SIZE) + ssize_t s = CODEC_SIZE - codec_size; + void *buf = &codecbuf[codec_size]; + ALIGN_BUFFER(buf, s, CACHEALIGN_SIZE); + + if (s <= 0) return NULL; - *size = CODEC_SIZE - codec_size; - return &codecbuf[codec_size]; + + *size = s; + return buf; } static void codec_pcmbuf_insert_callback( diff --git a/apps/playback.c b/apps/playback.c index 5ee5166cd..b72ed8a3b 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -116,7 +116,6 @@ static volatile bool paused SHAREDBSS_ATTR = false; /* Is audio paused? (A/C-) * /* Ring buffer where compressed audio and codecs are loaded */ static unsigned char *filebuf = NULL; /* Start of buffer (A/C-) */ -static unsigned char *malloc_buf = NULL; /* Start of malloc buffer (A/C-) */ static size_t filebuflen = 0; /* Size of buffer (A/C-) */ /* FIXME: make buf_ridx (C/A-) */ @@ -2014,26 +2013,21 @@ static void audio_reset_buffer(void) as it will likely be affected and need sliding over */ /* Initially set up file buffer as all space available */ - malloc_buf = audiobuf + talk_get_bufsize(); + filebuf = audiobuf + talk_get_bufsize(); + filebuflen = audiobufend - filebuf; - /* Align the malloc buf to line size. - * Especially important to cf targets that do line reads/writes. - * Also for targets which need aligned DMA storage buffers */ - malloc_buf = (unsigned char *)(((uintptr_t)malloc_buf + (CACHEALIGN_SIZE - 1)) & ~(CACHEALIGN_SIZE - 1)); - filebuf = malloc_buf; /* filebuf line align implied */ - filebuflen = (audiobufend - filebuf) & ~(CACHEALIGN_SIZE - 1); + ALIGN_BUFFER(filebuf, filebuflen, sizeof (intptr_t)); /* Subtract whatever the pcm buffer says it used plus the guard buffer */ - const size_t pcmbuf_size = pcmbuf_init(filebuf + filebuflen) +GUARD_BUFSIZE; + size_t pcmbuf_size = pcmbuf_init(filebuf + filebuflen) + GUARD_BUFSIZE; + + /* Make sure filebuflen is a pointer sized multiple after adjustment */ + pcmbuf_size = ALIGN_UP(pcmbuf_size, sizeof (intptr_t)); + if(pcmbuf_size > filebuflen) panicf("%s(): EOM (%zu > %zu)", __func__, pcmbuf_size, filebuflen); filebuflen -= pcmbuf_size; - - /* Make sure filebuflen is a longword multiple after adjustment - filebuf - will already be line aligned */ - filebuflen &= ~3; - buffering_reset(filebuf, filebuflen); /* Clear any references to the file buffer */ @@ -2046,7 +2040,6 @@ static void audio_reset_buffer(void) { size_t pcmbufsize; const unsigned char *pcmbuf = pcmbuf_get_meminfo(&pcmbufsize); - logf("mabuf: %08X", (unsigned)malloc_buf); logf("fbuf: %08X", (unsigned)filebuf); logf("fbufe: %08X", (unsigned)(filebuf + filebuflen)); logf("gbuf: %08X", (unsigned)(filebuf + filebuflen)); -- 2.11.4.GIT