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