cellMusicDecode: fix random pop at the end of a stream

Observed in SSX, which seems to ignore the readSize sometimes
This commit is contained in:
Megamouse 2024-01-09 22:08:57 +01:00
parent b5f3f910f6
commit b67837c0ef
1 changed files with 6 additions and 0 deletions

View File

@ -227,6 +227,12 @@ error_code cell_music_decode_read(vm::ptr<void> buf, vm::ptr<u32> startTime, u64
std::memcpy(buf.get_ptr(), &dec.decoder.data[dec.read_pos], size_to_read);
if (size_to_read < reqSize)
{
// Set the rest of the buffer to zero to prevent loud pops at the end of the stream if the game ignores the readSize.
std::memset(vm::static_ptr_cast<u8>(buf).get_ptr() + size_to_read, 0, reqSize - size_to_read);
}
dec.read_pos += size_to_read;
s64 start_time_ms = 0;