From 44d96ed4b9b721331fcca4aeb763f04c8fac6dda Mon Sep 17 00:00:00 2001 From: Silviu Florian Barbulescu Date: Fri, 10 May 2024 17:09:41 +0300 Subject: [PATCH] bluez: on metadata, parse remove the length field, and deduce the length from the value plus type --- doc/dox/config/pipewire-devices.7.md | 1 - spa/plugins/bluez5/bluez5-dbus.c | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/dox/config/pipewire-devices.7.md b/doc/dox/config/pipewire-devices.7.md index 8dadfbab2..a662a0cbd 100644 --- a/doc/dox/config/pipewire-devices.7.md +++ b/doc/dox/config/pipewire-devices.7.md @@ -436,7 +436,6 @@ example JSON "audio_channel_allocation": 1, // audio channel allocation configuration for the BIS "metadata": [ // metadata configurations for the BIS { - "length": 3, "type": 1, "value": [ 1, 1 diff --git a/spa/plugins/bluez5/bluez5-dbus.c b/spa/plugins/bluez5/bluez5-dbus.c index 97cf654c2..72c9ac089 100644 --- a/spa/plugins/bluez5/bluez5-dbus.c +++ b/spa/plugins/bluez5/bluez5-dbus.c @@ -6127,24 +6127,22 @@ static void parse_broadcast_source_config(struct spa_bt_monitor *monitor, const while (spa_json_enter_object(&it_array[2], &it[3]) > 0) { metadata_entry = calloc(1, sizeof(struct spa_bt_metadata)); while (spa_json_get_string(&it[3], qos_key, sizeof(qos_key)) > 0) { - if (spa_streq(qos_key, "length")) { - if (spa_json_get_int(&it[3], &metadata_entry->length) <= 0) - goto parse_failed; - spa_log_debug(monitor->log, "metadata_entry->length %d", metadata_entry->length); - } else if (spa_streq(qos_key, "type")) { + if (spa_streq(qos_key, "type")) { if (spa_json_get_int(&it[3], &metadata_entry->type) <= 0) goto parse_failed; spa_log_debug(monitor->log, "metadata_entry->type %d", metadata_entry->type); } else if (spa_streq(qos_key, "value")) { if (spa_json_enter_array(&it[3], &it_array[3]) <= 0) goto parse_failed; - cursor = 0; for (cursor = 0; cursor < METADATA_MAX_LEN; cursor++) { if (spa_json_get_int(&it_array[3], &temp_val) <= 0) break; metadata_entry->value[cursor] = (uint8_t)temp_val; spa_log_debug(monitor->log, "metadata_entry->value[cursor] %d", metadata_entry->value[cursor]); } + /* length is size of value plus 1 octet for type */ + metadata_entry->length = cursor + 1; + spa_log_debug(monitor->log, "metadata_entry->length %d", metadata_entry->length); spa_log_debug(monitor->log, "metadata_entry->value_size %d", cursor); spa_list_append(&bis_entry->metadata_list, &metadata_entry->link); metadata_entry = NULL;