diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/jsyn/engine/SynthesisEngine.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/com/jsyn/engine/SynthesisEngine.java b/src/com/jsyn/engine/SynthesisEngine.java index ae16405..c79083e 100644 --- a/src/com/jsyn/engine/SynthesisEngine.java +++ b/src/com/jsyn/engine/SynthesisEngine.java @@ -319,8 +319,11 @@ public class SynthesisEngine implements Synthesizer { } loadAnalyzer = new LoadAnalyzer(); while (go) { + boolean throttled = false; if (audioInputStream != null) { + // This call will block when the input is empty. audioInputStream.read(inputBuffer.interleavedBuffer); + throttled = true; } loadAnalyzer.start(); @@ -331,6 +334,10 @@ public class SynthesisEngine implements Synthesizer { if (audioOutputStream != null) { // This call will block when the output is full. audioOutputStream.write(outputBuffer.interleavedBuffer); + throttled = true; + } + if (!throttled && isRealTime()) { + Thread.sleep(2); // avoid spinning and eating up CPU } } |