fix computation of conversion buffer size
git-svn-id: https://svn.musicpd.org/mpd/trunk@974 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
4f76ba5a42
commit
5b4a0a1821
|
@ -255,17 +255,36 @@ size_t pcm_sizeOfOutputBufferForAudioFormatConversion(AudioFormat * inFormat,
|
||||||
char * inBuffer, size_t inSize, AudioFormat * outFormat)
|
char * inBuffer, size_t inSize, AudioFormat * outFormat)
|
||||||
{
|
{
|
||||||
const int shift = sizeof(mpd_sint16);
|
const int shift = sizeof(mpd_sint16);
|
||||||
mpd_uint32 nlen = (((inSize >> shift) *
|
size_t outSize = inSize;
|
||||||
(mpd_uint32)(outFormat->sampleRate)) /
|
|
||||||
|
switch(inFormat->bits) {
|
||||||
|
case 8:
|
||||||
|
outSize = outSize << 1;
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERROR("only 8 or 16 bits are supported for conversion!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(inFormat->channels) {
|
||||||
|
case 1:
|
||||||
|
outSize = (outSize >> 1) << 2;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERROR("only 1 or 2 channels are supported for conversion!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
outSize = (((outSize >> shift) * (mpd_uint32)(outFormat->sampleRate)) /
|
||||||
inFormat->sampleRate);
|
inFormat->sampleRate);
|
||||||
|
|
||||||
nlen <<= shift;
|
outSize <<= shift;
|
||||||
|
|
||||||
|
return outSize;
|
||||||
assert(outFormat->bits==16);
|
|
||||||
assert(outFormat->channels==2);
|
|
||||||
|
|
||||||
return nlen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=8 tabstop=8 expandtab: */
|
/* vim:set shiftwidth=8 tabstop=8 expandtab: */
|
||||||
|
|
Loading…
Reference in New Issue