diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-12-11 04:07:55 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-12-11 04:07:55 +0900 |
| commit | 47db461546f355b971c3ca35d4dec48778c172ab (patch) | |
| tree | a2c0b6b761ea328dad85c3b3c329b8b393a546c2 /internal/pipewire/core.go | |
| parent | 0a3fe5f907d868f828f64c650e7a63a599e7ed68 (diff) | |
internal/pipewire: generic Core::Error handling
This flushes message buffer before queueing the event expecting the error. Since this is quite useful and relatively complex, it is relocated to a method of Context.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/core.go')
| -rw-r--r-- | internal/pipewire/core.go | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/internal/pipewire/core.go b/internal/pipewire/core.go index a53f02d5..d115da33 100644 --- a/internal/pipewire/core.go +++ b/internal/pipewire/core.go @@ -642,33 +642,28 @@ 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 { +func (registry *Registry) Destroy(id Int) (err error) { + asCoreError := registry.ctx.expectsCoreError(registry.ID, &err) + if err != nil { + return + } + if err = registry.destroy(id); err != nil { return err } - destroySeq := registry.ctx.currentSeq() - - err := registry.ctx.GetCore().Sync() - if err == nil { + if err = registry.ctx.GetCore().Sync(); 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 - } + if coreError := asCoreError(); coreError == nil { + return + } else { + switch syscall.Errno(-coreError.Result) { + case syscall.EPERM: + return &PermissionError{registry.ID, coreError.Message} - switch syscall.Errno(-coreError.Result) { - case syscall.EPERM: - return &PermissionError{registry.ID, coreError.Message} - - default: - return coreError + default: + return coreError + } } } |
