From b9b9705b520cd3effaba3dc5e94c83e36f655bc4 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sun, 7 Dec 2025 13:54:11 +0900 Subject: internal/pipewire: specify opcode and file count with message 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 --- internal/pipewire/client.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'internal/pipewire/client.go') diff --git a/internal/pipewire/client.go b/internal/pipewire/client.go index 8e901d8e..faa114b9 100644 --- a/internal/pipewire/client.go +++ b/internal/pipewire/client.go @@ -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}, ) } -- cgit v1.3.1