diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-12-13 21:49:28 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-12-13 21:50:32 +0900 |
| commit | b5999b88140eb437e87580848513dc1e74bc190b (patch) | |
| tree | b6c62904f056221b81653f17ae5f90957f5a0d6c /internal/pipewire/securitycontext.go | |
| parent | ebc67bb8ada03750eee60ab58c945b4745f22af1 (diff) | |
internal/pipewire: implement Core::RemoveId
This is emitted by the server when a proxy id is removed for any reason. Currently, the only path for this to be emitted is when a global object is destroyed while some proxy is still bound to it.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/securitycontext.go')
| -rw-r--r-- | internal/pipewire/securitycontext.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/internal/pipewire/securitycontext.go b/internal/pipewire/securitycontext.go index dbc3c529..ec28d753 100644 --- a/internal/pipewire/securitycontext.go +++ b/internal/pipewire/securitycontext.go @@ -26,9 +26,10 @@ const ( const ( PW_SECURITY_CONTEXT_METHOD_ADD_LISTENER = iota + PW_SECURITY_CONTEXT_METHOD_CREATE - PW_SECURITY_CONTEXT_METHOD_NUM + PW_SECURITY_CONTEXT_METHOD_NUM PW_VERSION_SECURITY_CONTEXT_METHODS = 0 ) @@ -90,6 +91,8 @@ type SecurityContext struct { GlobalID Int `json:"id"` ctx *Context + + removable } // GetSecurityContext queues a [RegistryBind] message for the PipeWire server @@ -109,6 +112,10 @@ func (registry *Registry) GetSecurityContext() (securityContext *SecurityContext // Create queues a [SecurityContextCreate] message for the PipeWire server. func (securityContext *SecurityContext) Create(listenFd, closeFd int, props SPADict) error { + if err := securityContext.checkDestroy(); err != nil { + return err + } + // queued in reverse based on upstream behaviour, unsure why offset := securityContext.ctx.queueFiles(closeFd, listenFd) return securityContext.ctx.writeMessage( @@ -144,6 +151,9 @@ func (scc *securityContextCloser) Close() (err error) { // BindAndCreate binds a new socket to the specified pathname and pass it to Create. // It returns an [io.Closer] corresponding to [SecurityContextCreate.CloseFd]. func (securityContext *SecurityContext) BindAndCreate(pathname string, props SPADict) (io.Closer, error) { + if err := securityContext.checkDestroy(); err != nil { + return nil, err + } var scc securityContextCloser // ensure pathname is available @@ -185,6 +195,7 @@ func (securityContext *SecurityContext) BindAndCreate(pathname string, props SPA } func (securityContext *SecurityContext) consume(opcode byte, files []int, _ func(v any)) error { + securityContext.mustCheckDestroy() closeReceivedFiles(files...) switch opcode { // SecurityContext does not receive any events @@ -196,6 +207,7 @@ func (securityContext *SecurityContext) consume(opcode byte, files []int, _ func } func (securityContext *SecurityContext) setBoundProps(event *CoreBoundProps) error { + securityContext.mustCheckDestroy() if securityContext.ID != event.ID { return &InconsistentIdError{Proxy: securityContext, ID: securityContext.ID, ServerID: event.ID} } |
