Skip to content

Commit

Permalink
Fix thread assertion in GB_set_sample_rate, should make GB_set_clock_…
Browse files Browse the repository at this point in the history
…multiplier thread-safe. Fix missing memset.
  • Loading branch information
LIJI32 committed Nov 29, 2024
1 parent 1285968 commit 9ff3bff
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Core/apu.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ static void __attribute__((constructor)) band_limited_init(void)
{
const unsigned master_size = GB_BAND_LIMITED_WIDTH * GB_BAND_LIMITED_PHASES;
double *master = malloc(master_size * sizeof(*master));
memset(master, 0, master_size * sizeof(*master));

const unsigned sine_size = 256 * GB_BAND_LIMITED_PHASES + 2;
const unsigned max_harmonic = sine_size / 2 / GB_BAND_LIMITED_PHASES;
Expand Down Expand Up @@ -1752,7 +1753,9 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value)

void GB_set_sample_rate(GB_gameboy_t *gb, unsigned sample_rate)
{
GB_ASSERT_NOT_RUNNING_OTHER_THREAD(gb)
if (gb->apu_output.sample_rate != sample_rate) {
GB_ASSERT_NOT_RUNNING_OTHER_THREAD(gb)
}
gb->apu_output.sample_rate = sample_rate;
if (sample_rate) {
gb->apu_output.highpass_rate = pow(0.999958, GB_get_clock_rate(gb) / (double)sample_rate);
Expand Down

0 comments on commit 9ff3bff

Please sign in to comment.