From ffbec828e17da38211e74499fb1fc537ec24bd1a Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sun, 14 Dec 2025 05:35:27 +0900 Subject: [PATCH] internal/pipewire: move Core wrapper methods under Core These do not belong under Context, and is an early implementation limitation that carried over. Signed-off-by: Ophestra --- internal/pipewire/core.go | 18 +++++++++--------- internal/pipewire/pipewire.go | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/pipewire/core.go b/internal/pipewire/core.go index ff13eab..80bd217 100644 --- a/internal/pipewire/core.go +++ b/internal/pipewire/core.go @@ -424,10 +424,10 @@ func (c *CoreHello) MarshalBinary() ([]byte, error) { return Marshal(c) } // UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal]. func (c *CoreHello) UnmarshalBinary(data []byte) error { return Unmarshal(data, c) } -// coreHello queues a [CoreHello] message for the PipeWire server. -// This method should not be called directly, the New function queues this message. -func (ctx *Context) coreHello() error { - return ctx.writeMessage( +// hello queues a [CoreHello] message for the PipeWire server. +// This method should not be called directly, the [New] function queues this message. +func (core *Core) hello() error { + return core.ctx.writeMessage( PW_ID_CORE, &CoreHello{PW_VERSION_CORE}, ) @@ -463,12 +463,12 @@ func (c *CoreSync) MarshalBinary() ([]byte, error) { return Marshal(c) } // UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal]. func (c *CoreSync) UnmarshalBinary(data []byte) error { return Unmarshal(data, c) } -// coreSync queues a [CoreSync] message for the PipeWire server. +// sync queues a [CoreSync] message for the PipeWire server. // This is not safe to use directly, callers should use Sync instead. -func (ctx *Context) coreSync(id Int) error { - return ctx.writeMessage( +func (core *Core) sync(id Int) error { + return core.ctx.writeMessage( PW_ID_CORE, - &CoreSync{id, CoreSyncSequenceOffset + Int(ctx.sequence)}, + &CoreSync{id, CoreSyncSequenceOffset + Int(core.ctx.sequence)}, ) } @@ -485,7 +485,7 @@ const ( // Sync queues a [CoreSync] message for the PipeWire server and initiates a Roundtrip. func (core *Core) Sync() error { core.done = false - if err := core.ctx.coreSync(roundtripSyncID); err != nil { + if err := core.sync(roundtripSyncID); err != nil { return err } deadline := time.Now().Add(syncTimeout) diff --git a/internal/pipewire/pipewire.go b/internal/pipewire/pipewire.go index 92a5dbc..35d380f 100644 --- a/internal/pipewire/pipewire.go +++ b/internal/pipewire/pipewire.go @@ -122,7 +122,7 @@ func New(conn Conn, props SPADict) (*Context, error) { } ctx.nextId = Int(len(ctx.proxy)) - if err := ctx.coreHello(); err != nil { + if err := ctx.core.hello(); err != nil { return nil, err } if err := ctx.clientUpdateProperties(props); err != nil {