Use a macro for aligning PCM chunks instead of explictly coding it each time.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31152 a1c6a512-1295-4272-9138-f99709370657
diff --git a/firmware/export/pcm-internal.h b/firmware/export/pcm-internal.h
index 16e2aea..d881963 100644
--- a/firmware/export/pcm-internal.h
+++ b/firmware/export/pcm-internal.h
@@ -22,6 +22,11 @@
#ifndef PCM_INTERNAL_H
#define PCM_INTERNAL_H
+/* Cheapo buffer align macro to align to the 16-16 PCM size */
+#define ALIGN_AUDIOBUF(start, size) \
+ ({ (start) = (void *)(((uintptr_t)(start) + 3) & ~3); \
+ (size) &= ~3; })
+
struct pcm_peaks
{
long period;
diff --git a/firmware/pcm.c b/firmware/pcm.c
index b0a91fb..f5efb4f 100644
--- a/firmware/pcm.c
+++ b/firmware/pcm.c
@@ -260,8 +260,7 @@
/* Common code to pcm_play_data and pcm_play_pause */
static void pcm_play_data_start(unsigned char *start, size_t size)
{
- start = (unsigned char *)(((uintptr_t)start + 3) & ~3);
- size &= ~3;
+ ALIGN_AUDIOBUF(start, size);
if (!(start && size))
{
@@ -271,9 +270,7 @@
{
logf(" get_more");
get_more(&start, &size);
-
- start = (unsigned char *)(((uintptr_t)start + 3) & ~3);
- size &= ~3;
+ ALIGN_AUDIOBUF(start, size);
}
}
@@ -319,8 +316,7 @@
/* Call registered callback */
get_more((unsigned char **)start, size);
- *start = (void *)(((uintptr_t)*start + 3) & ~3);
- *size &= ~3;
+ ALIGN_AUDIOBUF(*start, *size);
if (*start && *size)
return;
@@ -557,9 +553,7 @@
{
logf("pcm_record_data");
- /* 32-bit aligned and sized data only */
- start = (void *)(((uintptr_t)start + 3) & ~3);
- size &= ~3;
+ ALIGN_AUDIOBUF(start, size);
if (!(start && size))
{
@@ -611,8 +605,7 @@
if (have_more && start)
{
have_more(status, start, size);
- *start = (void *)(((uintptr_t)*start + 3) & ~3);
- *size &= ~3;
+ ALIGN_AUDIOBUF(*start, *size);
if (*start && *size)
{
diff --git a/firmware/pcm_mixer.c b/firmware/pcm_mixer.c
index 817b9a6..25c41c2 100644
--- a/firmware/pcm_mixer.c
+++ b/firmware/pcm_mixer.c
@@ -70,11 +70,6 @@
#define MAX_IDLE_FRAMES (NATIVE_FREQUENCY*3 / MIX_FRAME_SAMPLES)
static unsigned int idle_counter = 0;
-/* Cheapo buffer align macro to align to the 16-16 PCM size */
-#define ALIGN_CHANNEL(start, size) \
- ({ start = (void *)(((uintptr_t)start + 3) & ~3); \
- size &= ~3; })
-
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
/* Include any implemented CPU-optimized mixdown routines */
@@ -244,7 +239,7 @@
if (chan->get_more)
{
chan->get_more(&chan->start, &chan->size);
- ALIGN_CHANNEL(chan->start, chan->size);
+ ALIGN_AUDIOBUF(chan->start, chan->size);
}
if (!(chan->start && chan->size))
@@ -368,7 +363,7 @@
{
pcm_play_unlock(); /* Allow playback while doing any callback */
- ALIGN_CHANNEL(start, size);
+ ALIGN_AUDIOBUF(start, size);
if (!(start && size))
{
@@ -377,7 +372,7 @@
if (get_more)
{
get_more(&start, &size);
- ALIGN_CHANNEL(start, size);
+ ALIGN_AUDIOBUF(start, size);
}
}