SB16: Send (sample count, less 1) to the DSP, not the number of bytes.

This worked fine when we were using 8-bit samples but broke on 16-bit.
This commit is contained in:
Andreas Kling 2019-07-13 17:47:57 +02:00
parent 781a28f3ed
commit d63b6e624e
Notes: sideshowbarker 2024-07-19 13:18:06 +09:00

View File

@ -174,14 +174,19 @@ ssize_t SB16::write(FileDescription&, const u8* data, ssize_t length)
dma_start(length);
u8 command = 0x06;
// Send 16-bit samples.
command |= 0xb0;
u16 sample_count = length / sizeof(i16);
if (mode & (u8)SampleFormat::Stereo)
sample_count /= 2;
sample_count -= 1;
dsp_write(command);
dsp_write(mode);
dsp_write((u8)length);
dsp_write((u8)(length >> 8));
dsp_write((u8)sample_count);
dsp_write((u8)(sample_count >> 8));
enable_irq();
wait_for_irq();