internal/pipewire: respond to Core::Ping
All checks were successful
Test / Create distribution (push) Successful in 36s
Test / Sandbox (push) Successful in 2m39s
Test / Sandbox (race detector) (push) Successful in 4m41s
Test / Hpkg (push) Successful in 5m4s
Test / Hakurei (race detector) (push) Successful in 6m17s
Test / Hakurei (push) Successful in 4m11s
Test / Flake checks (push) Successful in 1m39s
All checks were successful
Test / Create distribution (push) Successful in 36s
Test / Sandbox (push) Successful in 2m39s
Test / Sandbox (race detector) (push) Successful in 4m41s
Test / Hpkg (push) Successful in 5m4s
Test / Hakurei (race detector) (push) Successful in 6m17s
Test / Hakurei (push) Successful in 4m11s
Test / Flake checks (push) Successful in 1m39s
There is currently no known message that will get the PipeWire server to emit this event. It should be handled regardless. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"maps"
|
||||
"slices"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -615,6 +616,14 @@ func (e *UnknownBoundIdError[E]) Error() string {
|
||||
return "unknown bound proxy id " + strconv.Itoa(int(e.Id))
|
||||
}
|
||||
|
||||
// An InvalidPingError is a [CorePing] event targeting a proxy id that was never allocated.
|
||||
type InvalidPingError CorePing
|
||||
|
||||
func (e *InvalidPingError) Error() string {
|
||||
return "received Core::Ping seq " + strconv.Itoa(int(e.Sequence)) +
|
||||
" targeting unknown proxy id " + strconv.Itoa(int(e.ID))
|
||||
}
|
||||
|
||||
func (core *Core) consume(opcode byte, files []int, unmarshal func(v any)) error {
|
||||
closeReceivedFiles(files...)
|
||||
switch opcode {
|
||||
@@ -637,6 +646,23 @@ func (core *Core) consume(opcode byte, files []int, unmarshal func(v any)) error
|
||||
// anything, and this behaviour is never mentioned in documentation
|
||||
return nil
|
||||
|
||||
case PW_CORE_EVENT_PING:
|
||||
var ping CorePing
|
||||
unmarshal(&ping)
|
||||
if _, ok := core.ctx.proxy[ping.ID]; ok {
|
||||
core.ctx.mustWriteMessage(PW_ID_CORE, (*CorePong)(&ping))
|
||||
return nil
|
||||
} else {
|
||||
invalidPingError := InvalidPingError(ping)
|
||||
core.ctx.mustWriteMessage(PW_ID_CORE, &CoreErrorMethod{CoreError{
|
||||
ID: PW_ID_CORE,
|
||||
Sequence: core.ctx.currentRemoteSeq(),
|
||||
Result: -Int(syscall.EINVAL),
|
||||
Message: invalidPingError.Error(),
|
||||
}})
|
||||
return &invalidPingError
|
||||
}
|
||||
|
||||
case PW_CORE_EVENT_ERROR:
|
||||
var coreError CoreError
|
||||
unmarshal(&coreError)
|
||||
|
||||
Reference in New Issue
Block a user