mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-19 19:04:05 +09:00
beeper: better divider 0 handling
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user