diff options
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 |
