client

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package client provides the client-side functionality for Gophercast.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDisconnected = errors.New("disconnected")
	ErrRejected     = errors.New("rejected")
)

Sentinel errors for clean shutdown handling.

Functions

This section is empty.

Types

type AudioClient

type AudioClient struct {
	// contains filtered or unexported fields
}

AudioClient connects to a GopherCast server and plays audio.

func NewAudioClient

func NewAudioClient(serverURL, name string, sink AudioSink, latencyOverride time.Duration) (*AudioClient, error)

NewAudioClient dials the server and sends a hello. Pass latencyOverride > 0 to skip auto-detection.

func (*AudioClient) Close

func (c *AudioClient) Close()

func (*AudioClient) Start

func (c *AudioClient) Start() error

type AudioSink

type AudioSink interface {
	Init(sampleRate, channels int) error
	Write(p []byte) (int, error)
	Close() error
	// Latency is how long it takes from writing PCM to hearing it out the speaker.
	Latency() time.Duration
}

AudioSink is the interface for audio output backends.

type FileSink

type FileSink struct {
	// contains filtered or unexported fields
}

FileSink writes raw PCM audio data to a file. Mostly useful for debugging.

func NewFileSink

func NewFileSink(path string) *FileSink

func (*FileSink) Close

func (s *FileSink) Close() error

func (*FileSink) Init

func (s *FileSink) Init(sampleRate, channels int) error

func (*FileSink) Latency

func (s *FileSink) Latency() time.Duration

func (*FileSink) Write

func (s *FileSink) Write(p []byte) (int, error)

type SystemAudioSink

type SystemAudioSink struct {
	// contains filtered or unexported fields
}

SystemAudioSink plays PCM audio through the system audio output using oto.

func NewSystemAudioSink

func NewSystemAudioSink() *SystemAudioSink

func (*SystemAudioSink) Close

func (s *SystemAudioSink) Close() error

func (*SystemAudioSink) Init

func (s *SystemAudioSink) Init(sampleRate, channels int) error

func (*SystemAudioSink) Latency

func (s *SystemAudioSink) Latency() time.Duration

func (*SystemAudioSink) Write

func (s *SystemAudioSink) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL