diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2008-03-30 10:11:31 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2008-03-30 10:11:31 +0000 |
commit | 21870cfd9bd4778ea3b69ff0090292df14c49641 (patch) | |
tree | 2d1ebb62656d3b7316664c7f44ee389d52bc14d1 /apps | |
parent | 63acf3eb167cab7722e61e857a109b718ff2b561 (diff) | |
download | rockbox-21870cfd9bd4778ea3b69ff0090292df14c49641.tar.gz rockbox-21870cfd9bd4778ea3b69ff0090292df14c49641.zip |
Fixes FS#8651 (noise and/or crash while crossfading). Latest ARM-asm submit for dsp showed we had a possible alignment issue with pcm-buffer when using crossfade.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16890 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/pcmbuf.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index 8f16c90523..99a440ad6b 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c | |||
@@ -687,13 +687,20 @@ static size_t crossfade_fade_mix(int factor, const char *buf, size_t fade_rem) | |||
687 | int16_t *output_buf = (int16_t *)(crossfade_chunk->addr); | 687 | int16_t *output_buf = (int16_t *)(crossfade_chunk->addr); |
688 | int16_t *chunk_end = SKIPBYTES(output_buf, crossfade_chunk->size); | 688 | int16_t *chunk_end = SKIPBYTES(output_buf, crossfade_chunk->size); |
689 | output_buf = &output_buf[crossfade_sample]; | 689 | output_buf = &output_buf[crossfade_sample]; |
690 | int32_t sample; | ||
690 | 691 | ||
691 | while (fade_rem) | 692 | while (fade_rem) |
692 | { | 693 | { |
693 | int32_t sample = *input_buf++; | 694 | /* fade left and right channel at once to keep buffer alignment */ |
695 | sample = *input_buf++; | ||
694 | sample = ((sample * factor) >> 8) + *output_buf; | 696 | sample = ((sample * factor) >> 8) + *output_buf; |
695 | *output_buf++ = clip_sample_16(sample); | 697 | *output_buf++ = clip_sample_16(sample); |
696 | fade_rem -= 2; | 698 | |
699 | sample = *input_buf++; | ||
700 | sample = ((sample * factor) >> 8) + *output_buf; | ||
701 | *output_buf++ = clip_sample_16(sample); | ||
702 | |||
703 | fade_rem -= 4; /* 2 samples, each 16 bit -> 4 bytes */ | ||
697 | 704 | ||
698 | if (output_buf >= chunk_end) | 705 | if (output_buf >= chunk_end) |
699 | { | 706 | { |
@@ -715,12 +722,18 @@ static size_t crossfade_mix(const char *buf, size_t length) | |||
715 | int16_t *output_buf = (int16_t *)crossfade_chunk->addr; | 722 | int16_t *output_buf = (int16_t *)crossfade_chunk->addr; |
716 | int16_t *chunk_end = SKIPBYTES(output_buf, crossfade_chunk->size); | 723 | int16_t *chunk_end = SKIPBYTES(output_buf, crossfade_chunk->size); |
717 | output_buf = &output_buf[crossfade_sample]; | 724 | output_buf = &output_buf[crossfade_sample]; |
725 | int32_t sample; | ||
718 | 726 | ||
719 | while (length) | 727 | while (length) |
720 | { | 728 | { |
721 | int32_t sample = *input_buf++ + *output_buf; | 729 | /* fade left and right channel at once to keep buffer alignment */ |
730 | sample = *input_buf++ + *output_buf; | ||
731 | *output_buf++ = clip_sample_16(sample); | ||
732 | |||
733 | sample = *input_buf++ + *output_buf; | ||
722 | *output_buf++ = clip_sample_16(sample); | 734 | *output_buf++ = clip_sample_16(sample); |
723 | length -= 2; | 735 | |
736 | length -= 4; /* 2 samples, each 16 bit -> 4 bytes */ | ||
724 | 737 | ||
725 | if (output_buf >= chunk_end) | 738 | if (output_buf >= chunk_end) |
726 | { | 739 | { |