aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/pipewire/core.go33
-rw-r--r--internal/pipewire/core_test.go17
2 files changed, 50 insertions, 0 deletions
diff --git a/internal/pipewire/core.go b/internal/pipewire/core.go
index fc3edd4e..eec62da3 100644
--- a/internal/pipewire/core.go
+++ b/internal/pipewire/core.go
@@ -608,6 +608,39 @@ func (registry *Registry) bind(proxy eventProxy, id, version Int) (Int, error) {
)
}
+// RegistryDestroy is sent to try to destroy the global object with id.
+// This might fail when the client does not have permission.
+type RegistryDestroy struct {
+ // The global id to destroy.
+ ID Int `json:"id"`
+}
+
+// Opcode satisfies [Message] with a constant value.
+func (c *RegistryDestroy) Opcode() byte { return PW_REGISTRY_METHOD_DESTROY }
+
+// FileCount satisfies [Message] with a constant value.
+func (c *RegistryDestroy) FileCount() Int { return 0 }
+
+// Size satisfies [KnownSize] with a constant value.
+func (c *RegistryDestroy) Size() Word {
+ return SizePrefix +
+ Size(SizeInt)
+}
+
+// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].
+func (c *RegistryDestroy) MarshalBinary() ([]byte, error) { return Marshal(c) }
+
+// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal].
+func (c *RegistryDestroy) UnmarshalBinary(data []byte) error { return Unmarshal(data, c) }
+
+// destroy queues a [RegistryDestroy] message for the PipeWire server.
+func (registry *Registry) destroy(id Int) error {
+ return registry.ctx.writeMessage(
+ registry.ID,
+ &RegistryDestroy{id},
+ )
+}
+
// An UnsupportedObjectTypeError is the name of a type not known by the server [Registry].
type UnsupportedObjectTypeError string
diff --git a/internal/pipewire/core_test.go b/internal/pipewire/core_test.go
index 42b18b98..f9e5f09d 100644
--- a/internal/pipewire/core_test.go
+++ b/internal/pipewire/core_test.go
@@ -774,3 +774,20 @@ func TestRegistryBind(t *testing.T) {
}, nil},
}.run(t)
}
+
+func TestRegistryDestroy(t *testing.T) {
+ t.Parallel()
+
+ encodingTestCases[pipewire.RegistryDestroy, *pipewire.RegistryDestroy]{
+ {"sample", []byte{
+ /* size: rest of data*/ 0x10, 0, 0, 0,
+ /* type: Struct */ 0xe, 0, 0, 0,
+ /* size: 4 bytes */ 4, 0, 0, 0,
+ /* type: Int */ 4, 0, 0, 0,
+ /* value: 0xbad */ 0xad, 0xb, 0, 0,
+ /* padding */ 0, 0, 0, 0,
+ }, pipewire.RegistryDestroy{
+ ID: 0xbad,
+ }, nil},
+ }.run(t)
+}