From: nishi Date: Sat, 15 Jun 2024 14:03:55 +0000 (+0000) Subject: fixed set_max_polyphony X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=33f39f6a0206904cb0ccdc4c4fc09103be88b96f;p=ksynth.git fixed set_max_polyphony git-svn-id: file:///raid/svn-main/kazu-ksynth/trunk@47 7b47e76f-e598-2f43-bc14-414d160cc389 --- diff --git a/src/ksynth.c b/src/ksynth.c index d8e165f..514b59a 100644 --- a/src/ksynth.c +++ b/src/ksynth.c @@ -321,17 +321,18 @@ bool ksynth_set_max_polyphony(struct KSynth* ksynth_instance, unsigned int max_p struct Voice** old_ptr = ksynth_instance->voices; unsigned long old_count = ksynth_instance->max_polyphony; + ksynth_instance->max_polyphony = max_polyphony; struct Voice** new_ptr = int_allocate_voices(ksynth_instance); if(new_ptr != NULL) { - ksynth_note_off_all(ksynth_instance); - ksynth_instance->voices = new_ptr; - ksynth_instance->max_polyphony = max_polyphony; + + ksynth_note_off_all(ksynth_instance); int_free_voices(old_ptr, old_count); return true; } + ksynth_instance->max_polyphony = old_count; fprintf(stderr, "[KSynth] Error: Failed to allocate memory for voices.\n"); return false;