aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pipewire
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-12-02 03:32:10 +0900
committerOphestra <cat@gensokyo.uk>2025-12-02 03:32:10 +0900
commit39c6716fb0081249908433403c4da6298a4d12d3 (patch)
tree1a02994fd26f816ed575038c17f77e41c0177d65 /internal/pipewire
parent7bc73afaddc543bbc0e798b4e98b3e91ea289726 (diff)
internal/pipewire: use correct types in header
This was written when the protocol was still barely understood, so none of the types here are correct and match the rest of the protocol. This change corrects these types. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire')
-rw-r--r--internal/pipewire/header.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/pipewire/header.go b/internal/pipewire/header.go
index 89d50efa..40ea0805 100644
--- a/internal/pipewire/header.go
+++ b/internal/pipewire/header.go
@@ -22,14 +22,14 @@ 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 Word `json:"Id"`
+ ID Int `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 Word `json:"seq"`
+ Sequence Int `json:"seq"`
// Number of file descriptors in this message.
FileCount Word `json:"n_fds"`
}
@@ -38,9 +38,9 @@ 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, Word(h.ID))
data = binary.NativeEndian.AppendUint32(data, Word(h.Opcode)<<24|h.Size)
- data = binary.NativeEndian.AppendUint32(data, h.Sequence)
+ data = binary.NativeEndian.AppendUint32(data, Word(h.Sequence))
data = binary.NativeEndian.AppendUint32(data, h.FileCount)
return data
}
@@ -55,11 +55,11 @@ func (h *Header) MarshalBinary() (data []byte, err error) {
// unmarshalBinary decodes the protocol native message header.
func (h *Header) unmarshalBinary(data [SizeHeader]byte) {
- h.ID = binary.NativeEndian.Uint32(data[0:4])
+ h.ID = Int(binary.NativeEndian.Uint32(data[0:4]))
h.Size = binary.NativeEndian.Uint32(data[4:8])
h.Opcode = byte(h.Size >> 24)
h.Size &= SizeMax
- h.Sequence = binary.NativeEndian.Uint32(data[8:])
+ h.Sequence = Int(binary.NativeEndian.Uint32(data[8:]))
h.FileCount = binary.NativeEndian.Uint32(data[12:])
}