# PcmSource

48 kHz, mono, signed 16-bit PCM.

Source: https://socketsvc.vercel.app/zh-TW/api/shared/PcmSource
<Callout title="Generated from source">
  Interface `com.socketsvc.api.PcmSource` — generated from [PcmSource.java](https://github.com/HippoDev03/SocketSVC/blob/main/common/core/src/main/java/com/socketsvc/api/PcmSource.java). Edit the Javadoc in the Java source, then run `pnpm gen:api`.
</Callout>

```java
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

```java
boolean readFrame(short[] samples) throws Exception
```

### pendingFrames

```java
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

```java
default void close() throws Exception
```