Better click prevention
This commit is contained in:
parent
d43daed6a6
commit
36943866e2
13
Core/apu.c
13
Core/apu.c
@ -309,13 +309,14 @@ void GB_apu_copy_buffer(GB_gameboy_t *gb, GB_sample_t *dest, size_t count)
|
||||
|
||||
if (count > gb->apu_output.buffer_position) {
|
||||
// GB_log(gb, "Audio underflow: %d\n", count - gb->apu_output.buffer_position);
|
||||
if (gb->apu_output.buffer_position != 0) {
|
||||
GB_sample_t output = {0,0};
|
||||
for (unsigned i = GB_N_CHANNELS; i--;) {
|
||||
output.left += gb->apu_output.current_sample[i].left * CH_STEP;
|
||||
output.right += gb->apu_output.current_sample[i].right * CH_STEP;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < count - gb->apu_output.buffer_position; i++) {
|
||||
dest[gb->apu_output.buffer_position + i] = gb->apu_output.buffer[gb->apu_output.buffer_position - 1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
memset(dest + gb->apu_output.buffer_position, 0, (count - gb->apu_output.buffer_position) * sizeof(*gb->apu_output.buffer));
|
||||
dest[gb->apu_output.buffer_position + i] = output;
|
||||
}
|
||||
count = gb->apu_output.buffer_position;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user