diff options
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 | { |