aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pipewire/core.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/pipewire/core.go')
-rw-r--r--internal/pipewire/core.go79
1 files changed, 75 insertions, 4 deletions
diff --git a/internal/pipewire/core.go b/internal/pipewire/core.go
index 6a8af0ba..35340c88 100644
--- a/internal/pipewire/core.go
+++ b/internal/pipewire/core.go
@@ -133,6 +133,12 @@ type CoreInfo struct {
Properties *SPADict `json:"props"`
}
+// Opcode satisfies [Message] with a constant value.
+func (c *CoreInfo) Opcode() byte { return PW_CORE_EVENT_INFO }
+
+// FileCount satisfies [Message] with a constant value.
+func (c *CoreInfo) FileCount() Int { return 0 }
+
// Size satisfies [KnownSize] with a value computed at runtime.
func (c *CoreInfo) Size() Word {
return SizePrefix +
@@ -160,6 +166,12 @@ type CoreDone struct {
Sequence Int `json:"seq"`
}
+// Opcode satisfies [Message] with a constant value.
+func (c *CoreDone) Opcode() byte { return PW_CORE_EVENT_DONE }
+
+// FileCount satisfies [Message] with a constant value.
+func (c *CoreDone) FileCount() Int { return 0 }
+
// Size satisfies [KnownSize] with a constant value.
func (c *CoreDone) Size() Word { return SizePrefix + Size(SizeInt) + Size(SizeInt) }
@@ -179,6 +191,12 @@ type CorePing struct {
Sequence Int `json:"seq"`
}
+// Opcode satisfies [Message] with a constant value.
+func (c *CorePing) Opcode() byte { return PW_CORE_EVENT_PING }
+
+// FileCount satisfies [Message] with a constant value.
+func (c *CorePing) FileCount() Int { return 0 }
+
// Size satisfies [KnownSize] with a constant value.
func (c *CorePing) Size() Word { return SizePrefix + Size(SizeInt) + Size(SizeInt) }
@@ -209,6 +227,9 @@ type CoreError struct {
Message String `json:"message"`
}
+// FileCount satisfies [Message] with a constant value.
+func (c *CoreError) FileCount() Int { return 0 }
+
func (c *CoreError) Error() string {
return "received Core::Error on" +
" id " + strconv.Itoa(int(c.ID)) +
@@ -232,6 +253,18 @@ func (c *CoreError) MarshalBinary() ([]byte, error) { return Marshal(c) }
// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal].
func (c *CoreError) UnmarshalBinary(data []byte) error { return Unmarshal(data, c) }
+// CoreErrorMethod is [CoreError] as a method [Message].
+type CoreErrorMethod struct{ CoreError }
+
+// Opcode satisfies [Message] with a constant value.
+func (c *CoreErrorMethod) Opcode() byte { return PW_CORE_METHOD_ERROR }
+
+// CoreErrorEvent is [CoreError] as an event [Message].
+type CoreErrorEvent struct{ CoreError }
+
+// Opcode satisfies [Message] with a constant value.
+func (c *CoreErrorEvent) Opcode() byte { return PW_CORE_EVENT_ERROR }
+
// 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 {
@@ -243,6 +276,12 @@ type CoreBoundProps struct {
Properties *SPADict `json:"props"`
}
+// Opcode satisfies [Message] with a constant value.
+func (c *CoreBoundProps) Opcode() byte { return PW_CORE_EVENT_BOUND_PROPS }
+
+// FileCount satisfies [Message] with a constant value.
+func (c *CoreBoundProps) FileCount() Int { return 0 }
+
// Size satisfies [KnownSize] with a value computed at runtime.
func (c *CoreBoundProps) Size() Word {
return SizePrefix +
@@ -294,6 +333,12 @@ type CoreHello struct {
Version Int `json:"version"`
}
+// Opcode satisfies [Message] with a constant value.
+func (c *CoreHello) Opcode() byte { return PW_CORE_METHOD_HELLO }
+
+// FileCount satisfies [Message] with a constant value.
+func (c *CoreHello) FileCount() Int { return 0 }
+
// Size satisfies [KnownSize] with a constant value.
func (c *CoreHello) Size() Word { return SizePrefix + Size(SizeInt) }
@@ -308,7 +353,6 @@ func (c *CoreHello) UnmarshalBinary(data []byte) error { return Unmarshal(data,
func (ctx *Context) coreHello() error {
return ctx.writeMessage(
PW_ID_CORE,
- PW_CORE_METHOD_HELLO,
&CoreHello{PW_VERSION_CORE},
)
}
@@ -328,6 +372,12 @@ type CoreSync struct {
Sequence Int `json:"seq"`
}
+// Opcode satisfies [Message] with a constant value.
+func (c *CoreSync) Opcode() byte { return PW_CORE_METHOD_SYNC }
+
+// FileCount satisfies [Message] with a constant value.
+func (c *CoreSync) FileCount() Int { return 0 }
+
// Size satisfies [KnownSize] with a constant value.
func (c *CoreSync) Size() Word { return SizePrefix + Size(SizeInt) + Size(SizeInt) }
@@ -342,7 +392,6 @@ func (c *CoreSync) UnmarshalBinary(data []byte) error { return Unmarshal(data, c
func (ctx *Context) coreSync(id Int) error {
return ctx.writeMessage(
PW_ID_CORE,
- PW_CORE_METHOD_SYNC,
&CoreSync{id, CoreSyncSequenceOffset + Int(ctx.sequence)},
)
}
@@ -390,6 +439,12 @@ type CorePong struct {
Sequence Int `json:"seq"`
}
+// Opcode satisfies [Message] with a constant value.
+func (c *CorePong) Opcode() byte { return PW_CORE_METHOD_PONG }
+
+// FileCount satisfies [Message] with a constant value.
+func (c *CorePong) FileCount() Int { return 0 }
+
// Size satisfies [KnownSize] with a constant value.
func (c *CorePong) Size() Word { return SizePrefix + Size(SizeInt) + Size(SizeInt) }
@@ -414,6 +469,12 @@ type CoreGetRegistry struct {
NewID Int `json:"new_id"`
}
+// Opcode satisfies [Message] with a constant value.
+func (c *CoreGetRegistry) Opcode() byte { return PW_CORE_METHOD_GET_REGISTRY }
+
+// FileCount satisfies [Message] with a constant value.
+func (c *CoreGetRegistry) FileCount() Int { return 0 }
+
// Size satisfies [KnownSize] with a constant value.
func (c *CoreGetRegistry) Size() Word { return SizePrefix + Size(SizeInt) + Size(SizeInt) }
@@ -431,7 +492,6 @@ func (ctx *Context) GetRegistry() (*Registry, error) {
registry.ID = newId
return &registry, ctx.writeMessage(
PW_ID_CORE,
- PW_CORE_METHOD_GET_REGISTRY,
&CoreGetRegistry{PW_VERSION_REGISTRY, newId},
)
}
@@ -450,6 +510,12 @@ type RegistryGlobal struct {
Properties *SPADict `json:"props"`
}
+// Opcode satisfies [Message] with a constant value.
+func (c *RegistryGlobal) Opcode() byte { return PW_REGISTRY_EVENT_GLOBAL }
+
+// FileCount satisfies [Message] with a constant value.
+func (c *RegistryGlobal) FileCount() Int { return 0 }
+
// Size satisfies [KnownSize] with a value computed at runtime.
func (c *RegistryGlobal) Size() Word {
return SizePrefix +
@@ -481,6 +547,12 @@ type RegistryBind struct {
NewID Int `json:"new_id"`
}
+// Opcode satisfies [Message] with a constant value.
+func (c *RegistryBind) Opcode() byte { return PW_REGISTRY_METHOD_BIND }
+
+// FileCount satisfies [Message] with a constant value.
+func (c *RegistryBind) FileCount() Int { return 0 }
+
// Size satisfies [KnownSize] with a value computed at runtime.
func (c *RegistryBind) Size() Word {
return SizePrefix +
@@ -507,7 +579,6 @@ func (registry *Registry) bind(proxy eventProxy, id, version Int) (Int, error) {
}
return bind.NewID, registry.ctx.writeMessage(
registry.ID,
- PW_REGISTRY_METHOD_BIND,
&bind,
)
}