diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-11-25 15:11:22 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-11-25 15:11:22 +0900 |
| commit | 05391da5562db46d379f81145b461a0a4ad10c8d (patch) | |
| tree | a62448095244aae4e7322816538f3ce877b70bb7 | |
| parent | 463f8836e6ec44f73d72bc984240f2e179b3e5c1 (diff) | |
internal/pipewire: implement footer
The POD itself is serialised without requiring a special case, however its presence is only indicated by the difference in size recorded in the header and payload.
Signed-off-by: Ophestra <cat@gensokyo.uk>
| -rw-r--r-- | internal/pipewire/pod.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/pipewire/pod.go b/internal/pipewire/pod.go index e2e8b37a..811a77ae 100644 --- a/internal/pipewire/pod.go +++ b/internal/pipewire/pod.go @@ -386,6 +386,24 @@ func unmarshalCheckTypeBounds(data *[]byte, t Word, sizeP *Word) error { return nil } +// The Footer contains additional messages, not directed to +// the destination object defined by the Id field. +type Footer[T any] struct { + // The footer opcode. + Opcode Id + // The footer payload struct. + Payload T +} + +// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal]. +func (f *Footer[T]) MarshalBinary() ([]byte, error) { return Marshal(f) } + +// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal]. +func (f *Footer[T]) UnmarshalBinary(data []byte) error { + _, err := Unmarshal(data, f) + return err +} + // SPADictItem is an encoding-compatible representation of spa_dict_item. type SPADictItem struct{ Key, Value string } |
