diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-11-25 15:01:58 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-11-25 15:01:58 +0900 |
| commit | 2e465c94da7286a6f90dbcef032451ff0ae91deb (patch) | |
| tree | 6a09f641aaa081f9bdc2534c1c1c0299baa0b1bf /internal | |
| parent | 26009fd3f7ee6dae2b5e67d129089084de47d650 (diff) | |
internal/pipewire: implement Id type
This is, in fact, just a glorified Int type.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/pipewire/pod.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/pipewire/pod.go b/internal/pipewire/pod.go index ba7ac6f0..793a102c 100644 --- a/internal/pipewire/pod.go +++ b/internal/pipewire/pod.go @@ -16,6 +16,8 @@ type ( // A Bool is a boolean value representing SPA_TYPE_Bool. Bool = bool + // An Id is an enumerated value representing SPA_TYPE_Id. + Id = Word // An Int is a signed integer value representing SPA_TYPE_Int. Int = int32 // A Long is a signed integer value representing SPA_TYPE_Long. @@ -131,6 +133,10 @@ func marshalValueAppend(data []byte, v reflect.Value) ([]byte, error) { // marshalValueAppendRaw implements [MarshalAppend] on [reflect.Value] without the size prefix. func marshalValueAppendRaw(data []byte, v reflect.Value) ([]byte, error) { switch v.Kind() { + case reflect.Uint32: + data = binary.NativeEndian.AppendUint32(data, SPA_TYPE_Id) + data = binary.NativeEndian.AppendUint32(data, Word(v.Uint())) + return data, nil case reflect.Int32: data = binary.NativeEndian.AppendUint32(data, SPA_TYPE_Int) @@ -248,6 +254,13 @@ func unmarshalValue(data []byte, v reflect.Value, wireSizeP *Word) error { } switch v.Kind() { + case reflect.Uint32: + *wireSizeP = 4 + if err := unmarshalCheckTypeBounds(&data, SPA_TYPE_Id, wireSizeP); err != nil { + return err + } + v.SetUint(uint64(binary.NativeEndian.Uint32(data))) + return nil case reflect.Int32: *wireSizeP = 4 |
