Documentation
¶
Overview ¶
Package pulsetest is a fake PulseAudio server for tests: a unix socket speaking the native protocol's real frames, backed by a scriptable object model (sinks, sources, streams, defaults) that answers introspection, applies control commands, emits subscription events the way pulsecore does, serves record and playback streams, and can inject server errors, malformed frames, and disconnects.
Index ¶
- Constants
- func Sink(index uint32, name, desc string, monitor uint32) native.DeviceInfo
- func Source(index uint32, name, desc string, monitorOf uint32, monitorName string) native.DeviceInfo
- func StereoMap() native.ChannelMap
- func StereoSpec() native.SampleSpec
- type Play
- type Playback
- type Record
- type Server
- func (s *Server) Addr() string
- func (s *Server) Calls() []uint32
- func (s *Server) Card(index uint32) (native.CardInfo, bool)
- func (s *Server) Clients() int
- func (s *Server) Close()
- func (s *Server) Defaults() (sink, source string)
- func (s *Server) Disconnect()
- func (s *Server) Emit(ev native.SubscribeEvent)
- func (s *Server) FailNext(cmd uint32, code native.Error)
- func (s *Server) ForgetSamples()
- func (s *Server) Listen(t testing.TB)
- func (s *Server) Playbacks() []*Playback
- func (s *Server) Plays() []Play
- func (s *Server) PutCard(c native.CardInfo)
- func (s *Server) PutSink(d native.DeviceInfo)
- func (s *Server) PutSinkInput(st native.StreamInfo)
- func (s *Server) PutSource(d native.DeviceInfo)
- func (s *Server) PutSourceOutput(st native.StreamInfo)
- func (s *Server) Records() []*Record
- func (s *Server) RemoveSink(index uint32)
- func (s *Server) RemoveSinkInput(index uint32)
- func (s *Server) RemoveSource(index uint32)
- func (s *Server) RemoveSourceOutput(index uint32)
- func (s *Server) Samples() map[string]native.Sample
- func (s *Server) SendFrame(f native.Frame)
- func (s *Server) SendRaw(b []byte)
- func (s *Server) SetDefaults(sink, source string)
- func (s *Server) SetVersion(v uint32)
- func (s *Server) Sink(index uint32) (native.DeviceInfo, bool)
- func (s *Server) SinkInput(index uint32) (native.StreamInfo, bool)
- func (s *Server) Source(index uint32) (native.DeviceInfo, bool)
- func (s *Server) SourceOutput(index uint32) (native.StreamInfo, bool)
- func (s *Server) Uploads() int
- func (s *Server) WaitPlaybacks(t testing.TB, n int) []*Playback
- func (s *Server) WaitRecords(t testing.TB, n int) []*Record
Constants ¶
const DefaultVersion = 35
DefaultVersion is the protocol version the fake announces: PulseAudio 17 and pipewire-pulse both speak 35.
Variables ¶
This section is empty.
Functions ¶
func Sink ¶
func Sink(index uint32, name, desc string, monitor uint32) native.DeviceInfo
Sink is a running ALSA sink at 50% volume with two ports, whose monitor source has index monitor.
func Source ¶
func Source(index uint32, name, desc string, monitorOf uint32, monitorName string) native.DeviceInfo
Source is a suspended ALSA source at full volume; monitorOf and monitorName name the sink it monitors (InvalidIndex and "" for a real input).
func StereoMap ¶
func StereoMap() native.ChannelMap
StereoMap is the front-left/front-right channel map.
func StereoSpec ¶
func StereoSpec() native.SampleSpec
StereoSpec is the s16le 48 kHz stereo sample spec the fixtures use.
Types ¶
type Play ¶
Play is one PLAY_SAMPLE the fake answered: Sink is the sink it named, empty for the default one.
type Playback ¶
type Playback struct {
Channel uint32
SinkInput uint32
Sink string
SinkIndex uint32
SampleSpec native.SampleSpec
ChannelMap native.ChannelMap
TargetLength uint32
AdjustLatency bool
SyncID uint32
Props native.PropList
// contains filtered or unexported fields
}
Playback is one playback stream a client created. The fake grants the requested target length as the first request, then asks for more only through Request.
func (*Playback) Kill ¶
func (p *Playback) Kill()
Kill ends the stream from the server side (PLAYBACK_STREAM_KILLED).
type Record ¶
type Record struct {
Channel uint32
SourceOutput uint32
Source string
SourceIndex uint32
SampleSpec native.SampleSpec
ChannelMap native.ChannelMap
FragSize uint32
AdjustLatency bool
Props native.PropList
// contains filtered or unexported fields
}
Record is one record stream a client created.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the fake. Its methods are safe for concurrent use.
func New ¶
New starts a fake on a socket in a short per-test dir (sockdir: a long test name under CI's TMPDIR overflows sun_path); it shuts down with the test.
func (*Server) Close ¶
func (s *Server) Close()
Close stops accepting and drops every client: the server is down until Listen.
func (*Server) Disconnect ¶
func (s *Server) Disconnect()
Disconnect drops every client connection, and with each the record and playback streams its client created.
func (*Server) Emit ¶
func (s *Server) Emit(ev native.SubscribeEvent)
Emit sends a subscription event to every client subscribed to its facility.
func (*Server) ForgetSamples ¶
func (s *Server) ForgetSamples()
ForgetSamples empties the cache, as a server restart does.
func (*Server) Listen ¶
Listen brings a closed server back on the same socket, its devices, defaults and the streams the test put kept, as a restarted sound server; the streams clients created went with their connections.
func (*Server) PutSink ¶
func (s *Server) PutSink(d native.DeviceInfo)
PutSink adds or replaces a sink, announcing it to subscribers.
func (*Server) PutSinkInput ¶
func (s *Server) PutSinkInput(st native.StreamInfo)
PutSinkInput adds or replaces a playback stream.
func (*Server) PutSource ¶
func (s *Server) PutSource(d native.DeviceInfo)
PutSource adds or replaces a source.
func (*Server) PutSourceOutput ¶
func (s *Server) PutSourceOutput(st native.StreamInfo)
PutSourceOutput adds or replaces a recording stream.
func (*Server) RemoveSink ¶
RemoveSink drops a sink and announces the removal.
func (*Server) RemoveSinkInput ¶
RemoveSinkInput drops a playback stream.
func (*Server) RemoveSource ¶
RemoveSource drops a source.
func (*Server) RemoveSourceOutput ¶
RemoveSourceOutput drops a recording stream.
func (*Server) SetDefaults ¶
SetDefaults names the default sink and source (empty for none) and announces a server change.
func (*Server) SetVersion ¶
SetVersion changes the protocol version later handshakes announce.
func (*Server) Sink ¶
func (s *Server) Sink(index uint32) (native.DeviceInfo, bool)
Sink snapshots one sink.
func (*Server) SinkInput ¶
func (s *Server) SinkInput(index uint32) (native.StreamInfo, bool)
SinkInput snapshots one playback stream.
func (*Server) Source ¶
func (s *Server) Source(index uint32) (native.DeviceInfo, bool)
Source snapshots one source.
func (*Server) SourceOutput ¶
func (s *Server) SourceOutput(index uint32) (native.StreamInfo, bool)
SourceOutput snapshots one recording stream.
func (*Server) WaitPlaybacks ¶
WaitPlaybacks waits until n playback streams are live and returns them.