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
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user