[pulseaudio-discuss] [PATCH v3 02/18] sink, source: Disallow NULL or empty description
Tanu Kaskinen
tanu.kaskinen at linux.intel.com
Wed Jul 3 04:09:05 PDT 2013
---
src/pulsecore/sink.c | 16 ++++++----------
src/pulsecore/source.c | 14 +++++---------
2 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index cf3a90e..f06a20e 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -2295,29 +2295,25 @@ 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(*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..cda183d 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -1852,24 +1852,20 @@ 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(*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