Fix HDD audio cache provider when channels > 1

This commit is contained in:
arch1t3cht 2022-11-15 18:31:19 +01:00
parent 819d90e9b0
commit b3b4b96238

View file

@ -38,7 +38,7 @@ class HDAudioProvider final : public AudioProviderWrapper {
void FillBuffer(void *buf, int64_t start, int64_t count) const override {
auto missing = std::min(count, start + count - decoded_samples);
if (missing > 0) {
memset(static_cast<int16_t*>(buf) + count - missing, 0, missing * bytes_per_sample);
memset(static_cast<int16_t*>(buf) + count - missing, 0, missing * bytes_per_sample * channels);
count -= missing;
}
@ -69,7 +69,7 @@ public:
for (int64_t i = 0; i < num_samples; i += block) {
if (cancelled) break;
block = std::min(block, num_samples - i);
source->GetAudio(file.write(i * bytes_per_sample, block * bytes_per_sample), i, block);
source->GetAudio(file.write(i * bytes_per_sample * channels, block * bytes_per_sample * channels), i, block);
decoded_samples += block;
}
});