diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2011-12-05 13:58:35 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2011-12-05 13:58:35 +0000 |
commit | 906905aa43566c16913238a71ccc13d438af1702 (patch) | |
tree | a80373f2495303db1245564bff5a5c66e9449473 | |
parent | 6461f74ae450ce0c834b3d4c7da134f0fefed945 (diff) | |
download | rockbox-906905aa43566c16913238a71ccc13d438af1702.tar.gz rockbox-906905aa43566c16913238a71ccc13d438af1702.zip |
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
-rw-r--r-- | firmware/export/pcm-internal.h | 5 | ||||
-rw-r--r-- | firmware/pcm.c | 17 | ||||
-rw-r--r-- | firmware/pcm_mixer.c | 11 |
3 files changed, 13 insertions, 20 deletions
diff --git a/firmware/export/pcm-internal.h b/firmware/export/pcm-internal.h index 16e2aeae4d..d881963ebd 100644 --- a/firmware/export/pcm-internal.h +++ b/firmware/export/pcm-internal.h | |||
@@ -22,6 +22,11 @@ | |||
22 | #ifndef PCM_INTERNAL_H | 22 | #ifndef PCM_INTERNAL_H |
23 | #define PCM_INTERNAL_H | 23 | #define PCM_INTERNAL_H |
24 | 24 | ||
25 | /* Cheapo buffer align macro to align to the 16-16 PCM size */ | ||
26 | #define ALIGN_AUDIOBUF(start, size) \ | ||
27 | ({ (start) = (void *)(((uintptr_t)(start) + 3) & ~3); \ | ||
28 | (size) &= ~3; }) | ||
29 | |||
25 | struct pcm_peaks | 30 | struct pcm_peaks |
26 | { | 31 | { |
27 | long period; | 32 | long period; |
diff --git a/firmware/pcm.c b/firmware/pcm.c index b0a91fb64e..f5efb4f84e 100644 --- a/firmware/pcm.c +++ b/firmware/pcm.c | |||
@@ -260,8 +260,7 @@ bool pcm_is_initialized(void) | |||
260 | /* Common code to pcm_play_data and pcm_play_pause */ | 260 | /* Common code to pcm_play_data and pcm_play_pause */ |
261 | static void pcm_play_data_start(unsigned char *start, size_t size) | 261 | static void pcm_play_data_start(unsigned char *start, size_t size) |
262 | { | 262 | { |
263 | start = (unsigned char *)(((uintptr_t)start + 3) & ~3); | 263 | ALIGN_AUDIOBUF(start, size); |
264 | size &= ~3; | ||
265 | 264 | ||
266 | if (!(start && size)) | 265 | if (!(start && size)) |
267 | { | 266 | { |
@@ -271,9 +270,7 @@ static void pcm_play_data_start(unsigned char *start, size_t size) | |||
271 | { | 270 | { |
272 | logf(" get_more"); | 271 | logf(" get_more"); |
273 | get_more(&start, &size); | 272 | get_more(&start, &size); |
274 | 273 | ALIGN_AUDIOBUF(start, size); | |
275 | start = (unsigned char *)(((uintptr_t)start + 3) & ~3); | ||
276 | size &= ~3; | ||
277 | } | 274 | } |
278 | } | 275 | } |
279 | 276 | ||
@@ -319,8 +316,7 @@ void pcm_play_get_more_callback(void **start, size_t *size) | |||
319 | /* Call registered callback */ | 316 | /* Call registered callback */ |
320 | get_more((unsigned char **)start, size); | 317 | get_more((unsigned char **)start, size); |
321 | 318 | ||
322 | *start = (void *)(((uintptr_t)*start + 3) & ~3); | 319 | ALIGN_AUDIOBUF(*start, *size); |
323 | *size &= ~3; | ||
324 | 320 | ||
325 | if (*start && *size) | 321 | if (*start && *size) |
326 | return; | 322 | return; |
@@ -557,9 +553,7 @@ void pcm_record_data(pcm_rec_callback_type more_ready, | |||
557 | { | 553 | { |
558 | logf("pcm_record_data"); | 554 | logf("pcm_record_data"); |
559 | 555 | ||
560 | /* 32-bit aligned and sized data only */ | 556 | ALIGN_AUDIOBUF(start, size); |
561 | start = (void *)(((uintptr_t)start + 3) & ~3); | ||
562 | size &= ~3; | ||
563 | 557 | ||
564 | if (!(start && size)) | 558 | if (!(start && size)) |
565 | { | 559 | { |
@@ -611,8 +605,7 @@ void pcm_rec_more_ready_callback(int status, void **start, size_t *size) | |||
611 | if (have_more && start) | 605 | if (have_more && start) |
612 | { | 606 | { |
613 | have_more(status, start, size); | 607 | have_more(status, start, size); |
614 | *start = (void *)(((uintptr_t)*start + 3) & ~3); | 608 | ALIGN_AUDIOBUF(*start, *size); |
615 | *size &= ~3; | ||
616 | 609 | ||
617 | if (*start && *size) | 610 | if (*start && *size) |
618 | { | 611 | { |
diff --git a/firmware/pcm_mixer.c b/firmware/pcm_mixer.c index 817b9a6a3c..25c41c2586 100644 --- a/firmware/pcm_mixer.c +++ b/firmware/pcm_mixer.c | |||
@@ -70,11 +70,6 @@ static struct mixer_channel * active_channels[PCM_MIXER_NUM_CHANNELS+1] IBSS_ATT | |||
70 | #define MAX_IDLE_FRAMES (NATIVE_FREQUENCY*3 / MIX_FRAME_SAMPLES) | 70 | #define MAX_IDLE_FRAMES (NATIVE_FREQUENCY*3 / MIX_FRAME_SAMPLES) |
71 | static unsigned int idle_counter = 0; | 71 | static unsigned int idle_counter = 0; |
72 | 72 | ||
73 | /* Cheapo buffer align macro to align to the 16-16 PCM size */ | ||
74 | #define ALIGN_CHANNEL(start, size) \ | ||
75 | ({ start = (void *)(((uintptr_t)start + 3) & ~3); \ | ||
76 | size &= ~3; }) | ||
77 | |||
78 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 73 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
79 | 74 | ||
80 | /* Include any implemented CPU-optimized mixdown routines */ | 75 | /* Include any implemented CPU-optimized mixdown routines */ |
@@ -244,7 +239,7 @@ fill_frame: | |||
244 | if (chan->get_more) | 239 | if (chan->get_more) |
245 | { | 240 | { |
246 | chan->get_more(&chan->start, &chan->size); | 241 | chan->get_more(&chan->start, &chan->size); |
247 | ALIGN_CHANNEL(chan->start, chan->size); | 242 | ALIGN_AUDIOBUF(chan->start, chan->size); |
248 | } | 243 | } |
249 | 244 | ||
250 | if (!(chan->start && chan->size)) | 245 | if (!(chan->start && chan->size)) |
@@ -368,7 +363,7 @@ static void mixer_channel_play_start(struct mixer_channel *chan, | |||
368 | { | 363 | { |
369 | pcm_play_unlock(); /* Allow playback while doing any callback */ | 364 | pcm_play_unlock(); /* Allow playback while doing any callback */ |
370 | 365 | ||
371 | ALIGN_CHANNEL(start, size); | 366 | ALIGN_AUDIOBUF(start, size); |
372 | 367 | ||
373 | if (!(start && size)) | 368 | if (!(start && size)) |
374 | { | 369 | { |
@@ -377,7 +372,7 @@ static void mixer_channel_play_start(struct mixer_channel *chan, | |||
377 | if (get_more) | 372 | if (get_more) |
378 | { | 373 | { |
379 | get_more(&start, &size); | 374 | get_more(&start, &size); |
380 | ALIGN_CHANNEL(start, size); | 375 | ALIGN_AUDIOBUF(start, size); |
381 | } | 376 | } |
382 | } | 377 | } |
383 | 378 | ||