diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-11-26 19:02:21 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-11-26 19:02:21 +0900 |
| commit | 2698ca00e8fad5f7243c1e1b4c078d322854917c (patch) | |
| tree | d9d46ca19010fcec16c4e41bc2418184bd54ba6b | |
| parent | 1d0143386de410b19a0e4adea497f7e246e89226 (diff) | |
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 <cat@gensokyo.uk>
| -rw-r--r-- | internal/pipewire/core.go | 14 | ||||
| -rw-r--r-- | internal/pipewire/core_test.go | 18 | ||||
| -rw-r--r-- | internal/pipewire/header_test.go | 6 | ||||
| -rw-r--r-- | internal/pipewire/pipewire_test.go | 7 | ||||
| -rw-r--r-- | internal/pipewire/testdata/19-recvmsg00-message05-header | bin | 0 -> 16 bytes | |||
| -rw-r--r-- | internal/pipewire/testdata/20-recvmsg00-message05-POD | bin | 0 -> 40 bytes | |||
| -rw-r--r-- | internal/pipewire/testdata/21-recvmsg00-message05-footer | bin | 0 -> 48 bytes |
7 files changed, 44 insertions, 1 deletions
diff --git a/internal/pipewire/core.go b/internal/pipewire/core.go index 05fd03bd..407ea954 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 1dc63278..7d3fad35 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 56f51c85..fba5d837 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 3d2ff055..78e44f49 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 Binary files differnew file mode 100644 index 00000000..41c8aa78 --- /dev/null +++ b/internal/pipewire/testdata/19-recvmsg00-message05-header diff --git a/internal/pipewire/testdata/20-recvmsg00-message05-POD b/internal/pipewire/testdata/20-recvmsg00-message05-POD Binary files differnew file mode 100644 index 00000000..bc14f3c4 --- /dev/null +++ b/internal/pipewire/testdata/20-recvmsg00-message05-POD diff --git a/internal/pipewire/testdata/21-recvmsg00-message05-footer b/internal/pipewire/testdata/21-recvmsg00-message05-footer Binary files differnew file mode 100644 index 00000000..92ab10bd --- /dev/null +++ b/internal/pipewire/testdata/21-recvmsg00-message05-footer |
