Decoder interface for audio format decoding. Decode takes a context.Context as its first argument so callers can cancel a long-running or stalled decode (e.g. an MP3 source whose underlying reader has hung). The MP3 decoder polls ctx between read chunks; WAV and AIFF check ctx at entry (they alread
| 37 | // The interface is internal to package audio — there are no external |
| 38 | // importers — so adding the parameter is safe. |
| 39 | type Decoder interface { |
| 40 | // Decode reads audio data from reader and returns decoded PCM data. |
| 41 | // If ctx is cancelled, Decode returns ctx.Err(). |
| 42 | Decode(ctx context.Context, reader io.Reader) (*AudioData, error) |
| 43 | |
| 44 | // CanDecode checks if this decoder can handle the given filename |
| 45 | CanDecode(filename string) bool |
| 46 | |
| 47 | // FormatName returns the name of the format this decoder handles |
| 48 | FormatName() string |
| 49 | } |
no outgoing calls
no test coverage detected