hostbuf

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 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 hostbuf keeps decoded Linux pictures in memory: NV12 or P010 planes in memfd-backed mappings, which a Wayland compositor maps as wl_shm buffers with no copy, described by capture.DMABuf with Memory set.

Index

Constants

This section is empty.

Variables

View Source
var ErrExhausted = errors.New("hostbuf: every picture buffer is in use")

ErrExhausted is Get's error when every buffer is out.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	DMABuf capture.DMABuf
	// Luma and Chroma are the planes, rows of Pitch bytes.
	Luma, Chroma []byte
	Pitch        int
	// contains filtered or unexported fields
}

Buffer is one picture's memory. Its DMABuf stays valid, and its planes unchanged, until the pool gets it back.

func (*Buffer) Index

func (b *Buffer) Index() int

Index is b's place in its pool.

func (*Buffer) Mem

func (b *Buffer) Mem() []byte

Mem is b's whole mapping, luma then chroma.

type Pool

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

Pool hands out buffers of one size and layout, making more as all are out, up to its most.

func New

func New(fourcc uint32, width, height, most int) *Pool

New makes a pool of width x height pictures of fourcc (NV12 or P010) of at most most buffers.

func (*Pool) At

func (p *Pool) At(i int) *Buffer

At is the buffer of index i, as Buffer.Index tells it.

func (*Pool) Close

func (p *Pool) Close()

Close unmaps every buffer; none may be out.

func (*Pool) Get

func (p *Pool) Get() (*Buffer, error)

Get returns a free buffer, made if none is.

func (*Pool) Matches

func (p *Pool) Matches(fourcc uint32, width, height int) bool

Matches reports whether p holds pictures of this layout.

func (*Pool) Put

func (p *Pool) Put(b *Buffer)

Put gives b back.

Jump to

Keyboard shortcuts

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