1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Michael Sevakis 2011-12-05 13:58:35 +00:00
parent 6461f74ae4
commit 906905aa43
3 changed files with 13 additions and 20 deletions

View file

@ -22,6 +22,11 @@
#ifndef PCM_INTERNAL_H #ifndef PCM_INTERNAL_H
#define 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 struct pcm_peaks
{ {
long period; long period;

View file

@ -260,8 +260,7 @@ bool pcm_is_initialized(void)
/* Common code to pcm_play_data and pcm_play_pause */ /* Common code to pcm_play_data and pcm_play_pause */
static void pcm_play_data_start(unsigned char *start, size_t size) static void pcm_play_data_start(unsigned char *start, size_t size)
{ {
start = (unsigned char *)(((uintptr_t)start + 3) & ~3); ALIGN_AUDIOBUF(start, size);
size &= ~3;
if (!(start && size)) if (!(start && size))
{ {
@ -271,9 +270,7 @@ static void pcm_play_data_start(unsigned char *start, size_t size)
{ {
logf(" get_more"); logf(" get_more");
get_more(&start, &size); get_more(&start, &size);
ALIGN_AUDIOBUF(start, size);
start = (unsigned char *)(((uintptr_t)start + 3) & ~3);
size &= ~3;
} }
} }
@ -319,8 +316,7 @@ void pcm_play_get_more_callback(void **start, size_t *size)
/* Call registered callback */ /* Call registered callback */
get_more((unsigned char **)start, size); get_more((unsigned char **)start, size);
*start = (void *)(((uintptr_t)*start + 3) & ~3); ALIGN_AUDIOBUF(*start, *size);
*size &= ~3;
if (*start && *size) if (*start && *size)
return; return;
@ -557,9 +553,7 @@ void pcm_record_data(pcm_rec_callback_type more_ready,
{ {
logf("pcm_record_data"); logf("pcm_record_data");
/* 32-bit aligned and sized data only */ ALIGN_AUDIOBUF(start, size);
start = (void *)(((uintptr_t)start + 3) & ~3);
size &= ~3;
if (!(start && size)) if (!(start && size))
{ {
@ -611,8 +605,7 @@ void pcm_rec_more_ready_callback(int status, void **start, size_t *size)
if (have_more && start) if (have_more && start)
{ {
have_more(status, start, size); have_more(status, start, size);
*start = (void *)(((uintptr_t)*start + 3) & ~3); ALIGN_AUDIOBUF(*start, *size);
*size &= ~3;
if (*start && *size) if (*start && *size)
{ {

View file

@ -70,11 +70,6 @@ static struct mixer_channel * active_channels[PCM_MIXER_NUM_CHANNELS+1] IBSS_ATT
#define MAX_IDLE_FRAMES (NATIVE_FREQUENCY*3 / MIX_FRAME_SAMPLES) #define MAX_IDLE_FRAMES (NATIVE_FREQUENCY*3 / MIX_FRAME_SAMPLES)
static unsigned int idle_counter = 0; 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) #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
/* Include any implemented CPU-optimized mixdown routines */ /* Include any implemented CPU-optimized mixdown routines */
@ -244,7 +239,7 @@ fill_frame:
if (chan->get_more) if (chan->get_more)
{ {
chan->get_more(&chan->start, &chan->size); chan->get_more(&chan->start, &chan->size);
ALIGN_CHANNEL(chan->start, chan->size); ALIGN_AUDIOBUF(chan->start, chan->size);
} }
if (!(chan->start && chan->size)) if (!(chan->start && chan->size))
@ -368,7 +363,7 @@ static void mixer_channel_play_start(struct mixer_channel *chan,
{ {
pcm_play_unlock(); /* Allow playback while doing any callback */ pcm_play_unlock(); /* Allow playback while doing any callback */
ALIGN_CHANNEL(start, size); ALIGN_AUDIOBUF(start, size);
if (!(start && size)) if (!(start && size))
{ {
@ -377,7 +372,7 @@ static void mixer_channel_play_start(struct mixer_channel *chan,
if (get_more) if (get_more)
{ {
get_more(&start, &size); get_more(&start, &size);
ALIGN_CHANNEL(start, size); ALIGN_AUDIOBUF(start, size);
} }
} }