pwtest

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pwtest starts a private PipeWire daemon for tests, so producers and consumers link without touching the user's session, and runs libpipewire consumers against it as the reference a producer is checked by.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serial

func Serial(t testing.TB, id uint32) uint64

Serial is the object.serial the server's registry lists for global id, as pw-dump reads it.

func WithPods

func WithPods(pods [][]byte, call func(params unsafe.Pointer, n uint32) int32) int32

WithPods hands C an array of pointers to the pods, pinned for the call (libpipewire copies the params).

Types

type Bitmap

type Bitmap struct {
	Format, Width, Height uint32
	Stride                int32
}

Bitmap is a cursor meta's bitmap: a 0 x 0 one hides the pointer.

type Buffer

type Buffer struct {
	// Size is the chunk's size: 0 for a buffer that holds no frame.
	Size uint32
	// Corrupted is the chunk's SPA_CHUNK_FLAG_CORRUPTED.
	Corrupted bool
	// Seq is the header meta's sequence number: a buffer dequeued again
	// without the producer queueing it anew carries the same one.
	Seq uint64
	// Cursor is the cursor meta, nil when the buffers have none.
	Cursor *Cursor
}

Buffer is what one dequeued buffer carried.

type Consumer

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

Consumer is a reference consumer: a libpipewire input stream, linked to a node's first output port, asking for the header and cursor metas as screen recorders do, and reporting every buffer it dequeues.

func Consume

func Consume(t *testing.T, node string) *Consumer

Consume connects a reference consumer offering any size of BGRx video and links node's output_0 to it with pw-link. The daemon must be running; the consumer goes away with the test.

func (*Consumer) Buffer

func (c *Consumer) Buffer(t *testing.T) Buffer

Buffer waits for the next buffer.

func (*Consumer) Frame

func (c *Consumer) Frame(t *testing.T) uint32

Frame waits for the next buffer that holds a frame and returns its size.

type Cursor

type Cursor struct {
	ID                 uint32
	X, Y               int32
	HotspotX, HotspotY int32
	// Bitmap is the bitmap the meta carried, nil when it carried none.
	Bitmap *Bitmap
}

Cursor is a cursor meta: an ID of 0 is no news.

type Daemon

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

Daemon is a private pipewire a test runs.

func Start

func Start(t *testing.T) *Daemon

Start runs a private pipewire for the test and points the client library at it. A missing pipewire fails the test: the dev shell provides one.

func (*Daemon) Kill

func (d *Daemon) Kill()

Kill ends the daemon at once, as a crash would, and reaps it.

type Lib

type Lib struct {
	PropertiesNew    func(s string) uintptr
	StreamNewSimple  func(loop uintptr, name string, props uintptr, events unsafe.Pointer, data uintptr) uintptr
	StreamConnect    func(stream uintptr, direction, target, flags uint32, params unsafe.Pointer, n uint32) int32
	StreamDisconnect func(stream uintptr) int32
	StreamDestroy    func(stream uintptr)
	StreamUpdate     func(stream uintptr, params unsafe.Pointer, n uint32) int32
	StreamDequeue    func(stream uintptr) unsafe.Pointer
	StreamQueue      func(stream uintptr, buffer unsafe.Pointer) int32
	// contains filtered or unexported fields
}

Lib is libpipewire bound through purego: the reference implementation the tests' consumers run on, so the producer is checked against the library every other PipeWire client uses.

func Load

func Load() (*Lib, error)

Load binds libpipewire and initializes it, once per process.

func (*Lib) StartLoop

func (l *Lib) StartLoop() (*Loop, error)

StartLoop starts a loop thread.

type Loop

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

Loop runs one pw_loop on a goroutine locked to its OS thread, and every libpipewire call of its streams happens there: stream events arrive on a Go thread, inside iterate, which purego's cgo-less callbacks need.

func (*Loop) Do

func (t *Loop) Do(fn func())

Do runs fn on the loop thread and waits for it.

func (*Loop) Handle

func (t *Loop) Handle() uintptr

Handle is the loop for StreamNewSimple.

func (*Loop) Stop

func (t *Loop) Stop()

Stop ends the loop once its queued work ran.

Jump to

Keyboard shortcuts

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