internal/pipewire: do not emit None for spa_dict
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m23s
Test / Hakurei (push) Successful in 3m26s
Test / Hpkg (push) Successful in 4m9s
Test / Sandbox (race detector) (push) Successful in 4m30s
Test / Hakurei (race detector) (push) Successful in 3m18s
Test / Flake checks (push) Successful in 1m41s

Turns out the PipeWire server does not expect a value of type None here at all.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-12-14 09:06:44 +09:00
parent a27dfdc058
commit 00a5bdf006
2 changed files with 11 additions and 20 deletions

View File

@@ -311,7 +311,7 @@ func TestCoreCreateObject(t *testing.T) {
encodingTestCases[pipewire.CoreCreateObject, *pipewire.CoreCreateObject]{ encodingTestCases[pipewire.CoreCreateObject, *pipewire.CoreCreateObject]{
{"sample", []byte{ {"sample", []byte{
/* size: rest of data */ 0x70, 0, 0, 0, /* size: rest of data */ 0x80, 0, 0, 0,
/* type: Struct */ 0xe, 0, 0, 0, /* type: Struct */ 0xe, 0, 0, 0,
/* size: 0x13 bytes */ 0x13, 0, 0, 0, /* size: 0x13 bytes */ 0x13, 0, 0, 0,
@@ -343,8 +343,13 @@ func TestCoreCreateObject(t *testing.T) {
/* value: 3 */ 3, 0, 0, 0, /* value: 3 */ 3, 0, 0, 0,
/* padding */ 0, 0, 0, 0, /* padding */ 0, 0, 0, 0,
/* size */ 0, 0, 0, 0, /* size */ 0x10, 0, 0, 0,
/* type: None */ 1, 0, 0, 0, /* type: Struct */ 0xe, 0, 0, 0,
/* size: 4 bytes */ 4, 0, 0, 0,
/* type: Int */ 4, 0, 0, 0,
/* value: 0 */ 0, 0, 0, 0,
/* padding */ 0, 0, 0, 0,
/* size: 4 bytes */ 4, 0, 0, 0, /* size: 4 bytes */ 4, 0, 0, 0,
/* type: Int */ 4, 0, 0, 0, /* type: Int */ 4, 0, 0, 0,
@@ -354,7 +359,7 @@ func TestCoreCreateObject(t *testing.T) {
FactoryName: "spa-device-factory", FactoryName: "spa-device-factory",
Type: pipewire.PW_TYPE_INTERFACE_Device, Type: pipewire.PW_TYPE_INTERFACE_Device,
Version: pipewire.PW_VERSION_FACTORY, Version: pipewire.PW_VERSION_FACTORY,
Properties: new(pipewire.SPADict), Properties: &pipewire.SPADict{},
NewID: 0xbad, NewID: 0xbad,
}, nil}, }, nil},
}.run(t) }.run(t)

View File

@@ -524,9 +524,8 @@ type SPADict []SPADictItem
// Size satisfies [KnownSize] with a value computed at runtime. // Size satisfies [KnownSize] with a value computed at runtime.
func (d *SPADict) Size() Word { func (d *SPADict) Size() Word {
if *d == nil { if d == nil {
// None type prefix with zero-length body return 0
return SizePrefix
} }
// struct prefix, NItems value // struct prefix, NItems value
@@ -541,11 +540,6 @@ func (d *SPADict) Size() Word {
// MarshalPOD satisfies [PODMarshaler] as [SPADict] violates the POD type system. // MarshalPOD satisfies [PODMarshaler] as [SPADict] violates the POD type system.
func (d *SPADict) MarshalPOD(data []byte) ([]byte, error) { func (d *SPADict) MarshalPOD(data []byte) ([]byte, error) {
return appendInner(data, func(dataPrefix []byte) (data []byte, err error) { return appendInner(data, func(dataPrefix []byte) (data []byte, err error) {
if *d == nil {
data = SPA_TYPE_None.append(dataPrefix)
return
}
data = SPA_TYPE_Struct.append(dataPrefix) data = SPA_TYPE_Struct.append(dataPrefix)
if data, err = MarshalAppend(data, Int(len(*d))); err != nil { if data, err = MarshalAppend(data, Int(len(*d))); err != nil {
return return
@@ -565,14 +559,6 @@ func (d *SPADict) MarshalPOD(data []byte) ([]byte, error) {
// UnmarshalPOD satisfies [PODUnmarshaler] as [SPADict] violates the POD type system. // UnmarshalPOD satisfies [PODUnmarshaler] as [SPADict] violates the POD type system.
func (d *SPADict) UnmarshalPOD(data []byte) (Word, error) { func (d *SPADict) UnmarshalPOD(data []byte) (Word, error) {
var wireSize Word var wireSize Word
if ok, err := unmarshalHandleNone(&data, &wireSize); err != nil {
return wireSize, err
} else if ok {
*d = nil
return wireSize, nil
}
if err := unmarshalCheckTypeBounds(&data, SPA_TYPE_Struct, &wireSize); err != nil { if err := unmarshalCheckTypeBounds(&data, SPA_TYPE_Struct, &wireSize); err != nil {
return wireSize, err return wireSize, err
} }