From 1efd5f185c4863e51f26146dd15d0d3886eacb1d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 4 Dec 2018 13:38:23 +0100 Subject: [PATCH] proplist: implement merge mode --- src/proplist.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/proplist.c b/src/proplist.c index fad5c1a5f..7aba67bed 100644 --- a/src/proplist.c +++ b/src/proplist.c @@ -158,14 +158,27 @@ int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t * void pa_proplist_update(pa_proplist *p, pa_update_mode_t mode, const pa_proplist *other) { + int i; + spa_assert(p); spa_assert(mode == PA_UPDATE_SET || mode == PA_UPDATE_MERGE || mode == PA_UPDATE_REPLACE); spa_assert(other); + if (mode == PA_UPDATE_REPLACE) { + pa_proplist_update_dict(p, &other->props->dict); + return; + } + if (mode == PA_UPDATE_SET) pa_proplist_clear(p); - pa_proplist_update_dict(p, &other->props->dict); + for (i = 0; i < other->props->dict.n_items; i++) { + const struct spa_dict_item *oi; + + oi = &other->props->dict.items[i]; + if (pw_properties_get(p->props, oi->key) == NULL) + pw_properties_set(p->props, oi->key, oi->value); + } } int pa_proplist_unset(pa_proplist *p, const char *key)