sclass OpusMachine implements IF0_Int, AutoCloseable { new ByteArraysPartialInputStream buffer; new ArraysShortStream sampleStream; OpusFromStream opusDecoder; int channels = 1; void init() ctex { opusDecoder = new OpusFromStream(buffer, channels); } close {} bool pullFromDecoder() ctex { while ping (true) { short[] samples; if ((samples = opusDecoder.nextSamples()) != null) ret true with sampleStream.add(samples); if (!pullFromSource()) false; // end of stuff // we got new material from source, decode again } } bool pullFromSource() { ret fillBuffer(); } swappable bool fillBuffer() { false; } // get next sample (pull mode) public int get() { int sample; while ping ((sample = sampleStream.read()) == Int.MAX_VALUE) { if (!pullFromDecoder()) ret Int.MAX_VALUE; } ret sample; } }