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/securitycontext.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'internal/pipewire/securitycontext.go') diff --git a/internal/pipewire/securitycontext.go b/internal/pipewire/securitycontext.go index f07d5dc9..107fe994 100644 --- a/internal/pipewire/securitycontext.go +++ b/internal/pipewire/securitycontext.go @@ -61,6 +61,12 @@ type SecurityContextCreate struct { Properties *SPADict `json:"props"` } +// Opcode satisfies [Message] with a constant value. +func (c *SecurityContextCreate) Opcode() byte { return PW_SECURITY_CONTEXT_METHOD_CREATE } + +// FileCount satisfies [Message] with a constant value. +func (c *SecurityContextCreate) FileCount() Int { return 2 } + // Size satisfies [KnownSize] with a value computed at runtime. func (c *SecurityContextCreate) Size() Word { return SizePrefix + @@ -106,7 +112,6 @@ func (securityContext *SecurityContext) Create(listenFd, closeFd int, props SPAD offset := securityContext.ctx.queueFiles(closeFd, listenFd) return securityContext.ctx.writeMessage( securityContext.ID, - PW_SECURITY_CONTEXT_METHOD_CREATE, &SecurityContextCreate{ListenFd: offset + 1, CloseFd: offset + 0, Properties: &props}, ) } -- cgit v1.3.1