aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pipewire/core.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-29 23:23:19 +0900
committerOphestra <cat@gensokyo.uk>2025-11-29 23:25:29 +0900
commit4fd6d6c037b30b02aff861542721b0cc40f083fe (patch)
tree1677c4cc52e4d6d84b43d5aaebb1a5c7e61c28b8 /internal/pipewire/core.go
parentde3fc7ba381988c06fdbb0be8446b8e8d2e75af4 (diff)
internal/pipewire: implement Core::Ping, Core::Pong
I could not get the server to produce these events, however I am confident enough with the implementation to do it by hand. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/core.go')
-rw-r--r--internal/pipewire/core.go40
1 files changed, 38 insertions, 2 deletions
diff --git a/internal/pipewire/core.go b/internal/pipewire/core.go
index 7c2b4a90..99e4137e 100644
--- a/internal/pipewire/core.go
+++ b/internal/pipewire/core.go
@@ -136,7 +136,7 @@ type CoreDone struct {
// Passed from [CoreSync.ID].
ID Int `json:"id"`
// Passed from [CoreSync.Sequence].
- Sequence Int `json:"sequence"`
+ Sequence Int `json:"seq"`
}
// Size satisfies [KnownSize] with a constant value.
@@ -148,6 +148,25 @@ func (c *CoreDone) MarshalBinary() ([]byte, error) { return Marshal(c) }
// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal].
func (c *CoreDone) UnmarshalBinary(data []byte) error { return Unmarshal(data, c) }
+// The CorePing event is emitted by the server when it wants to check if a client is
+// alive or ensure that it has processed the previous events.
+type CorePing struct {
+ // The object id to ping.
+ ID Int `json:"id"`
+ // Usually automatically generated.
+ // The client should pass this in the Pong method reply.
+ Sequence Int `json:"seq"`
+}
+
+// Size satisfies [KnownSize] with a constant value.
+func (c *CorePing) Size() Word { return SizePrefix + Size(SizeInt) + Size(SizeInt) }
+
+// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].
+func (c *CorePing) MarshalBinary() ([]byte, error) { return Marshal(c) }
+
+// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal].
+func (c *CorePing) UnmarshalBinary(data []byte) error { return Unmarshal(data, c) }
+
// The CoreBoundProps event is emitted when a local object ID is bound to a global ID.
// It is emitted before the global becomes visible in the registry.
type CoreBoundProps struct {
@@ -200,7 +219,7 @@ type CoreSync struct {
// The id will be returned in the Done event.
ID Int `json:"id"`
// Usually generated automatically and will be returned in the Done event.
- Sequence Int `json:"sequence"`
+ Sequence Int `json:"seq"`
}
// Size satisfies [KnownSize] with a constant value.
@@ -212,6 +231,23 @@ 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) }
+// The CorePong message is sent from the client to the server when the server emits the Ping event.
+type CorePong struct {
+ // Copied from [CorePing.ID].
+ ID Int `json:"id"`
+ // Copied from [CorePing.Sequence]
+ Sequence Int `json:"seq"`
+}
+
+// Size satisfies [KnownSize] with a constant value.
+func (c *CorePong) Size() Word { return SizePrefix + Size(SizeInt) + Size(SizeInt) }
+
+// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].
+func (c *CorePong) MarshalBinary() ([]byte, error) { return Marshal(c) }
+
+// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal].
+func (c *CorePong) UnmarshalBinary(data []byte) error { return Unmarshal(data, c) }
+
// CoreGetRegistry is sent when a client requests to bind to the
// registry object and list the available objects on the server.
//