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>
This commit is contained in:
2025-11-26 19:02:21 +09:00
parent 1d0143386d
commit 2698ca00e8
7 changed files with 44 additions and 1 deletions

View File

@@ -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 {

View File

@@ -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()

View File

@@ -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,

View File

@@ -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
)

Binary file not shown.

Binary file not shown.

Binary file not shown.