diff options
author | Andreas Claesson <andreas.claesson@gmail.com> | 2005-05-25 15:25:59 +0000 |
---|---|---|
committer | Andreas Claesson <andreas.claesson@gmail.com> | 2005-05-25 15:25:59 +0000 |
commit | af30dfbe847477360a1c86418a6f5a63aabdc8e4 (patch) | |
tree | 7e4aa1f8129eed939db71f93e8505196a52744a6 /src/pcm_utils.c | |
parent | 84808afcd92c85f6d9f434aa93f5b92c98548f1c (diff) | |
download | mpd-af30dfbe847477360a1c86418a6f5a63aabdc8e4.tar.gz mpd-af30dfbe847477360a1c86418a6f5a63aabdc8e4.tar.xz mpd-af30dfbe847477360a1c86418a6f5a63aabdc8e4.zip |
Fixing faulty check in pcm_volumeChange and fixed some warnings.
git-svn-id: https://svn.musicpd.org/mpd/branches/ancl@3287 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/pcm_utils.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/pcm_utils.c b/src/pcm_utils.c index 9e816e00d..e92089f31 100644 --- a/src/pcm_utils.c +++ b/src/pcm_utils.c @@ -236,8 +236,8 @@ void pcm_volumeChange(char * buffer, int bufferSize, AudioFormat * format, int samples; int shift; - if(format->bits!=32 || format->channels!=2) { - ERROR("Only 32 bit stereo is supported for pcm_volumeChange!\n"); + if(format->bits!=32 || format->fracBits == 0) { + ERROR("Only 32 bit mpd_fixed_t samples are supported in pcm_volumeChange!\n"); exit(EXIT_FAILURE); } @@ -261,12 +261,16 @@ void pcm_volumeChange(char * buffer, int bufferSize, AudioFormat * format, } /* change */ if(iScale == 1) { - while(samples--) - *buffer32++ = *buffer32 >> shift; + while(samples--) { + *buffer32 = *buffer32 >> shift; + buffer32++; + } } else { - while(samples--) - *buffer32++ = (*buffer32 >> shift) * iScale; + while(samples--) { + *buffer32 = (*buffer32 >> shift) * iScale; + buffer32++; + } } } @@ -283,8 +287,8 @@ void pcm_add(char * buffer1, char * buffer2, size_t bufferSize1, int iScale2; int shift; - if(format->bits!=32 || format->channels!=2 ) { - ERROR("Only 32 bit stereo is supported for pcm_add!\n"); + if(format->bits!=32 || format->fracBits==0 ) { + ERROR("Only 32 bit mpd_fixed_t samples are supported in pcm_add!\n"); exit(EXIT_FAILURE); } @@ -297,8 +301,10 @@ void pcm_add(char * buffer1, char * buffer2, size_t bufferSize1, /* scale and add samples */ /* no check for overflow needed - we trust our headroom is enough */ while(samples1 && samples2) { - *buffer32_1++ = (*buffer32_1 >> shift) * iScale1 + + temp = (*buffer32_1 >> shift) * iScale1 + (*buffer32_2 >> shift) * iScale2; + *buffer32_1++ = temp; + buffer32_2++; } /* take care of case where buffer2 > buffer1 */ if(samples2) memcpy(buffer32_1,buffer32_2,samples2<<2); |