internal/pipewire: use sendmsg/recvmsg directly
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m41s
Test / Sandbox (race detector) (push) Successful in 4m46s
Test / Hakurei (push) Successful in 4m58s
Test / Hpkg (push) Successful in 5m4s
Test / Hakurei (race detector) (push) Successful in 6m32s
Test / Flake checks (push) Successful in 1m29s

The PipeWire protocol does not work with Go abstractions. This change makes relevant methods call sendmsg/recvmsg directly.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-12-06 01:51:57 +09:00
parent 0d3f332d45
commit 8a2f9edcf9
3 changed files with 232 additions and 181 deletions

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"strconv"
"time"
)
/* pipewire/core.h */
@@ -348,17 +349,28 @@ func (ctx *Context) coreSync(id Int) error {
// receiving a [CoreDone] event targeting the [CoreSync] event it delivered.
var ErrNotDone = errors.New("did not receive a Core::Done event targeting previously delivered Core::Sync")
const (
// syncTimeout is the maximum duration [Core.Sync] is allowed to take before
// receiving [CoreDone] or failing.
syncTimeout = 5 * time.Second
)
// Sync queues a [CoreSync] message for the PipeWire server and initiates a Roundtrip.
func (core *Core) Sync() error {
core.done = false
if err := core.ctx.coreSync(roundtripSyncID); err != nil {
return err
}
if err := core.ctx.Roundtrip(); err != nil {
return err
}
if !core.done {
return ErrNotDone
deadline := time.Now().Add(syncTimeout)
for !core.done {
if time.Now().After(deadline) {
return ErrNotDone
}
if err := core.ctx.Roundtrip(); err != nil {
return err
}
}
return nil
}