aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Claesson <andreas.claesson@gmail.com>2005-05-25 15:25:59 +0000
committerAndreas Claesson <andreas.claesson@gmail.com>2005-05-25 15:25:59 +0000
commitaf30dfbe847477360a1c86418a6f5a63aabdc8e4 (patch)
tree7e4aa1f8129eed939db71f93e8505196a52744a6 /src
parent84808afcd92c85f6d9f434aa93f5b92c98548f1c (diff)
downloadmpd-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.c24
-rw-r--r--src/replayGain.c14
2 files changed, 24 insertions, 14 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);
diff --git a/src/replayGain.c b/src/replayGain.c
index d0de774a0..ace70b0e5 100644
--- a/src/replayGain.c
+++ b/src/replayGain.c
@@ -155,12 +155,16 @@ void doReplayGain(ReplayGainInfo * info, char * buffer, int bufferSize,
/* no check for overflow needed - replaygain peak info prevent
* clipping and we have 3 headroom bits in our 32 bit samples */
if(iScale == 1) {
- while(samples--)
- *buffer32++ = *buffer32 >> shift;
+ while(samples--) {
+ *buffer32 = *buffer32 >> shift;
+ buffer32++;
+ }
}
- else {
- while(samples--)
- *buffer32++ = (*buffer32 >> shift) * iScale;
+ else {
+ while(samples--) {
+ *buffer32 = (*buffer32 >> shift) * iScale;
+ buffer32++;
+ }
}
}