internal/pipewire: do not store spa_dict fields
All checks were successful
Test / Create distribution (push) Successful in 37s
Test / Sandbox (push) Successful in 2m29s
Test / Hakurei (push) Successful in 3m21s
Test / Hpkg (push) Successful in 4m12s
Test / Sandbox (race detector) (push) Successful in 4m24s
Test / Hakurei (race detector) (push) Successful in 5m15s
Test / Flake checks (push) Successful in 1m30s
All checks were successful
Test / Create distribution (push) Successful in 37s
Test / Sandbox (push) Successful in 2m29s
Test / Hakurei (push) Successful in 3m21s
Test / Hpkg (push) Successful in 4m12s
Test / Sandbox (race detector) (push) Successful in 4m24s
Test / Hakurei (race detector) (push) Successful in 5m15s
Test / Flake checks (push) Successful in 1m30s
This is effectively a poor man's slice, it is entirely unnecessary here and can be handled internally. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
72a2601d74
commit
d08a1081bd
@ -13,7 +13,7 @@ func TestClientInfo(t *testing.T) {
|
|||||||
{"sample", samplePWContainer[1][2][1], pipewire.ClientInfo{
|
{"sample", samplePWContainer[1][2][1], pipewire.ClientInfo{
|
||||||
ID: 34,
|
ID: 34,
|
||||||
ChangeMask: pipewire.PW_CLIENT_CHANGE_MASK_PROPS,
|
ChangeMask: pipewire.PW_CLIENT_CHANGE_MASK_PROPS,
|
||||||
Props: &pipewire.SPADict{NItems: 9, Items: []pipewire.SPADictItem{
|
Props: &pipewire.SPADict{
|
||||||
{Key: "pipewire.protocol", Value: "protocol-native"},
|
{Key: "pipewire.protocol", Value: "protocol-native"},
|
||||||
{Key: "core.name", Value: "pipewire-0"},
|
{Key: "core.name", Value: "pipewire-0"},
|
||||||
{Key: "pipewire.sec.socket", Value: "pipewire-0-manager"},
|
{Key: "pipewire.sec.socket", Value: "pipewire-0-manager"},
|
||||||
@ -23,12 +23,12 @@ func TestClientInfo(t *testing.T) {
|
|||||||
{Key: "module.id", Value: "2"},
|
{Key: "module.id", Value: "2"},
|
||||||
{Key: "object.id", Value: "34"},
|
{Key: "object.id", Value: "34"},
|
||||||
{Key: "object.serial", Value: "34"},
|
{Key: "object.serial", Value: "34"},
|
||||||
}}}, nil},
|
}}, nil},
|
||||||
|
|
||||||
{"sample*", samplePWContainer[1][3][1], pipewire.ClientInfo{
|
{"sample*", samplePWContainer[1][3][1], pipewire.ClientInfo{
|
||||||
ID: 34,
|
ID: 34,
|
||||||
ChangeMask: pipewire.PW_CLIENT_CHANGE_MASK_PROPS,
|
ChangeMask: pipewire.PW_CLIENT_CHANGE_MASK_PROPS,
|
||||||
Props: &pipewire.SPADict{NItems: 38, Items: []pipewire.SPADictItem{
|
Props: &pipewire.SPADict{
|
||||||
{Key: "pipewire.protocol", Value: "protocol-native"},
|
{Key: "pipewire.protocol", Value: "protocol-native"},
|
||||||
{Key: "core.name", Value: "pipewire-alice-1443"},
|
{Key: "core.name", Value: "pipewire-alice-1443"},
|
||||||
{Key: "pipewire.sec.socket", Value: "pipewire-0-manager"},
|
{Key: "pipewire.sec.socket", Value: "pipewire-0-manager"},
|
||||||
@ -67,12 +67,12 @@ func TestClientInfo(t *testing.T) {
|
|||||||
{Key: "settings.check-quantum", Value: "false"},
|
{Key: "settings.check-quantum", Value: "false"},
|
||||||
{Key: "settings.check-rate", Value: "false"},
|
{Key: "settings.check-rate", Value: "false"},
|
||||||
{Key: "core.version", Value: "1.4.7"},
|
{Key: "core.version", Value: "1.4.7"},
|
||||||
}}}, nil},
|
}}, nil},
|
||||||
|
|
||||||
{"sample**", samplePWContainer[1][4][1], pipewire.ClientInfo{
|
{"sample**", samplePWContainer[1][4][1], pipewire.ClientInfo{
|
||||||
ID: 34,
|
ID: 34,
|
||||||
ChangeMask: pipewire.PW_CLIENT_CHANGE_MASK_PROPS,
|
ChangeMask: pipewire.PW_CLIENT_CHANGE_MASK_PROPS,
|
||||||
Props: &pipewire.SPADict{NItems: 39, Items: []pipewire.SPADictItem{
|
Props: &pipewire.SPADict{
|
||||||
{Key: "pipewire.protocol", Value: "protocol-native"},
|
{Key: "pipewire.protocol", Value: "protocol-native"},
|
||||||
{Key: "core.name", Value: "pipewire-alice-1443"},
|
{Key: "core.name", Value: "pipewire-alice-1443"},
|
||||||
{Key: "pipewire.sec.socket", Value: "pipewire-0-manager"},
|
{Key: "pipewire.sec.socket", Value: "pipewire-0-manager"},
|
||||||
@ -112,7 +112,7 @@ func TestClientInfo(t *testing.T) {
|
|||||||
{Key: "settings.check-rate", Value: "false"},
|
{Key: "settings.check-rate", Value: "false"},
|
||||||
{Key: "core.version", Value: "1.4.7"},
|
{Key: "core.version", Value: "1.4.7"},
|
||||||
{Key: "pipewire.access", Value: "unrestricted"},
|
{Key: "pipewire.access", Value: "unrestricted"},
|
||||||
}}}, nil},
|
}}, nil},
|
||||||
}.run(t)
|
}.run(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ func TestClientUpdateProperties(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
encodingTestCases[pipewire.ClientUpdateProperties, *pipewire.ClientUpdateProperties]{
|
encodingTestCases[pipewire.ClientUpdateProperties, *pipewire.ClientUpdateProperties]{
|
||||||
{"sample", samplePWContainer[0][1][1], pipewire.ClientUpdateProperties{Props: &pipewire.SPADict{NItems: 0x1e, Items: []pipewire.SPADictItem{
|
{"sample", samplePWContainer[0][1][1], pipewire.ClientUpdateProperties{Props: &pipewire.SPADict{
|
||||||
{Key: "remote.intention", Value: "manager"},
|
{Key: "remote.intention", Value: "manager"},
|
||||||
{Key: "application.name", Value: "pw-container"},
|
{Key: "application.name", Value: "pw-container"},
|
||||||
{Key: "application.process.binary", Value: "pw-container"},
|
{Key: "application.process.binary", Value: "pw-container"},
|
||||||
@ -151,6 +151,6 @@ func TestClientUpdateProperties(t *testing.T) {
|
|||||||
{Key: "settings.check-rate", Value: "false"},
|
{Key: "settings.check-rate", Value: "false"},
|
||||||
{Key: "core.version", Value: "1.4.7"},
|
{Key: "core.version", Value: "1.4.7"},
|
||||||
{Key: "core.name", Value: "pipewire-alice-1443"},
|
{Key: "core.name", Value: "pipewire-alice-1443"},
|
||||||
}}}, nil},
|
}}, nil},
|
||||||
}.run(t)
|
}.run(t)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@ func TestCoreInfo(t *testing.T) {
|
|||||||
Version: "1.4.7",
|
Version: "1.4.7",
|
||||||
Name: "pipewire-0",
|
Name: "pipewire-0",
|
||||||
ChangeMask: pipewire.PW_CORE_CHANGE_MASK_PROPS,
|
ChangeMask: pipewire.PW_CORE_CHANGE_MASK_PROPS,
|
||||||
Props: &pipewire.SPADict{NItems: 31, Items: []pipewire.SPADictItem{
|
Props: &pipewire.SPADict{
|
||||||
{Key: "config.name", Value: "pipewire.conf"},
|
{Key: "config.name", Value: "pipewire.conf"},
|
||||||
{Key: "application.name", Value: "pipewire"},
|
{Key: "application.name", Value: "pipewire"},
|
||||||
{Key: "application.process.binary", Value: "pipewire"},
|
{Key: "application.process.binary", Value: "pipewire"},
|
||||||
@ -66,7 +66,7 @@ func TestCoreInfo(t *testing.T) {
|
|||||||
{Key: "settings.check-rate", Value: "false"},
|
{Key: "settings.check-rate", Value: "false"},
|
||||||
{Key: "object.id", Value: "0"},
|
{Key: "object.id", Value: "0"},
|
||||||
{Key: "object.serial", Value: "0"}},
|
{Key: "object.serial", Value: "0"}},
|
||||||
}}, nil},
|
}, nil},
|
||||||
}.run(t)
|
}.run(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ func TestCoreBoundProps(t *testing.T) {
|
|||||||
{"sample", samplePWContainer[1][1][1], pipewire.CoreBoundProps{
|
{"sample", samplePWContainer[1][1][1], pipewire.CoreBoundProps{
|
||||||
ID: pipewire.PW_ID_CLIENT,
|
ID: pipewire.PW_ID_CLIENT,
|
||||||
GlobalID: 34,
|
GlobalID: 34,
|
||||||
Props: &pipewire.SPADict{NItems: 7, Items: []pipewire.SPADictItem{
|
Props: &pipewire.SPADict{
|
||||||
{Key: "object.serial", Value: "34"},
|
{Key: "object.serial", Value: "34"},
|
||||||
{Key: "module.id", Value: "2"},
|
{Key: "module.id", Value: "2"},
|
||||||
{Key: "pipewire.protocol", Value: "protocol-native"},
|
{Key: "pipewire.protocol", Value: "protocol-native"},
|
||||||
@ -96,7 +96,7 @@ func TestCoreBoundProps(t *testing.T) {
|
|||||||
{Key: "pipewire.sec.uid", Value: "1000"},
|
{Key: "pipewire.sec.uid", Value: "1000"},
|
||||||
{Key: "pipewire.sec.gid", Value: "100"},
|
{Key: "pipewire.sec.gid", Value: "100"},
|
||||||
{Key: "pipewire.sec.socket", Value: "pipewire-0-manager"}},
|
{Key: "pipewire.sec.socket", Value: "pipewire-0-manager"}},
|
||||||
}}, nil},
|
}, nil},
|
||||||
}.run(t)
|
}.run(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -456,14 +456,11 @@ func (f *Footer[T]) MarshalBinary() ([]byte, error) { return Marshal(f) }
|
|||||||
// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal].
|
// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal].
|
||||||
func (f *Footer[T]) UnmarshalBinary(data []byte) error { return Unmarshal(data, f) }
|
func (f *Footer[T]) UnmarshalBinary(data []byte) error { return Unmarshal(data, f) }
|
||||||
|
|
||||||
// SPADictItem is an encoding-compatible representation of spa_dict_item.
|
// SPADictItem represents spa_dict_item.
|
||||||
type SPADictItem struct{ Key, Value string }
|
type SPADictItem struct{ Key, Value string }
|
||||||
|
|
||||||
// SPADict is an encoding-compatible representation of spa_dict.
|
// SPADict represents spa_dict.
|
||||||
type SPADict struct {
|
type SPADict []SPADictItem
|
||||||
NItems Int
|
|
||||||
Items []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 {
|
||||||
@ -473,9 +470,9 @@ func (d *SPADict) Size() Word {
|
|||||||
|
|
||||||
// struct prefix, NItems value
|
// struct prefix, NItems value
|
||||||
size := SizePrefix + int(Size(SizeInt))
|
size := SizePrefix + int(Size(SizeInt))
|
||||||
for i := range d.Items {
|
for i := range *d {
|
||||||
size += SizeString[int](d.Items[i].Key)
|
size += SizeString[int]((*d)[i].Key)
|
||||||
size += SizeString[int](d.Items[i].Value)
|
size += SizeString[int]((*d)[i].Value)
|
||||||
}
|
}
|
||||||
return Word(size)
|
return Word(size)
|
||||||
}
|
}
|
||||||
@ -484,14 +481,14 @@ func (d *SPADict) Size() Word {
|
|||||||
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) {
|
||||||
data = binary.NativeEndian.AppendUint32(dataPrefix, SPA_TYPE_Struct)
|
data = binary.NativeEndian.AppendUint32(dataPrefix, SPA_TYPE_Struct)
|
||||||
if data, err = MarshalAppend(data, d.NItems); err != nil {
|
if data, err = MarshalAppend(data, Int(len(*d))); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i := range d.Items {
|
for i := range *d {
|
||||||
if data, err = MarshalAppend(data, d.Items[i].Key); err != nil {
|
if data, err = MarshalAppend(data, (*d)[i].Key); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if data, err = MarshalAppend(data, d.Items[i].Value); err != nil {
|
if data, err = MarshalAppend(data, (*d)[i].Value); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -508,22 +505,23 @@ func (d *SPADict) UnmarshalPOD(data []byte) (Word, error) {
|
|||||||
// bounds check completed in successful call to unmarshalCheckTypeBounds
|
// bounds check completed in successful call to unmarshalCheckTypeBounds
|
||||||
data = data[:wireSize]
|
data = data[:wireSize]
|
||||||
|
|
||||||
if size, err := UnmarshalNext(data, &d.NItems); err != nil {
|
var count Int
|
||||||
|
if size, err := UnmarshalNext(data, &count); err != nil {
|
||||||
return wireSize, err
|
return wireSize, err
|
||||||
} else {
|
} else {
|
||||||
// bounds check completed in successful call to Unmarshal
|
// bounds check completed in successful call to Unmarshal
|
||||||
data = data[size:]
|
data = data[size:]
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Items = make([]SPADictItem, d.NItems)
|
*d = make([]SPADictItem, count)
|
||||||
for i := range d.Items {
|
for i := range *d {
|
||||||
if size, err := UnmarshalNext(data, &d.Items[i].Key); err != nil {
|
if size, err := UnmarshalNext(data, &(*d)[i].Key); err != nil {
|
||||||
return wireSize, err
|
return wireSize, err
|
||||||
} else {
|
} else {
|
||||||
// bounds check completed in successful call to Unmarshal
|
// bounds check completed in successful call to Unmarshal
|
||||||
data = data[size:]
|
data = data[size:]
|
||||||
}
|
}
|
||||||
if size, err := UnmarshalNext(data, &d.Items[i].Value); err != nil {
|
if size, err := UnmarshalNext(data, &(*d)[i].Value); err != nil {
|
||||||
return wireSize, err
|
return wireSize, err
|
||||||
} else {
|
} else {
|
||||||
// bounds check completed in successful call to Unmarshal
|
// bounds check completed in successful call to Unmarshal
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user