From abb09c9d46335a0a61b0a666e7b4970187b5e958 Mon Sep 17 00:00:00 2001 From: funman Date: Wed, 23 Jun 2010 04:34:18 +0000 Subject: [PATCH] playback.c: don't assume cacheline size is 16 bytes ideally all targets should define CACHEALIGN_BITS, for now we default it to 16 bytes if it's not specified Since the buffer is already aligned in playback.c no need to align it again in buffering.c git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27073 a1c6a512-1295-4272-9138-f99709370657 --- apps/buffering.c | 3 +-- apps/playback.c | 12 ++++++------ firmware/export/system.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/buffering.c b/apps/buffering.c index c2cecddf0..489a4500c 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -1577,8 +1577,7 @@ bool buffering_reset(char *buf, size_t buflen) return false; buffer = buf; - /* Preserve alignment when wrapping around */ - buffer_len = STORAGE_ALIGN_DOWN(buflen); + buffer_len = buflen; guard_buffer = buf + buflen; buf_widx = 0; diff --git a/apps/playback.c b/apps/playback.c index 4a28a9d00..e8a6efc10 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1850,13 +1850,13 @@ static void audio_reset_buffer(void) /* Initially set up file buffer as all space available */ malloc_buf = audiobuf + talk_get_bufsize(); - /* Align the malloc buf to line size. Especially important to cf - targets that do line reads/writes. */ - malloc_buf = (unsigned char *)(((uintptr_t)malloc_buf + 15) & ~15); - filebuf = malloc_buf; /* filebuf line align implied */ - filebuflen = audiobufend - filebuf; - filebuflen &= ~15; + /* 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); /* Subtract whatever the pcm buffer says it used plus the guard buffer */ const size_t pcmbuf_size = pcmbuf_init(filebuf + filebuflen) +GUARD_BUFSIZE; diff --git a/firmware/export/system.h b/firmware/export/system.h index 7a04422b0..fe8121ce2 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h @@ -304,7 +304,7 @@ static inline void cpucache_flush(void) /* 2^CACHEALIGN_BITS = the byte size */ #define CACHEALIGN_SIZE (1u << CACHEALIGN_BITS) #else -#define CACHEALIGN_SIZE sizeof(int) +#define CACHEALIGN_SIZE 16 /* FIXME */ #endif #endif /* CACHEALIGN_SIZE */ -- 2.11.4.GIT