Documentation ¶
Overview ¶
Package track provides a beep.Streamer with real-time stream insertion.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SilenceError ¶ added in v1.1.0
type SilenceError struct { // Silence is the track's silence streamer. Silence beep.Streamer // contains filtered or unexported fields }
SilenceError is the error returned by Track.Err if the track's silence streamer fails to provide enough samples. It wraps the silence streamer's error if there is one.
func (*SilenceError) Error ¶ added in v1.1.0
func (err *SilenceError) Error() string
func (*SilenceError) Unwrap ¶ added in v1.3.0
func (err *SilenceError) Unwrap() error
Unwrap returns the wrapped error which was returned by the track's silence streamer after it closed.
type Track ¶
type Track struct {
// contains filtered or unexported fields
}
Track is a beep.StreamCloser which synchronously switches between a default streamer and a settable active streamer to provide a constantly playing stream.
The zero value of Track defaults to beep.Silence as its silence streamer.
func New ¶
New creates a track defaulting to silence and beginning with start as its active streamer. If silence is nil, a default silent stream is used. If start is nil, streaming begins with silence. silence must always fill any number of samples.
func (*Track) Close ¶
Close stops streamer playback. If there is an active streamer and it implements beep.StreamCloser, this additionally closes it. It is safe to call this concurrently with Stream, but the caller must ensure that there is no concurrent call to Set.
func (*Track) Err ¶
Err returns an error if the silence streamer failed to provide enough samples. The returned error is of type *SilenceError, and it wraps the silence streamer's error, if any. It does not propagate errors from any active streamers.
func (*Track) Interrupt ¶ added in v1.2.0
Interrupt stops the currently playing active streamer, if any. If the active streamer implements beep.StreamCloser, this additionally closes it. It is safe to call this concurrently with Stream and Set. The returned error is the error from closing the active streamer, if any.
func (*Track) Set ¶
Set sets the track's playing streamer. If the track is currently playing another streamer, this blocks until that streamer has finished. Panics if t is closed.
If stream is nil, Set performs all its normal blocking, but does not actually set a streamer. This allows callers to join on the completion of the current active streamer.
It is safe for any number of goroutines to call Set and for there to be at most one goroutine calling Stream concurrently.
func (*Track) Stream ¶
Stream returns samples from the track's active streamer, or from its default silence track if there is no active streamer. If all samples are streamed from the active streamer and the active streamer is a beep.StreamCloser, this additionally closes it. Panics if the silence streamer fails to stream all required samples.
It is not safe for multiple goroutines to call Stream concurrently, but any number of goroutines may call Set.