core: Fix bug in PcmDecoder::next
It looks like the mono and stereo cases were mistakenly swapped for 8-bit sounds. This commit simply swaps them to the correct order.
This commit is contained in:
parent
6d38eacf09
commit
e74e115cd0
|
@ -35,10 +35,11 @@ impl<R: Read> Iterator for PcmDecoder<R> {
|
|||
let right = i16::from_le_bytes(right);
|
||||
Some([left, right])
|
||||
} else {
|
||||
let mut bytes = [0u8];
|
||||
let mut bytes = [0u8; 2];
|
||||
self.inner.read_exact(&mut bytes).ok()?;
|
||||
let sample = (i16::from(bytes[0]) - 127) * 128;
|
||||
Some([sample, sample])
|
||||
let left = (i16::from(bytes[0]) - 127) * 128;
|
||||
let right = (i16::from(bytes[1]) - 127) * 128;
|
||||
Some([left, right])
|
||||
}
|
||||
} else if self.is_16_bit {
|
||||
let mut bytes = [0u8; 2];
|
||||
|
@ -46,11 +47,10 @@ impl<R: Read> Iterator for PcmDecoder<R> {
|
|||
let sample = i16::from_le_bytes(bytes);
|
||||
Some([sample, sample])
|
||||
} else {
|
||||
let mut bytes = [0u8; 2];
|
||||
let mut bytes = [0u8];
|
||||
self.inner.read_exact(&mut bytes).ok()?;
|
||||
let left = (i16::from(bytes[0]) - 127) * 128;
|
||||
let right = (i16::from(bytes[1]) - 127) * 128;
|
||||
Some([left, right])
|
||||
let sample = (i16::from(bytes[0]) - 127) * 128;
|
||||
Some([sample, sample])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue