internal/pipewire: specify opcode and file count with message
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m39s
Test / Sandbox (race detector) (push) Successful in 4m41s
Test / Hakurei (push) Successful in 4m56s
Test / Hpkg (push) Successful in 4m57s
Test / Hakurei (race detector) (push) Successful in 6m31s
Test / Flake checks (push) Successful in 1m30s

This adds checking of FileCount while writing a message. Message encoding is relocated to an exported method to be used externally, probably for test stubbing.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-12-07 13:54:11 +09:00
parent 246e04214a
commit b9b9705b52
5 changed files with 156 additions and 29 deletions

View File

@@ -46,6 +46,12 @@ type ClientInfo struct {
Properties *SPADict `json:"props"`
}
// Opcode satisfies [Message] with a constant value.
func (c *ClientInfo) Opcode() byte { return PW_CLIENT_EVENT_INFO }
// FileCount satisfies [Message] with a constant value.
func (c *ClientInfo) FileCount() Int { return 0 }
// Size satisfies [KnownSize] with a value computed at runtime.
func (c *ClientInfo) Size() Word {
return SizePrefix +
@@ -66,6 +72,12 @@ type ClientUpdateProperties struct {
Properties *SPADict `json:"props"`
}
// Opcode satisfies [Message] with a constant value.
func (c *ClientUpdateProperties) Opcode() byte { return PW_CLIENT_METHOD_UPDATE_PROPERTIES }
// FileCount satisfies [Message] with a constant value.
func (c *ClientUpdateProperties) FileCount() Int { return 0 }
// Size satisfies [KnownSize] with a value computed at runtime.
func (c *ClientUpdateProperties) Size() Word { return SizePrefix + c.Properties.Size() }
@@ -80,7 +92,6 @@ func (c *ClientUpdateProperties) UnmarshalBinary(data []byte) error { return Unm
func (ctx *Context) clientUpdateProperties(props SPADict) error {
return ctx.writeMessage(
PW_ID_CLIENT,
PW_CLIENT_METHOD_UPDATE_PROPERTIES,
&ClientUpdateProperties{&props},
)
}