aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pipewire/client.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-12-07 13:54:11 +0900
committerOphestra <cat@gensokyo.uk>2025-12-07 13:54:11 +0900
commitb9b9705b520cd3effaba3dc5e94c83e36f655bc4 (patch)
treeda70316f6ac5971746d526031592cd2bfcd11143 /internal/pipewire/client.go
parent246e04214a3554826be1f4285f56044b0850102d (diff)
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 <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/client.go')
-rw-r--r--internal/pipewire/client.go13
1 files changed, 12 insertions, 1 deletions
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},
)
}