Skip to content

Commit 9ff3bff

Browse files
committed
Fix thread assertion in GB_set_sample_rate, should make GB_set_clock_multiplier thread-safe. Fix missing memset.
1 parent 1285968 commit 9ff3bff

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Core/apu.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ static void __attribute__((constructor)) band_limited_init(void)
1313
{
1414
const unsigned master_size = GB_BAND_LIMITED_WIDTH * GB_BAND_LIMITED_PHASES;
1515
double *master = malloc(master_size * sizeof(*master));
16+
memset(master, 0, master_size * sizeof(*master));
1617

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

17531754
void GB_set_sample_rate(GB_gameboy_t *gb, unsigned sample_rate)
17541755
{
1755-
GB_ASSERT_NOT_RUNNING_OTHER_THREAD(gb)
1756+
if (gb->apu_output.sample_rate != sample_rate) {
1757+
GB_ASSERT_NOT_RUNNING_OTHER_THREAD(gb)
1758+
}
17561759
gb->apu_output.sample_rate = sample_rate;
17571760
if (sample_rate) {
17581761
gb->apu_output.highpass_rate = pow(0.999958, GB_get_clock_rate(gb) / (double)sample_rate);

0 commit comments

Comments
 (0)