Accepting request 1058203 from multimedia:libs

OBS-URL: https://build.opensuse.org/request/show/1058203
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/wireplumber?expand=0&rev=21
This commit is contained in:
Dominique Leuenberger 2023-01-13 23:02:09 +00:00 committed by Git OBS Bridge
commit 2c6028dc5e
5 changed files with 339 additions and 0 deletions

View File

@ -0,0 +1,32 @@
From f6dc1b3347967948cf876c62fa597b803052cb3b Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Tue, 13 Dec 2022 15:19:06 +0100
Subject: [PATCH] alsa-monitor: handle snd_aloop devices better
Place Loopback as the device description for snd_aloop devices.
Fixes pipewire#2214
---
src/scripts/monitors/alsa.lua | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/scripts/monitors/alsa.lua b/src/scripts/monitors/alsa.lua
index 195c0916..b959a4a2 100644
--- a/src/scripts/monitors/alsa.lua
+++ b/src/scripts/monitors/alsa.lua
@@ -228,8 +228,11 @@ function prepareDevice(parent, id, obj_type, factory, properties)
local d = nil
local f = properties["device.form-factor"]
local c = properties["device.class"]
+ local n = properties["api.alsa.card.name"]
- if f == "internal" then
+ if n == "Loopback" then
+ d = I18n.gettext("Loopback")
+ elseif f == "internal" then
d = I18n.gettext("Built-in Audio")
elseif c == "modem" then
d = I18n.gettext("Modem")
--
GitLab

View File

