sequentially-read-a-file as js module

This commit is contained in:
minjaesong
2023-01-08 16:23:50 +09:00
parent ca39263131
commit 132c31bda5
7 changed files with 237 additions and 290 deletions

View File

@@ -38,11 +38,15 @@ private class RenderRunnable(val playhead: AudioAdapter.Playhead) : Runnable {
// printdbg("P${playhead.index+1} go back to spinning")
Thread.sleep(2)
Thread.sleep(12)
}
else if (playhead.isPlaying && writeQueue.isEmpty) {
printdbg("Queue exhausted, stopping audio device...")
playhead.audioDevice.stop()
// TODO: wait for 1-2 seconds then finally stop the device
// playhead.audioDevice.stop()
Thread.sleep(12)
}
}
@@ -77,6 +81,10 @@ private class WriteQueueingRunnable(val playhead: AudioAdapter.Playhead, val pcm
it.position += 1
Thread.sleep(6)
}
else if (it.pcmUpload) {
printdbg("Rejecting samples (queueSize: ${it.pcmQueue.size}, uploadLength: ${it.pcmUploadLength})")
Thread.sleep(6)
}
}
Thread.sleep(1)
@@ -394,7 +402,7 @@ class AudioAdapter(val vm: VM) : PeriBase {
}
}
fun getPcmQueueCapacity() = QUEUE_SIZE[pcmQueueSizeIndex]
fun getPcmQueueCapacity() = 2147483647//QUEUE_SIZE[pcmQueueSizeIndex]
fun dispose() {
println("AudioDevice dispose ${parent.renderThreads[index]}")