From 2698ca00e8fad5f7243c1e1b4c078d322854917c Mon Sep 17 00:00:00 2001 From: Ophestra Date: Wed, 26 Nov 2025 19:02:21 +0900 Subject: [PATCH] internal/pipewire: implement Core::Done The message in the sample does not correspond to any known method call. The spec does not mention what to do with messages like this, but all existing usage code simply drops it. Signed-off-by: Ophestra --- internal/pipewire/core.go | 14 ++++++++++++++ internal/pipewire/core_test.go | 18 +++++++++++++++++- internal/pipewire/header_test.go | 6 ++++++ internal/pipewire/pipewire_test.go | 7 +++++++ .../testdata/19-recvmsg00-message05-header | Bin 0 -> 16 bytes .../testdata/20-recvmsg00-message05-POD | Bin 0 -> 40 bytes .../testdata/21-recvmsg00-message05-footer | Bin 0 -> 48 bytes 7 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 internal/pipewire/testdata/19-recvmsg00-message05-header create mode 100644 internal/pipewire/testdata/20-recvmsg00-message05-POD create mode 100644 internal/pipewire/testdata/21-recvmsg00-message05-footer diff --git a/internal/pipewire/core.go b/internal/pipewire/core.go index 05fd03b..407ea95 100644 --- a/internal/pipewire/core.go +++ b/internal/pipewire/core.go @@ -108,6 +108,20 @@ func (c *CoreInfo) MarshalBinary() ([]byte, error) { return Marshal(c) } // UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal]. func (c *CoreInfo) UnmarshalBinary(data []byte) error { return Unmarshal(data, c) } +// The CoreDone event is emitted as a result of a client Sync method. +type CoreDone struct { + // Passed from [CoreSync.ID]. + ID Int + // Passed from [CoreSync.Sequence]. + Sequence Int +} + +// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal]. +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 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 { diff --git a/internal/pipewire/core_test.go b/internal/pipewire/core_test.go index 1dc6327..7d3fad3 100644 --- a/internal/pipewire/core_test.go +++ b/internal/pipewire/core_test.go @@ -12,7 +12,12 @@ func TestFooterCoreGeneration(t *testing.T) { encodingTestCases[pipewire.Footer[pipewire.FooterCoreGeneration], *pipewire.Footer[pipewire.FooterCoreGeneration]]{ {"sample", []byte(recvmsg00Message00Footer), pipewire.Footer[pipewire.FooterCoreGeneration]{ Opcode: pipewire.FOOTER_CORE_OPCODE_GENERATION, - Payload: pipewire.FooterCoreGeneration{RegistryGeneration: 34}, + Payload: pipewire.FooterCoreGeneration{RegistryGeneration: 0x22}, + }, nil}, + + {"sample*", []byte(recvmsg00Message05Footer), pipewire.Footer[pipewire.FooterCoreGeneration]{ + Opcode: pipewire.FOOTER_CORE_OPCODE_GENERATION, + Payload: pipewire.FooterCoreGeneration{RegistryGeneration: 0x23}, }, nil}, }.run(t) } @@ -65,6 +70,17 @@ func TestCoreInfo(t *testing.T) { }.run(t) } +func TestCoreDone(t *testing.T) { + t.Parallel() + + encodingTestCases[pipewire.CoreDone, *pipewire.CoreDone]{ + {"sample", []byte(recvmsg00Message05POD), pipewire.CoreDone{ + ID: -1, + Sequence: 0, + }, nil}, + }.run(t) +} + func TestCoreBoundProps(t *testing.T) { t.Parallel() diff --git a/internal/pipewire/header_test.go b/internal/pipewire/header_test.go index 56f51c8..fba5d83 100644 --- a/internal/pipewire/header_test.go +++ b/internal/pipewire/header_test.go @@ -65,6 +65,12 @@ func TestHeader(t *testing.T) { Size: 0x7d0, Sequence: 4, FileCount: 0, }, nil}, + {"PW_CORE_EVENT_DONE", []byte(recvmsg00Message05Header), pipewire.Header{ + ID: pipewire.PW_ID_CORE, + Opcode: pipewire.PW_CORE_EVENT_DONE, + Size: 0x58, Sequence: 5, FileCount: 0, + }, nil}, + {"PW_SECURITY_CONTEXT_METHOD_CREATE", []byte{ // Id 3, 0, 0, 0, diff --git a/internal/pipewire/pipewire_test.go b/internal/pipewire/pipewire_test.go index 3d2ff05..78e44f4 100644 --- a/internal/pipewire/pipewire_test.go +++ b/internal/pipewire/pipewire_test.go @@ -51,4 +51,11 @@ var ( recvmsg00Message04Header string //go:embed testdata/18-recvmsg00-message04-POD recvmsg00Message04POD string + + //go:embed testdata/19-recvmsg00-message05-header + recvmsg00Message05Header string + //go:embed testdata/20-recvmsg00-message05-POD + recvmsg00Message05POD string + //go:embed testdata/21-recvmsg00-message05-footer + recvmsg00Message05Footer string ) diff --git a/internal/pipewire/testdata/19-recvmsg00-message05-header b/internal/pipewire/testdata/19-recvmsg00-message05-header new file mode 100644 index 0000000000000000000000000000000000000000..41c8aa78151dfd968e3d23edd21ce8c47ef80c5d GIT binary patch literal 16 UcmZQzU|@(~U|?hgF&G#a00dzGUjP6A literal 0 HcmV?d00001 diff --git a/internal/pipewire/testdata/20-recvmsg00-message05-POD b/internal/pipewire/testdata/20-recvmsg00-message05-POD new file mode 100644 index 0000000000000000000000000000000000000000..bc14f3c47d02f105f138e581e94441691b19cee4 GIT binary patch literal 40 ecmY#jU|`^5U|?W@;{X5u|7U=*L1G{_2m=6OCImYG literal 0 HcmV?d00001 diff --git a/internal/pipewire/testdata/21-recvmsg00-message05-footer b/internal/pipewire/testdata/21-recvmsg00-message05-footer new file mode 100644 index 0000000000000000000000000000000000000000..92ab10bd6ec715e2f6a6569afd93aaf501826989 GIT binary patch literal 48 kcmdO3U|`^5U|?WjU|?WoKmY-#I0pj*11kdqgECYK01uD=i~s-t literal 0 HcmV?d00001