aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pipewire/pod.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-12-02 03:06:27 +0900
committerOphestra <cat@gensokyo.uk>2025-12-02 03:06:27 +0900
commit647aa9d02fb275c47ae00c552977d42013888a6b (patch)
treedbba67377be4ace06939a4f845852c6395829694 /internal/pipewire/pod.go
parent91aaabaa1b48b870d4e818e3651b7c6bc3b182fb (diff)
internal/pipewire: preallocate for footer
This is useful during serialisation. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/pod.go')
-rw-r--r--internal/pipewire/pod.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/pipewire/pod.go b/internal/pipewire/pod.go
index fe6c43ad..88a49e82 100644
--- a/internal/pipewire/pod.go
+++ b/internal/pipewire/pod.go
@@ -468,11 +468,18 @@ func unmarshalCheckTypeBounds(data *[]byte, t Word, sizeP *Word) error {
// The Footer contains additional messages, not directed to
// the destination object defined by the Id field.
-type Footer[T any] struct {
+type Footer[P KnownSize] struct {
// The footer opcode.
Opcode Id `json:"opcode"`
// The footer payload struct.
- Payload T `json:"payload"`
+ Payload P `json:"payload"`
+}
+
+// Size satisfies [KnownSize] with a usually compile-time known value.
+func (f *Footer[P]) Size() Word {
+ return SizePrefix +
+ Size(SizeId) +
+ f.Payload.Size()
}
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].