Attempt to improve audio quality on frontend with big audio buffers

This commit is contained in:
Lior Halphon 2018-07-10 21:33:03 +03:00
parent dc4c23c0da
commit 5f58323c01
1 changed files with 8 additions and 0 deletions

View File

@ -417,6 +417,14 @@ void GB_apu_copy_buffer(GB_gameboy_t *gb, GB_sample_t *dest, size_t count)
dest[gb->apu_output.buffer_position + i] = output;
}
if (gb->apu_output.buffer_position) {
if (gb->apu_output.buffer_size + (count - gb->apu_output.buffer_position) < count * 3) {
gb->apu_output.buffer_size += count - gb->apu_output.buffer_position;
gb->apu_output.buffer = realloc(gb->apu_output.buffer,
gb->apu_output.buffer_size * sizeof(*gb->apu_output.buffer));
gb->apu_output.stream_started = false;
}
}
count = gb->apu_output.buffer_position;
}
memcpy(dest, gb->apu_output.buffer, count * sizeof(*gb->apu_output.buffer));