aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pipewire/pod.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-29 16:08:31 +0900
committerOphestra <cat@gensokyo.uk>2025-11-29 16:46:39 +0900
commitde3fc7ba381988c06fdbb0be8446b8e8d2e75af4 (patch)
tree10a00dee1a050b59b45ed8c8a875855fb471d169 /internal/pipewire/pod.go
parent5a5c4705dd47c7e27f49526b4ccf0d4c7c1bab5a (diff)
internal/pipewire: implement SecurityContext::Create
This is finally the thing we are after. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/pod.go')
-rw-r--r--internal/pipewire/pod.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/pipewire/pod.go b/internal/pipewire/pod.go
index 1abc821a..fe6c43ad 100644
--- a/internal/pipewire/pod.go
+++ b/internal/pipewire/pod.go
@@ -30,6 +30,9 @@ type (
String = string
// Bytes is a byte slice representing SPA_TYPE_Bytes.
Bytes = []byte
+
+ // A Fd is a signed integer value representing SPA_TYPE_Fd.
+ Fd Long
)
const (
@@ -49,6 +52,9 @@ const (
SizeInt Word = 4
// SizeLong is the fixed, unpadded size of a [SPA_TYPE_Long] value.
SizeLong Word = 8
+
+ // SizeFd is the fixed, unpadded size of a [SPA_TYPE_Fd] value.
+ SizeFd = SizeLong
)
/* Basic types */
@@ -176,6 +182,15 @@ 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) {
+ if v.CanInterface() {
+ switch c := v.Interface().(type) {
+ case Fd:
+ data = binary.NativeEndian.AppendUint32(data, SPA_TYPE_Fd)
+ data = binary.NativeEndian.AppendUint64(data, uint64(c))
+ return data, nil
+ }
+ }
+
switch v.Kind() {
case reflect.Uint32:
data = binary.NativeEndian.AppendUint32(data, SPA_TYPE_Id)
@@ -312,6 +327,16 @@ func unmarshalValue(data []byte, v reflect.Value, wireSizeP *Word) error {
*wireSizeP, err = u.UnmarshalPOD(data)
return err
}
+
+ switch v.Interface().(type) {
+ case Fd:
+ *wireSizeP = SizeFd
+ if err := unmarshalCheckTypeBounds(&data, SPA_TYPE_Fd, wireSizeP); err != nil {
+ return err
+ }
+ v.SetInt(int64(binary.NativeEndian.Uint64(data)))
+ return nil
+ }
}
switch v.Kind() {