fix: fix mpg123_read() read_size_bytes

This commit is contained in:
2026-03-22 23:27:07 +01:00
parent e8afb10f48
commit 45b1003c9a

View File

@@ -273,7 +273,8 @@ void PlaybackEngine::musicFeedThread() {
}
size_t done = 0; // bytes!
int err = mpg123_read(musicFile->handle, cbuf, cbuf_size_bytes, &done);
size_t read_size_bytes = std::min(num_samples * num_ch_in * sizeof(int16_t), cbuf_size_bytes);
int err = mpg123_read(musicFile->handle, cbuf, read_size_bytes, &done);
musicFile->remaining_samples -= done / sizeof(int16_t);
musicFile->offset = 0; // unused here
if (err != MPG123_OK && err != MPG123_DONE) {