aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pipewire/header.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-24 21:48:01 +0900
committerOphestra <cat@gensokyo.uk>2025-11-24 22:00:09 +0900
commit9f7b0c2f46305f8a321791d6fcedc3df7f966783 (patch)
treeb565a4a7d8e77f8f6717e46837f6b7d6ee174fc7 /internal/pipewire/header.go
parent3e87187c4c4eb43ed1c9dc1c0c6613e5bed1dc6c (diff)
internal/pipewire: add type constants
This change also centralises encoding testing. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/header.go')
-rw-r--r--internal/pipewire/header.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/internal/pipewire/header.go b/internal/pipewire/header.go
index ceb4cde6..99632208 100644
--- a/internal/pipewire/header.go
+++ b/internal/pipewire/header.go
@@ -22,16 +22,16 @@ var (
// A Header is the fixed-size message header described in protocol native.
type Header struct {
// The message id this is the destination resource/proxy id.
- ID uint32 `json:"Id"`
+ ID Uint `json:"Id"`
// The opcode on the resource/proxy interface.
Opcode byte `json:"opcode"`
// The size of the payload and optional footer of the message.
// Note: this value is only 24 bits long in the format.
Size uint32 `json:"size"`
// An increasing sequence number for each message.
- Sequence uint32 `json:"seq"`
+ Sequence Uint `json:"seq"`
// Number of file descriptors in this message.
- FileCount uint32 `json:"n_fds"`
+ FileCount Uint `json:"n_fds"`
}
// append appends the protocol native message header to data.
@@ -39,7 +39,7 @@ type Header struct {
// Callers must perform bounds check on [Header.Size].
func (h *Header) append(data []byte) []byte {
data = binary.NativeEndian.AppendUint32(data, h.ID)
- data = binary.NativeEndian.AppendUint32(data, uint32(h.Opcode)<<24|h.Size)
+ data = binary.NativeEndian.AppendUint32(data, Word(h.Opcode)<<24|h.Size)
data = binary.NativeEndian.AppendUint32(data, h.Sequence)
data = binary.NativeEndian.AppendUint32(data, h.FileCount)
return data