@ -0,0 +1,176 @@
From 6b761c03e18b89c5121e4f48ce7df471504801fd Mon Sep 17 00:00:00 2001
From: Julian Bouzas <julian.bouzas@collabora.com>
Date: Wed, 4 Jan 2023 11:20:14 -0500
Subject: [PATCH] m-lua-scripting: ignore string/integer table keys when
constructing a JSON Array/Object
---
modules/module-lua-scripting/api/json.c | 97 +++++++++++++------------
tests/wplua/scripts/json.lua | 26 +++++++
2 files changed, 77 insertions(+), 46 deletions(-)
diff --git a/modules/module-lua-scripting/api/json.c b/modules/module-lua-scripting/api/json.c
index be12ea38..cae96af8 100644
--- a/modules/module-lua-scripting/api/json.c
+++ b/modules/module-lua-scripting/api/json.c
@@ -242,31 +242,33 @@ spa_json_array_new (lua_State *L)
luaL_checktype (L, 1, LUA_TTABLE);
lua_pushnil (L);
- while (lua_next (L, 1)) {
- switch (lua_type (L, -1)) {
- case LUA_TBOOLEAN:
- wp_spa_json_builder_add_boolean (builder, lua_toboolean (L, -1));
- break;
- case LUA_TNUMBER:
- if (lua_isinteger (L, -1))
- wp_spa_json_builder_add_int (builder, lua_tointeger (L, -1));
- else
- wp_spa_json_builder_add_float (builder, lua_tonumber (L, -1));
- break;
- case LUA_TSTRING:
- wp_spa_json_builder_add_string (builder, lua_tostring (L, -1));
- break;
- case LUA_TUSERDATA: {
- WpSpaJson *json = wplua_checkboxed (L, -1, WP_TYPE_SPA_JSON);
- wp_spa_json_builder_add_json (builder, json);
- break;
+ while (lua_next (L, -2)) {
+ /* We only add table values with integer keys */
+ if (lua_isinteger (L, -2)) {
+ switch (lua_type (L, -1)) {
+ case LUA_TBOOLEAN:
+ wp_spa_json_builder_add_boolean (builder, lua_toboolean (L, -1));
+ break;
+ case LUA_TNUMBER:
+ if (lua_isinteger (L, -1))
+ wp_spa_json_builder_add_int (builder, lua_tointeger (L, -1));
+ else
+ wp_spa_json_builder_add_float (builder, lua_tonumber (L, -1));
+ break;
+ case LUA_TSTRING:
+ wp_spa_json_builder_add_string (builder, lua_tostring (L, -1));
+ break;
+ case LUA_TUSERDATA: {
+ WpSpaJson *json = wplua_checkboxed (L, -1, WP_TYPE_SPA_JSON);
+ wp_spa_json_builder_add_json (builder, json);
+ break;
+ }
+ default:
+ luaL_error (L, "Json does not support lua type ",
+ lua_typename(L, lua_type(L, -1)));
+ break;
}
- default:
- luaL_error (L, "Json does not support lua type ",
- lua_typename(L, lua_type(L, -1)));
- break;
}
-
lua_pop (L, 1);
}
@@ -285,30 +287,33 @@ spa_json_object_new (lua_State *L)
lua_pushnil (L);
while (lua_next (L, -2)) {
- wp_spa_json_builder_add_property (builder, lua_tostring (L, -2));
-
- switch (lua_type (L, -1)) {
- case LUA_TBOOLEAN:
- wp_spa_json_builder_add_boolean (builder, lua_toboolean (L, -1));
- break;
- case LUA_TNUMBER:
- if (lua_isinteger (L, -1))
- wp_spa_json_builder_add_int (builder, lua_tointeger (L, -1));
- else
- wp_spa_json_builder_add_float (builder, lua_tonumber (L, -1));
- break;
- case LUA_TSTRING:
- wp_spa_json_builder_add_string (builder, lua_tostring (L, -1));
- break;
- case LUA_TUSERDATA: {
- WpSpaJson *json = wplua_checkboxed (L, -1, WP_TYPE_SPA_JSON);
- wp_spa_json_builder_add_json (builder, json);
- break;
+ /* We only add table values with string keys */
+ if (lua_type (L, -2) == LUA_TSTRING) {
+ wp_spa_json_builder_add_property (builder, lua_tostring (L, -2));
+
+ switch (lua_type (L, -1)) {
+ case LUA_TBOOLEAN:
+ wp_spa_json_builder_add_boolean (builder, lua_toboolean (L, -1));
+ break;
+ case LUA_TNUMBER:
+ if (lua_isinteger (L, -1))
+ wp_spa_json_builder_add_int (builder, lua_tointeger (L, -1));
+ else
+ wp_spa_json_builder_add_float (builder, lua_tonumber (L, -1));
+ break;
+ case LUA_TSTRING:
+ wp_spa_json_builder_add_string (builder, lua_tostring (L, -1));
+ break;
+ case LUA_TUSERDATA: {
+ WpSpaJson *json = wplua_checkboxed (L, -1, WP_TYPE_SPA_JSON);
+ wp_spa_json_builder_add_json (builder, json);
+ break;
+ }
+ default:
+ luaL_error (L, "Json does not support lua type ",
+ lua_typename(L, lua_type(L, -1)));
+ break;
}
- default:
- luaL_error (L, "Json does not support lua type ",
- lua_typename(L, lua_type(L, -1)));
- break;
}
lua_pop (L, 1);
diff --git a/tests/wplua/scripts/json.lua b/tests/wplua/scripts/json.lua
index e01d7f6f..3671a698 100644
--- a/tests/wplua/scripts/json.lua
+++ b/tests/wplua/scripts/json.lua
@@ -102,6 +102,19 @@ assert (json:is_array())
assert (json:get_data() == "[[{\"key1\":1}, {\"key2\":2}]]")
assert (json:get_data() == json:to_string())
+table = {}
+table[1] = 1
+table[2] = 2
+table[3] = 3
+table["4"] = 4
+json = Json.Array (table)
+assert (json:is_array())
+val = json:parse ()
+assert (val[1] == 1)
+assert (val[2] == 2)
+assert (val[3] == 3)
+assert (val["4"] == nil)
+
-- Object
json = Json.Object {
key1 = Json.Null(),
@@ -134,6 +147,19 @@ assert (val.key7.key_nested3[2])
assert (not val.key7.key_nested3[3])
assert (val.key7["Key with spaces and (special % characters)"] == 50.0)
+table = {}
+table["1"] = 1
+table["2"] = 2
+table["3"] = 3
+table[4] = 4
+json = Json.Object (table)
+assert (json:is_object())
+val = json:parse ()
+assert (val["1"] == 1)
+assert (val["2"] == 2)
+assert (val["3"] == 3)
+assert (val[4] == nil)
+
-- Raw
json = Json.Raw ("[\"foo\", \"bar\"]")
assert (json:is_array())
--
GitLab

View File

@ -0,0 +1,75 @@
From 10f85549a42cd33daaa7a0c4eb1329c5f8067b7d Mon Sep 17 00:00:00 2001
From: Julian Bouzas <julian.bouzas@collabora.com>
Date: Wed, 4 Jan 2023 10:07:36 -0500
Subject: [PATCH] spa-json: make sure we only add encoded string data
The spa_json_encode_string() API does not add a null terminator character. We
need to use the return value to know the size of the encoded string when adding
it to the builder.
---
lib/wp/spa-json.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/lib/wp/spa-json.c b/lib/wp/spa-json.c
index 1649f64b..6c797cf9 100644
--- a/lib/wp/spa-json.c
+++ b/lib/wp/spa-json.c
@@ -391,9 +391,8 @@ wp_spa_json_new_string (const gchar *value)
{
size_t size = (strlen (value) * 4) + 2;
gchar dst[size];
- spa_json_encode_string (dst, sizeof(dst), value);
- return wp_spa_json_new_from_builder (
- wp_spa_json_builder_new_formatted ("%s", dst));
+ gint enc_size = spa_json_encode_string (dst, sizeof(dst), value);
+ return wp_spa_json_new_from_builder (wp_spa_json_builder_new (dst, enc_size));
}
/* Args is not a pointer in some architectures, so this needs to be a macro to
@@ -970,6 +969,14 @@ builder_add_formatted (WpSpaJsonBuilder *self, const gchar *fmt, ...)
self->size += s;
}
+static void
+builder_add (WpSpaJsonBuilder *self, const gchar *data, size_t size)
+{
+ g_return_if_fail (self->max_size - self->size >= size + 1);
+ snprintf (self->data + self->size, size + 1, "%s", data);
+ self->size += size;
+}
+
static void
builder_add_json (WpSpaJsonBuilder *self, WpSpaJson *json)
{
@@ -990,10 +997,12 @@ wp_spa_json_builder_add_property (WpSpaJsonBuilder *self, const gchar *key)
{
size_t size = (strlen (key) * 4) + 3;
gchar dst[size];
+ gint enc_size;
ensure_separator (self, TRUE);
ensure_allocated_max_size (self, size);
- spa_json_encode_string (dst, sizeof(dst), key);
- builder_add_formatted (self, "%s:", dst);
+ enc_size = spa_json_encode_string (dst, sizeof(dst), key);
+ builder_add (self, dst, enc_size);
+ builder_add (self, ":", 1);
}
/*!
@@ -1067,10 +1076,11 @@ wp_spa_json_builder_add_string (WpSpaJsonBuilder *self, const gchar *value)
{
size_t size = (strlen (value) * 4) + 2;
gchar dst[size];
+ gint enc_size;
ensure_separator (self, FALSE);
ensure_allocated_max_size (self, size);
- spa_json_encode_string (dst, sizeof(dst), value);
- builder_add_formatted (self, "%s", dst);
+ enc_size = spa_json_encode_string (dst, sizeof(dst), value);
+ builder_add (self, dst, enc_size);
}
/*!
--
GitLab

View File

@ -1,3 +1,24 @@
-------------------------------------------------------------------
Fri Jan 13 10:51:07 UTC 2023 - Antonio Larrosa <alarrosa@suse.com>
- Backport the workaround from SLE/Leap for the bug in systemd
scripts that didn't set the default enable state for the
wireplumber user service when installing wireplumber. The bug
(boo#1200485) was fixed but that's only for new installations
while this workaround will fix old installations (boo#1202008).
This is used to automatically fix installations of
SLE 15 SP4/Leap 15.4 that were not updated during it's lifetime
and upgrade directly to SP5/15.5 .
-------------------------------------------------------------------
Wed Jan 11 12:41:28 UTC 2023 - Antonio Larrosa <alarrosa@suse.com>
- Add upstream patches to fix glfo#pipewire/pipewire#2214 and to
handle better non-null terminated strings:
* 0001-alsa-monitor-handle-snd_aloop-devices-better.patch
* 0001-spa-json-make-sure-we-only-add-encoded-string-data.patch
* 0001-m-lua-scripting-ignore-string-integer-table-keys-when-constructing-a-JSON-Array-Object.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Dec 13 14:43:46 UTC 2022 - Alexei Sorokin <sor.alexei@meowr.ru> Tue Dec 13 14:43:46 UTC 2022 - Alexei Sorokin <sor.alexei@meowr.ru>

View File

@ -32,6 +32,13 @@ Source0: wireplumber-%{version}.tar.xz
Source1: split-config-file.py Source1: split-config-file.py
# PATCH-FIX-OPENSUSE reduce-meson-required-version.patch # PATCH-FIX-OPENSUSE reduce-meson-required-version.patch
Patch0: reduce-meson-required-version.patch Patch0: reduce-meson-required-version.patch
# PATCH-FIX-UPSTREAM 0001-alsa-monitor-handle-snd_aloop-devices-better.patch
Patch1: 0001-alsa-monitor-handle-snd_aloop-devices-better.patch
# PATCH-FIX-UPSTREAM 0001-spa-json-make-sure-we-only-add-encoded-string-data.patch
Patch2: 0001-spa-json-make-sure-we-only-add-encoded-string-data.patch
# PATCH-FIX-UPSTREAM 0001-m-lua-scripting-ignore-string-integer-table-keys-when-constructing-a-JSON-Array-Object.patch
Patch3: 0001-m-lua-scripting-ignore-string-integer-table-keys-when-constructing-a-JSON-Array-Object.patch
# docs # docs
BuildRequires: doxygen BuildRequires: doxygen
BuildRequires: graphviz BuildRequires: graphviz
@ -70,6 +77,8 @@ BuildRequires: gcc9-c++
%else %else
BuildRequires: gcc-c++ BuildRequires: gcc-c++
%endif %endif
%{?systemd_ordering}
%description %description
WirePlumber is a modular session / policy manager for PipeWire and WirePlumber is a modular session / policy manager for PipeWire and
@ -140,6 +149,9 @@ the wireplumber shared library.
%if 0%{?suse_version} <= 1500 && 0%{?sle_version} <= 150300 %if 0%{?suse_version} <= 1500 && 0%{?sle_version} <= 150300
%patch0 -p1 %patch0 -p1
%endif %endif
%patch1 -p1
%patch2 -p1
%patch3 -p1
pushd src/config/main.lua.d pushd src/config/main.lua.d
python3 %{SOURCE1} python3 %{SOURCE1}
@ -172,6 +184,29 @@ export XDG_RUNTIME_DIR=/tmp
%post %post
%systemd_user_post wireplumber.service %systemd_user_post wireplumber.service
%if 0%{?suse_version} <= 1500
# If the pipewire.socket user unit is not enabled and the workaround
# for boo#1186561 has never been executed, we need to execute it now
if [ ! -L %{_sysconfdir}/systemd/user/pipewire.service.wants/wireplumber.service \
-a ! -f %{_localstatedir}/lib/pipewire/wireplumber_post_workaround \
-a -x %{_bindir}/systemctl ]; then
for service in wireplumber.service ; do
%{_bindir}/systemctl --global preset "$service" || :
done
mkdir -p %{_localstatedir}/lib/pipewire
cat << EOF > %{_localstatedir}/lib/pipewire/wireplumber_post_workaround
# The existence of this file means that the wireplumber user services were
# enabled at least once. Please don't remove this file as that would
# make the services to be enabled again in the next package update.
#
# Check the following bugs for more information:
# https://bugzilla.opensuse.org/show_bug.cgi?id=1200485
EOF
fi
%endif
%preun %preun
%systemd_user_preun wireplumber.service %systemd_user_preun wireplumber.service