Documentation
¶
Index ¶
- type Buffer
- type BufferRing
- type Engine
- func (e *Engine) Close() error
- func (e *Engine) Next() error
- func (e *Engine) Pause() error
- func (e *Engine) Play(plist *Playlist, pos int) error
- func (e *Engine) Prev() error
- func (e *Engine) Seek(pos int, rel bool) error
- func (e *Engine) SetStatusHandler(h func(*Status))
- func (e *Engine) Start()
- func (e *Engine) Status() *Status
- func (e *Engine) Stop() error
- func (e *Engine) Volume(vol int) error
- type Event
- type Output
- type Player
- func (p *Player) Append(name string, path *vfs.Path) error
- func (p *Player) Clear(name string) error
- func (p *Player) Close() error
- func (p *Player) Create(name string) error
- func (p *Player) Delete(name string) error
- func (p *Player) Events() <-chan Event
- func (p *Player) Next() error
- func (p *Player) Pause() error
- func (p *Player) Play(path *vfs.Path) error
- func (p *Player) Playlist(name string) (*Playlist, error)
- func (p *Player) Playlists() []*Playlist
- func (p *Player) Prev() error
- func (p *Player) Rename(from string, to string) error
- func (p *Player) Seek(pos int, rel bool) error
- func (p *Player) SetVolume(vol int, rel bool) error
- func (p *Player) Status() *Status
- func (p *Player) Stop() error
- func (p *Player) Volume() int
- type Playlist
- func (pl *Playlist) Append(tracks ...*vfs.Track) *Playlist
- func (pl *Playlist) Clear() *Playlist
- func (pl *Playlist) Duration() int
- func (pl *Playlist) Get(i int) *vfs.Track
- func (pl *Playlist) Len() int
- func (pl *Playlist) Name() string
- func (pl *Playlist) Serialize() string
- func (pl *Playlist) SetName(name string) *Playlist
- func (pl *Playlist) Tracks() []*vfs.Track
- type PlistCreateEvent
- type PlistDeleteEvent
- type PlistRenameEvent
- type State
- type Status
- type StatusEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer contains piece of decoded PCM data with some metadata attached.
type BufferRing ¶
type BufferRing struct {
// contains filtered or unexported fields
}
BufferRing is a ring buffer organized by the list of fixed-size reusable buffers. BufferRing is a thread safe, however it is designed to work with only one writer and one reader. This schema suits well for audio decode-output loop when there is the only one decoder thread and one output thread that handles it.
func NewBufferRing ¶
func NewBufferRing(bufsz int, nbuf int) *BufferRing
NewBufferRing creates new BufferRing instance managing `nbuf` buffers of `bufsz` bytes each. So the total amount of data which can be stored equals to `bufsz * nbuf` bytes.
func (*BufferRing) Close ¶
func (r *BufferRing) Close(flush bool)
Close closes BufferRing. Consumer is still allowed to consume all data contained by BufferRing as usual. After that all next Peek() calls will return nil signalling end of the data. `flush` flag discards unconsumed data in the ring.
func (*BufferRing) Offer ¶
func (r *BufferRing) Offer(b *Buffer)
Offer marks buffer as containing data and available for the consumer. Panics if BufferRing is closed.
func (*BufferRing) OfferFree ¶
func (r *BufferRing) OfferFree(b *Buffer)
OfferFree marks buffer as free. After the buffer is freed it becomes available to be returned by PeekFree().
func (*BufferRing) Open ¶
func (r *BufferRing) Open()
Open opens BufferRing and make it available for the usage.
func (*BufferRing) Peek ¶
func (r *BufferRing) Peek() *Buffer
Peek returns the first non-emtpy buffer with data. If no buffer is available Peek blocks and waits for the one. Returns nil if cache is closed.
func (*BufferRing) PeekFree ¶
func (r *BufferRing) PeekFree() *Buffer
PeekFree returns the first empty buffer. If no empty buffer is available PeekFree blocks till it will become one. Retruns nil if BufferRing is closed.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is a core of playing process. It manages decoding source file and pass decoded samples to the output driver.
func (*Engine) SetStatusHandler ¶
type Event ¶
type Event interface {
Name() string
Serialize() []serialize.Serializable
}
type Output ¶
type Output interface {
// Open opens output audio device.
Open() error
// Set new value for sample rate parameter.
// TODO: Handle error by client.
SetSampleRate(rate int) error
// Set number of channels.
// TODO: Handle error by client.
SetChannels(channels int) error
// Write new portion of data into buffer.
Write(buf []byte) (written int, err error)
// Reset empties ouput buffer.
Flush() error
// Pause pauses or resumes playback process.
Pause() error
// Close closes output audio device.
Close() error
// Returns current volume level.
Volume() (int, error)
// Set output volume level.
SetVolume(vol int) error
}
Output interface represents audio autput driver (ALSA, OSS, ...).
type Playlist ¶
type Playlist struct {
// contains filtered or unexported fields
}
func NewPlaylist ¶
type PlistCreateEvent ¶
type PlistCreateEvent struct {
Plist string
}
func (*PlistCreateEvent) Name ¶
func (e *PlistCreateEvent) Name() string
func (*PlistCreateEvent) Serialize ¶
func (e *PlistCreateEvent) Serialize() []serialize.Serializable
type PlistDeleteEvent ¶
type PlistDeleteEvent struct {
Plist string
}
func (*PlistDeleteEvent) Name ¶
func (e *PlistDeleteEvent) Name() string
func (*PlistDeleteEvent) Serialize ¶
func (e *PlistDeleteEvent) Serialize() []serialize.Serializable
type PlistRenameEvent ¶
func (*PlistRenameEvent) Name ¶
func (e *PlistRenameEvent) Name() string
func (*PlistRenameEvent) Serialize ¶
func (e *PlistRenameEvent) Serialize() []serialize.Serializable
type StatusEvent ¶
type StatusEvent struct {
State State
Volume int
Plist *Playlist
PlistPos int
Track *vfs.Track
TrackPos int
}
func (*StatusEvent) Name ¶
func (e *StatusEvent) Name() string
func (*StatusEvent) Serialize ¶
func (e *StatusEvent) Serialize() []serialize.Serializable