diff options
author | 2011-01-24 21:45:43 +0100 | |
---|---|---|
committer | 2011-01-24 21:45:43 +0100 | |
commit | 69aef2ab97fcb38e83527510c758ba3e5916f924 (patch) | |
tree | 45aacb039a4d9d0de406b4bda4844b6feca60871 /plugins/mpgmad | |
parent | 7f34f84a31375eea905004cc412bbc434649d06e (diff) |
fixed spinlock bug on mono mp3s
Diffstat (limited to 'plugins/mpgmad')
-rw-r--r-- | plugins/mpgmad/mpgmad.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c index ced16e79..6c49e760 100644 --- a/plugins/mpgmad/mpgmad.c +++ b/plugins/mpgmad/mpgmad.c @@ -781,6 +781,8 @@ cmp3_decode_requested_int16 (mpgmad_info_t *info) { cmp3_skip (info); // copy synthesized samples into readbuffer int idx = info->synth.pcm.length-info->buffer.decode_remaining; + + // stereo if (MAD_NCHANNELS(&info->frame.header) == 2 && info->info.fmt.channels == 2) { while (info->buffer.decode_remaining > 0 && info->buffer.readsize > 0) { *((int16_t*)info->buffer.out) = MadFixedToSshort (info->synth.pcm.samples[0][idx]); @@ -793,6 +795,16 @@ cmp3_decode_requested_int16 (mpgmad_info_t *info) { idx++; } } + // mono + else if (MAD_NCHANNELS(&info->frame.header) == 1 && info->info.fmt.channels == 1){ + while (info->buffer.decode_remaining > 0 && info->buffer.readsize > 0) { + *((int16_t*)info->buffer.out) = MadFixedToSshort (info->synth.pcm.samples[0][idx]); + info->buffer.readsize -= 2; + info->buffer.out += 2; + info->buffer.decode_remaining--; + idx++; + } + } // workaround for bad mp3s that have both mono and stereo frames else if (MAD_NCHANNELS(&info->frame.header) == 1 && info->info.fmt.channels == 2) { while (info->buffer.decode_remaining > 0 && info->buffer.readsize > 0) { |