Open bradisbell opened 2 years ago
The problem also occurs on Node.js v16.15.1.
I've found that this problem doesn't occur as long as I have an output running too. It seems rtAudio.write()
must be called regularly for the input to work.
Using null
for the output options doesn't work, because calls to .write()
cause a crash.
I have almost the same exact same issue on Linux with PulseAudio. Based on your workaround I implemented a very dumb way of dealing with it after some experimentation.
// Start the stream
rtAudio.start();
setTimeout(() => {
try {
rtAudio.write(null);
} catch {
console.log("RTAudio fixed, enjoy your stream.");
}
})
Calling it once without setTimeout
does not work. Putting it in setTimeout
and the default 0ms timeout will make it work. I did not have to call it anymore after this.
I found out that it's not really related with the write
method, you can actually call isStreamOpen
or isStreamRunning
methods to keep it running. It almost feels like a reference counter or something that goes to zero if you don't reference it. I'm pretty sure it's about the C++ implementation of the binding.
Actually, even this worked for me:
// Not even calling the foo function, just declaring it.
const foo = () => {
recorder.isStreamOpen() // keeps the recorder stream running.
}
It's a Schrödinger's stream: if nobody is measuring if it's open or not, it declines to collapse its superposition into a concrete state of existence 🤣
I'm having trouble with the basic audio input example. The audio input callback stops being called after about 7 seconds. Some notes:
Any thoughts as to the cause of this and how it can be solved?