beeper: better divider 0 handling

This commit is contained in:
minjaesong
2026-06-19 14:53:44 +09:00
parent 9b3d111c5f
commit 7782e19710

View File

@@ -605,12 +605,6 @@ private class Beeper {
var arpTick = 0L var arpTick = 0L
while (running) { while (running) {
try { try {
if (divider == 0) {
// Silent: stop feeding so the OpenAL source drains to quiet, then idle.
phase = 0.0; arpSample = 0; arpTick = 0L
Thread.sleep(4)
continue
}
for (i in 0 until CHUNK) { for (i in 0 until CHUNK) {
val div = divisorForTick(arpTick) val div = divisorForTick(arpTick)
if (div <= 0) { if (div <= 0) {
@@ -625,6 +619,13 @@ private class Beeper {
} }
// writeSamples blocks until a device buffer frees, pacing the loop in real time. // writeSamples blocks until a device buffer frees, pacing the loop in real time.
audioDevice?.writeSamples(buf, 0, CHUNK) audioDevice?.writeSamples(buf, 0, CHUNK)
if (divider == 0) {
// Silent: stop feeding so the OpenAL source drains to quiet, then idle.
phase = 0.0; arpSample = 0; arpTick = 0L
Thread.sleep(4)
continue
}
} }
catch (e: InterruptedException) { break } catch (e: InterruptedException) { break }
catch (e: Throwable) { catch (e: Throwable) {