PcmSource - SocketSVC Docs
SocketSVC Docs

PcmSource

48 kHz, mono, signed 16-bit PCM.

Generated from source

Interface com.socketsvc.api.PcmSource — generated from PcmSource.java. Edit the Javadoc in the Java source, then run pnpm gen:api.

package com.socketsvc.api;

public interface PcmSource extends AutoCloseable { ... }

48 kHz, mono, signed 16-bit PCM. Called on a dedicated audio worker, never Bukkit's thread. Fill all 960 samples (20 ms); zero-pad the final partial frame. Return false at EOF. Reads must finish promptly and respond to interruption. Ownership transfers to play().

Methods

readFrame

boolean readFrame(short[] samples) throws Exception

pendingFrames

default int pendingFrames()

Whole frames already captured and waiting to be read, for a source backed by a real device; 0 for anything generated on demand, which by definition is never behind.

A caller that paces itself on a 20 ms timer needs this to tell "the device is keeping up" from "the device has a backlog". Reading one frame and then sleeping until the next tick carries a backlog forever rather than working it off, so whatever built up while the thread was descheduled becomes latency for as long as the source stays open.

close

default void close() throws Exception