[pulseaudio-discuss] [PATCH v2 02/18] sink, source: Disallow setting NULL description

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Fri Jun 28 00:47:56 PDT 2013


---
 src/pulsecore/sink.c   | 15 +++++----------
 src/pulsecore/source.c | 13 ++++---------
 2 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index cf3a90e..3d039b4 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -2295,29 +2295,24 @@ pa_bool_t pa_sink_update_proplist(pa_sink *s, pa_update_mode_t mode, pa_proplist
 }
 
 /* Called from main thread */
-/* FIXME -- this should be dropped and be merged into pa_sink_update_proplist() */
 void pa_sink_set_description(pa_sink *s, const char *description) {
     const char *old;
+
     pa_sink_assert_ref(s);
+    pa_assert(description);
     pa_assert_ctl_context();
 
-    if (!description && !pa_proplist_contains(s->proplist, PA_PROP_DEVICE_DESCRIPTION))
-        return;
-
     old = pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
 
-    if (old && description && pa_streq(old, description))
+    if (old && pa_streq(old, description))
         return;
 
-    if (description)
-        pa_proplist_sets(s->proplist, PA_PROP_DEVICE_DESCRIPTION, description);
-    else
-        pa_proplist_unset(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
+    pa_proplist_sets(s->proplist, PA_PROP_DEVICE_DESCRIPTION, description);
 
     if (s->monitor_source) {
         char *n;
 
-        n = pa_sprintf_malloc("Monitor Source of %s", description ? description : s->name);
+        n = pa_sprintf_malloc("Monitor Source of %s", description);
         pa_source_set_description(s->monitor_source, n);
         pa_xfree(n);
     }
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 98a8bcc..aaa0542 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -1852,24 +1852,19 @@ pa_bool_t pa_source_update_proplist(pa_source *s, pa_update_mode_t mode, pa_prop
 }
 
 /* Called from main thread */
-/* FIXME -- this should be dropped and be merged into pa_source_update_proplist() */
 void pa_source_set_description(pa_source *s, const char *description) {
     const char *old;
+
     pa_source_assert_ref(s);
+    pa_assert(description);
     pa_assert_ctl_context();
 
-    if (!description && !pa_proplist_contains(s->proplist, PA_PROP_DEVICE_DESCRIPTION))
-        return;
-
     old = pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
 
-    if (old && description && pa_streq(old, description))
+    if (old && pa_streq(old, description))
         return;
 
-    if (description)
-        pa_proplist_sets(s->proplist, PA_PROP_DEVICE_DESCRIPTION, description);
-    else
-        pa_proplist_unset(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
+    pa_proplist_sets(s->proplist, PA_PROP_DEVICE_DESCRIPTION, description);
 
     if (PA_SOURCE_IS_LINKED(s->state)) {
         pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
-- 
1.8.1.2



More information about the pulseaudio-discuss mailing list