diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-12-11 03:34:33 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-12-11 03:34:33 +0900 |
| commit | 0a3fe5f907d868f828f64c650e7a63a599e7ed68 (patch) | |
| tree | 9cec0462e6ec4cddd8c4de1cbe27b0c0c860d97f /internal/pipewire/core.go | |
| parent | b72d502f1c5568cd8f93c9142247fa0d94caece5 (diff) | |
internal/pipewire: export Registry::Destroy
This handles the error returned by Sync.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/core.go')
| -rw-r--r-- | internal/pipewire/core.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/pipewire/core.go b/internal/pipewire/core.go index d2677818..a53f02d5 100644 --- a/internal/pipewire/core.go +++ b/internal/pipewire/core.go @@ -641,6 +641,37 @@ func (registry *Registry) destroy(id Int) error { ) } +// Destroy tries to destroy the global object with id. +func (registry *Registry) Destroy(id Int) error { + if err := registry.destroy(id); err != nil { + return err + } + destroySeq := registry.ctx.currentSeq() + + err := registry.ctx.GetCore().Sync() + if err == nil { + return nil + } + + var coreError *CoreError + if proxyErrors, ok := err.(ProxyConsumeError); !ok || + len(proxyErrors) != 1 || + !errors.As(proxyErrors[0], &coreError) || + coreError == nil || + coreError.ID != registry.ID || + coreError.Sequence != destroySeq { + return err + } + + switch syscall.Errno(-coreError.Result) { + case syscall.EPERM: + return &PermissionError{registry.ID, coreError.Message} + + default: + return coreError + } +} + // An UnsupportedObjectTypeError is the name of a type not known by the server [Registry]. type UnsupportedObjectTypeError string |
