--- src/modules/alsa/alsa-sink.c | 4 +--- src/modules/alsa/alsa-source.c | 4 +--- src/modules/echo-cancel/module-echo-cancel.c | 32 +++++++--------------------- src/modules/macosx/module-bonjour-publish.c | 11 ++++------ src/modules/module-combine-sink.c | 6 +++--- src/modules/module-device-manager.c | 12 +++++------ src/modules/module-equalizer-sink.c | 4 +--- src/modules/module-ladspa-sink.c | 13 ++++------- src/modules/module-loopback.c | 8 +++---- src/modules/module-remap-sink.c | 12 +++-------- src/modules/module-remap-source.c | 12 +++-------- src/modules/module-rygel-media-server.c | 2 +- src/modules/module-virtual-sink.c | 16 ++++++-------- src/modules/module-virtual-source.c | 25 ++++++++-------------- src/modules/module-virtual-surround-sink.c | 16 ++++++-------- src/pulsecore/cli-text.c | 4 ++-- src/pulsecore/protocol-http.c | 4 ++-- src/pulsecore/protocol-native.c | 4 ++-- src/pulsecore/sink.c | 7 ++++++ src/pulsecore/sink.h | 1 + src/pulsecore/source.c | 7 ++++++ src/pulsecore/source.h | 1 + 22 files changed, 82 insertions(+), 123 deletions(-) diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 7c8db2e..fda621b 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -197,14 +197,12 @@ static void reserve_done(struct userdata *u) { } static void reserve_update(struct userdata *u) { - const char *description; pa_assert(u); if (!u->sink || !u->reserve) return; - if ((description = pa_proplist_gets(u->sink->proplist, PA_PROP_DEVICE_DESCRIPTION))) - pa_reserve_wrapper_set_application_device_name(u->reserve, description); + pa_reserve_wrapper_set_application_device_name(u->reserve, pa_sink_get_description(u->sink)); } static int reserve_init(struct userdata *u, const char *dname) { diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index 6541c91..da8222d 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -172,14 +172,12 @@ static void reserve_done(struct userdata *u) { } static void reserve_update(struct userdata *u) { - const char *description; pa_assert(u); if (!u->source || !u->reserve) return; - if ((description = pa_proplist_gets(u->source->proplist, PA_PROP_DEVICE_DESCRIPTION))) - pa_reserve_wrapper_set_application_device_name(u->reserve, description); + pa_reserve_wrapper_set_application_device_name(u->reserve, pa_source_get_description(u->source)); } static int reserve_init(struct userdata *u, const char *dname) { diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c index b45a40c..76c2c62 100644 --- a/src/modules/echo-cancel/module-echo-cancel.c +++ b/src/modules/echo-cancel/module-echo-cancel.c @@ -1464,14 +1464,11 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) { pa_source_set_asyncmsgq(u->source, NULL); if (u->source_auto_desc && dest) { - const char *y, *z; pa_proplist *pl; pl = pa_proplist_new(); - y = pa_proplist_gets(u->sink_input->sink->proplist, PA_PROP_DEVICE_DESCRIPTION); - z = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION); - pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "%s (echo cancelled with %s)", z ? z : dest->name, - y ? y : u->sink_input->sink->name); + pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "%s (echo cancelled with %s)", + pa_source_get_description(dest), pa_sink_get_description(u->sink_input->sink)); pa_source_update_proplist(u->source, PA_UPDATE_REPLACE, pl); pa_proplist_free(pl); @@ -1492,14 +1489,11 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) { pa_sink_set_asyncmsgq(u->sink, NULL); if (u->sink_auto_desc && dest) { - const char *y, *z; pa_proplist *pl; pl = pa_proplist_new(); - y = pa_proplist_gets(u->source_output->source->proplist, PA_PROP_DEVICE_DESCRIPTION); - z = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION); - pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "%s (echo cancelled with %s)", z ? z : dest->name, - y ? y : u->source_output->source->name); + pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "%s (echo cancelled with %s)", pa_sink_get_description(dest), + pa_source_get_description(u->source_output->source)); pa_sink_update_proplist(u->sink, PA_UPDATE_REPLACE, pl); pa_proplist_free(pl); @@ -1791,14 +1785,9 @@ int pa__init(pa_module*m) { goto fail; } - if ((u->source_auto_desc = !pa_proplist_contains(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) { - const char *y, *z; - - y = pa_proplist_gets(sink_master->proplist, PA_PROP_DEVICE_DESCRIPTION); - z = pa_proplist_gets(source_master->proplist, PA_PROP_DEVICE_DESCRIPTION); + if ((u->source_auto_desc = !pa_proplist_contains(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) pa_proplist_setf(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "%s (echo cancelled with %s)", - z ? z : source_master->name, y ? y : sink_master->name); - } + pa_source_get_description(source_master), pa_sink_get_description(sink_master)); u->source = pa_source_new(m->core, &source_data, (source_master->flags & (PA_SOURCE_LATENCY | PA_SOURCE_DYNAMIC_LATENCY)) | (u->use_volume_sharing ? PA_SOURCE_SHARE_VOLUME_WITH_MASTER : 0)); @@ -1842,14 +1831,9 @@ int pa__init(pa_module*m) { goto fail; } - if ((u->sink_auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) { - const char *y, *z; - - y = pa_proplist_gets(source_master->proplist, PA_PROP_DEVICE_DESCRIPTION); - z = pa_proplist_gets(sink_master->proplist, PA_PROP_DEVICE_DESCRIPTION); + if ((u->sink_auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "%s (echo cancelled with %s)", - z ? z : sink_master->name, y ? y : source_master->name); - } + pa_sink_get_description(sink_master), pa_source_get_description(source_master)); u->sink = pa_sink_new(m->core, &sink_data, (sink_master->flags & (PA_SINK_LATENCY | PA_SINK_DYNAMIC_LATENCY)) | (u->use_volume_sharing ? PA_SINK_SHARE_VOLUME_WITH_MASTER : 0)); diff --git a/src/modules/macosx/module-bonjour-publish.c b/src/modules/macosx/module-bonjour-publish.c index d29d518..9d6f77e 100644 --- a/src/modules/macosx/module-bonjour-publish.c +++ b/src/modules/macosx/module-bonjour-publish.c @@ -297,13 +297,10 @@ static struct service *get_service(struct userdata *u, pa_object *device) { s->userdata = u; s->device = device; - if (pa_sink_isinstance(device)) { - if (!(n = pa_proplist_gets(PA_SINK(device)->proplist, PA_PROP_DEVICE_DESCRIPTION))) - n = PA_SINK(device)->name; - } else { - if (!(n = pa_proplist_gets(PA_SOURCE(device)->proplist, PA_PROP_DEVICE_DESCRIPTION))) - n = PA_SOURCE(device)->name; - } + if (pa_sink_isinstance(device)) + n = pa_sink_get_description(PA_SINK(device)); + else + n = pa_source_get_description(PA_SOURCE(device)); hn = pa_get_host_name_malloc(); un = pa_get_user_name_malloc(); diff --git a/src/modules/module-combine-sink.c b/src/modules/module-combine-sink.c index faf65c2..ee5006f 100644 --- a/src/modules/module-combine-sink.c +++ b/src/modules/module-combine-sink.c @@ -833,10 +833,10 @@ static void update_description(struct userdata *u) { char *e; if (first) { - e = pa_sprintf_malloc("%s %s", t, pa_strnull(pa_proplist_gets(o->sink->proplist, PA_PROP_DEVICE_DESCRIPTION))); + e = pa_sprintf_malloc("%s %s", t, pa_sink_get_description(o->sink)); first = FALSE; } else - e = pa_sprintf_malloc("%s, %s", t, pa_strnull(pa_proplist_gets(o->sink->proplist, PA_PROP_DEVICE_DESCRIPTION))); + e = pa_sprintf_malloc("%s, %s", t, pa_sink_get_description(o->sink)); pa_xfree(t); t = e; @@ -857,7 +857,7 @@ static int output_create_sink_input(struct output *o) { pa_sink_input_new_data_init(&data); pa_sink_input_new_data_set_sink(&data, o->sink, FALSE); data.driver = __FILE__; - pa_proplist_setf(data.proplist, PA_PROP_MEDIA_NAME, "Simultaneous output on %s", pa_strnull(pa_proplist_gets(o->sink->proplist, PA_PROP_DEVICE_DESCRIPTION))); + pa_proplist_setf(data.proplist, PA_PROP_MEDIA_NAME, "Simultaneous output on %s", pa_sink_get_description(o->sink)); pa_proplist_sets(data.proplist, PA_PROP_MEDIA_ROLE, "filter"); pa_sink_input_new_data_set_sample_spec(&data, &o->userdata->sink->sample_spec); pa_sink_input_new_data_set_channel_map(&data, &o->userdata->sink->channel_map); diff --git a/src/modules/module-device-manager.c b/src/modules/module-device-manager.c index 57abd06..7db5f52 100644 --- a/src/modules/module-device-manager.c +++ b/src/modules/module-device-manager.c @@ -359,13 +359,13 @@ static void dump_database_helper(struct userdata *u, uint32_t role_index, const if (sink_mode) { pa_sink *s; if (PA_INVALID_INDEX != u->preferred_sinks[role_index] && (s = pa_idxset_get_by_index(u->core->sinks, u->preferred_sinks[role_index]))) - pa_log_debug(" %s %s (%s)", human, pa_strnull(pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION)), s->name); + pa_log_debug(" %s %s (%s)", human, pa_sink_get_description(s), s->name); else pa_log_debug(" %s No sink specified", human); } else { pa_source *s; if (PA_INVALID_INDEX != u->preferred_sources[role_index] && (s = pa_idxset_get_by_index(u->core->sources, u->preferred_sources[role_index]))) - pa_log_debug(" %s %s (%s)", human, pa_strnull(pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION)), s->name); + pa_log_debug(" %s %s (%s)", human, pa_source_get_description(s), s->name); else pa_log_debug(" %s No source specified", human); } @@ -812,8 +812,8 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 if (!entry->user_set_description) { pa_xfree(entry->description); - entry->description = pa_xstrdup(pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_DESCRIPTION)); - } else if (!pa_streq(entry->description, pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_DESCRIPTION))) { + entry->description = pa_xstrdup(pa_sink_get_description(sink)); + } else if (!pa_streq(entry->description, pa_sink_get_description(sink))) { /* Warning: If two modules fight over the description, this could cause an infinite loop. by changing the description here, we retrigger this subscription callback. The only thing stopping us from looping is the fact that the string comparison will fail on the second iteration. If another module tries to manage @@ -842,8 +842,8 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 if (!entry->user_set_description) { pa_xfree(entry->description); - entry->description = pa_xstrdup(pa_proplist_gets(source->proplist, PA_PROP_DEVICE_DESCRIPTION)); - } else if (!pa_streq(entry->description, pa_proplist_gets(source->proplist, PA_PROP_DEVICE_DESCRIPTION))) { + entry->description = pa_xstrdup(pa_source_get_description(source)); + } else if (!pa_streq(entry->description, pa_source_get_description(source))) { /* Warning: If two modules fight over the description, this could cause an infinite loop. by changing the description here, we retrigger this subscription callback. The only thing stopping us from looping is the fact that the string comparison will fail on the second iteration. If another module tries to manage diff --git a/src/modules/module-equalizer-sink.c b/src/modules/module-equalizer-sink.c index da4dd77..84009b4 100644 --- a/src/modules/module-equalizer-sink.c +++ b/src/modules/module-equalizer-sink.c @@ -1085,7 +1085,6 @@ int pa__init(pa_module*m) { pa_sample_spec ss; pa_channel_map map; pa_modargs *ma; - const char *z; pa_sink *master; pa_sink_input_new_data sink_input_data; pa_sink_new_data sink_data; @@ -1177,8 +1176,7 @@ int pa__init(pa_module*m) { pa_sink_new_data_set_sample_spec(&sink_data, &ss); pa_sink_new_data_set_channel_map(&sink_data, &map); - z = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION); - pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "FFT based equalizer on %s", z ? z : master->name); + pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "FFT based equalizer on %s", pa_sink_get_description(master)); pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_MASTER_DEVICE, master->name); pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_CLASS, "filter"); diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c index 6a757e4..3fb2294 100644 --- a/src/modules/module-ladspa-sink.c +++ b/src/modules/module-ladspa-sink.c @@ -655,13 +655,11 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) { pa_sink_set_asyncmsgq(u->sink, NULL); if (u->auto_desc && dest) { - const char *z; pa_proplist *pl; pl = pa_proplist_new(); - z = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION); pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "LADSPA Plugin %s on %s", - pa_proplist_gets(u->sink->proplist, "device.ladspa.name"), z ? z : dest->name); + pa_proplist_gets(u->sink->proplist, "device.ladspa.name"), pa_sink_get_description(dest)); pa_sink_update_proplist(u->sink, PA_UPDATE_REPLACE, pl); pa_proplist_free(pl); @@ -1230,12 +1228,9 @@ int pa__init(pa_module*m) { goto fail; } - if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) { - const char *z; - - z = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION); - pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "LADSPA Plugin %s on %s", d->Name, z ? z : master->name); - } + if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) + pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, + "LADSPA Plugin %s on %s", d->Name, pa_sink_get_description(master)); u->sink = pa_sink_new(m->core, &sink_data, (master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY)) | PA_SINK_SHARE_VOLUME_WITH_MASTER); diff --git a/src/modules/module-loopback.c b/src/modules/module-loopback.c index 6017891..89a5211 100644 --- a/src/modules/module-loopback.c +++ b/src/modules/module-loopback.c @@ -412,7 +412,7 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) { pa_assert_se(u = o->userdata); p = pa_proplist_new(); - pa_proplist_setf(p, PA_PROP_MEDIA_NAME, "Loopback of %s", pa_strnull(pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION))); + pa_proplist_setf(p, PA_PROP_MEDIA_NAME, "Loopback of %s", pa_source_get_description(dest)); if ((n = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_ICON_NAME))) pa_proplist_sets(p, PA_PROP_MEDIA_ICON_NAME, n); @@ -677,7 +677,7 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) { pa_assert_se(u = i->userdata); p = pa_proplist_new(); - pa_proplist_setf(p, PA_PROP_MEDIA_NAME, "Loopback to %s", pa_strnull(pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION))); + pa_proplist_setf(p, PA_PROP_MEDIA_NAME, "Loopback to %s", pa_sink_get_description(dest)); if ((n = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_ICON_NAME))) pa_proplist_sets(p, PA_PROP_MEDIA_ICON_NAME, n); @@ -954,7 +954,7 @@ int pa__init(pa_module *m) { if (!pa_proplist_contains(u->source_output->proplist, PA_PROP_MEDIA_NAME)) pa_proplist_setf(u->source_output->proplist, PA_PROP_MEDIA_NAME, "Loopback to %s", - pa_strnull(pa_proplist_gets(u->sink_input->sink->proplist, PA_PROP_DEVICE_DESCRIPTION))); + pa_sink_get_description(u->sink_input->sink)); if (!pa_proplist_contains(u->source_output->proplist, PA_PROP_MEDIA_ICON_NAME) && (n = pa_proplist_gets(u->sink_input->sink->proplist, PA_PROP_DEVICE_ICON_NAME))) @@ -962,7 +962,7 @@ int pa__init(pa_module *m) { if (!pa_proplist_contains(u->sink_input->proplist, PA_PROP_MEDIA_NAME)) pa_proplist_setf(u->sink_input->proplist, PA_PROP_MEDIA_NAME, "Loopback from %s", - pa_strnull(pa_proplist_gets(u->source_output->source->proplist, PA_PROP_DEVICE_DESCRIPTION))); + pa_source_get_description(u->source_output->source)); if (source && !pa_proplist_contains(u->sink_input->proplist, PA_PROP_MEDIA_ICON_NAME) && (n = pa_proplist_gets(u->source_output->source->proplist, PA_PROP_DEVICE_ICON_NAME))) diff --git a/src/modules/module-remap-sink.c b/src/modules/module-remap-sink.c index 3d9567b..e5f7e0c 100644 --- a/src/modules/module-remap-sink.c +++ b/src/modules/module-remap-sink.c @@ -303,12 +303,10 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) { pa_sink_set_asyncmsgq(u->sink, NULL); if (u->auto_desc && dest) { - const char *k; pa_proplist *pl; pl = pa_proplist_new(); - k = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION); - pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "Remapped %s", k ? k : dest->name); + pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "Remapped %s", pa_sink_get_description(dest)); pa_sink_update_proplist(u->sink, PA_UPDATE_REPLACE, pl); pa_proplist_free(pl); @@ -384,12 +382,8 @@ int pa__init(pa_module*m) { goto fail; } - if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) { - const char *k; - - k = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION); - pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Remapped %s", k ? k : master->name); - } + if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) + pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Remapped %s", pa_sink_get_description(master)); u->sink = pa_sink_new(m->core, &sink_data, master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY)); pa_sink_new_data_done(&sink_data); diff --git a/src/modules/module-remap-source.c b/src/modules/module-remap-source.c index c47d9b0..2e28027 100644 --- a/src/modules/module-remap-source.c +++ b/src/modules/module-remap-source.c @@ -249,12 +249,10 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) { pa_source_set_asyncmsgq(u->source, NULL); if (u->auto_desc && dest) { - const char *k; pa_proplist *pl; pl = pa_proplist_new(); - k = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION); - pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "Remapped %s", k ? k : dest->name); + pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "Remapped %s", pa_source_get_description(dest)); pa_source_update_proplist(u->source, PA_UPDATE_REPLACE, pl); pa_proplist_free(pl); @@ -330,12 +328,8 @@ int pa__init(pa_module*m) { goto fail; } - if ((u->auto_desc = !pa_proplist_contains(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) { - const char *k; - - k = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION); - pa_proplist_setf(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Remapped %s", k ? k : master->name); - } + if ((u->auto_desc = !pa_proplist_contains(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) + pa_proplist_setf(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Remapped %s", pa_source_get_description(master)); u->source = pa_source_new(m->core, &source_data, master->flags & (PA_SOURCE_LATENCY|PA_SOURCE_DYNAMIC_LATENCY)); pa_source_new_data_done(&source_data); diff --git a/src/modules/module-rygel-media-server.c b/src/modules/module-rygel-media-server.c index 855d7bb..b22586b 100644 --- a/src/modules/module-rygel-media-server.c +++ b/src/modules/module-rygel-media-server.c @@ -378,7 +378,7 @@ static void append_variant_item_display_name(DBusMessage *m, DBusMessageIter *it pa_assert(sink || source); - display_name = pa_strna(pa_proplist_gets(sink ? sink->proplist : source->proplist, PA_PROP_DEVICE_DESCRIPTION)); + display_name = sink ? pa_sink_get_description(sink) : pa_source_get_description(source); append_variant_string(m, iter, display_name); } diff --git a/src/modules/module-virtual-sink.c b/src/modules/module-virtual-sink.c index 4f91fe0..7e847f3 100644 --- a/src/modules/module-virtual-sink.c +++ b/src/modules/module-virtual-sink.c @@ -431,13 +431,11 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) { pa_sink_set_asyncmsgq(u->sink, NULL); if (u->auto_desc && dest) { - const char *z; pa_proplist *pl; pl = pa_proplist_new(); - z = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION); pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "Virtual Sink %s on %s", - pa_proplist_gets(u->sink->proplist, "device.vsink.name"), z ? z : dest->name); + pa_proplist_gets(u->sink->proplist, "device.vsink.name"), pa_sink_get_description(dest)); pa_sink_update_proplist(u->sink, PA_UPDATE_REPLACE, pl); pa_proplist_free(pl); @@ -536,12 +534,9 @@ int pa__init(pa_module*m) { goto fail; } - if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) { - const char *z; - - z = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION); - pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Virtual Sink %s on %s", sink_data.name, z ? z : master->name); - } + if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) + pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, + "Virtual Sink %s on %s", sink_data.name, pa_sink_get_description(master)); u->sink = pa_sink_new(m->core, &sink_data, (master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY)) | (use_volume_sharing ? PA_SINK_SHARE_VOLUME_WITH_MASTER : 0)); @@ -574,7 +569,8 @@ int pa__init(pa_module*m) { sink_input_data.module = m; pa_sink_input_new_data_set_sink(&sink_input_data, master, FALSE); sink_input_data.origin_sink = u->sink; - pa_proplist_setf(sink_input_data.proplist, PA_PROP_MEDIA_NAME, "Virtual Sink Stream from %s", pa_proplist_gets(u->sink->proplist, PA_PROP_DEVICE_DESCRIPTION)); + pa_proplist_setf(sink_input_data.proplist, PA_PROP_MEDIA_NAME, + "Virtual Sink Stream from %s", pa_sink_get_description(u->sink)); pa_proplist_sets(sink_input_data.proplist, PA_PROP_MEDIA_ROLE, "filter"); pa_sink_input_new_data_set_sample_spec(&sink_input_data, &ss); pa_sink_input_new_data_set_channel_map(&sink_input_data, &map); diff --git a/src/modules/module-virtual-source.c b/src/modules/module-virtual-source.c index 58041e7..25f20cd 100644 --- a/src/modules/module-virtual-source.c +++ b/src/modules/module-virtual-source.c @@ -454,13 +454,11 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) { pa_source_set_asyncmsgq(u->source, NULL); if (u->auto_desc && dest) { - const char *z; pa_proplist *pl; pl = pa_proplist_new(); - z = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION); pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "Virtual Source %s on %s", - pa_proplist_gets(u->source->proplist, "device.vsource.name"), z ? z : dest->name); + pa_proplist_gets(u->source->proplist, "device.vsource.name"), pa_source_get_description(dest)); pa_source_update_proplist(u->source, PA_UPDATE_REPLACE, pl); pa_proplist_free(pl); @@ -548,12 +546,9 @@ int pa__init(pa_module*m) { goto fail; } - if ((u->auto_desc = !pa_proplist_contains(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) { - const char *z; - - z = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION); - pa_proplist_setf(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Virtual Source %s on %s", source_data.name, z ? z : master->name); - } + if ((u->auto_desc = !pa_proplist_contains(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) + pa_proplist_setf(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, + "Virtual Source %s on %s", source_data.name, pa_source_get_description(master)); u->source = pa_source_new(m->core, &source_data, (master->flags & (PA_SOURCE_LATENCY|PA_SOURCE_DYNAMIC_LATENCY)) | (use_volume_sharing ? PA_SOURCE_SHARE_VOLUME_WITH_MASTER : 0)); @@ -587,7 +582,8 @@ int pa__init(pa_module*m) { pa_source_output_new_data_set_source(&source_output_data, master, FALSE); source_output_data.destination_source = u->source; - pa_proplist_setf(source_output_data.proplist, PA_PROP_MEDIA_NAME, "Virtual Source Stream of %s", pa_proplist_gets(u->source->proplist, PA_PROP_DEVICE_DESCRIPTION)); + pa_proplist_setf(source_output_data.proplist, PA_PROP_MEDIA_NAME, + "Virtual Source Stream of %s", pa_source_get_description(u->source)); pa_proplist_sets(source_output_data.proplist, PA_PROP_MEDIA_ROLE, "filter"); pa_source_output_new_data_set_sample_spec(&source_output_data, &ss); pa_source_output_new_data_set_channel_map(&source_output_data, &map); @@ -623,12 +619,9 @@ int pa__init(pa_module*m) { pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_CLASS, "uplink sink"); pa_proplist_sets(sink_data.proplist, "device.uplink_sink.name", sink_data.name); - if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) { - const char *z; - - z = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION); - pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Uplink Sink %s on %s", sink_data.name, z ? z : master->name); - } + if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) + pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, + "Uplink Sink %s on %s", sink_data.name, pa_source_get_description(master)); u->sink_memblockq = pa_memblockq_new("module-virtual-source sink_memblockq", 0, MEMBLOCKQ_MAXLENGTH, 0, &ss, 1, 1, 0, NULL); if (!u->sink_memblockq) { diff --git a/src/modules/module-virtual-surround-sink.c b/src/modules/module-virtual-surround-sink.c index bcca8d0..2b646af 100644 --- a/src/modules/module-virtual-surround-sink.c +++ b/src/modules/module-virtual-surround-sink.c @@ -443,13 +443,11 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) { pa_sink_set_asyncmsgq(u->sink, NULL); if (u->auto_desc && dest) { - const char *z; pa_proplist *pl; pl = pa_proplist_new(); - z = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION); pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "Virtual Surround Sink %s on %s", - pa_proplist_gets(u->sink->proplist, "device.vsurroundsink.name"), z ? z : dest->name); + pa_proplist_gets(u->sink->proplist, "device.vsurroundsink.name"), pa_sink_get_description(dest)); pa_sink_update_proplist(u->sink, PA_UPDATE_REPLACE, pl); pa_proplist_free(pl); @@ -638,12 +636,9 @@ int pa__init(pa_module*m) { goto fail; } - if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) { - const char *z; - - z = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION); - pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Virtual Surround Sink %s on %s", sink_data.name, z ? z : master->name); - } + if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) + pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, + "Virtual Surround Sink %s on %s", sink_data.name, pa_sink_get_description(master)); u->sink = pa_sink_new(m->core, &sink_data, (master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY)) | (use_volume_sharing ? PA_SINK_SHARE_VOLUME_WITH_MASTER : 0)); @@ -676,7 +671,8 @@ int pa__init(pa_module*m) { sink_input_data.module = m; pa_sink_input_new_data_set_sink(&sink_input_data, master, FALSE); sink_input_data.origin_sink = u->sink; - pa_proplist_setf(sink_input_data.proplist, PA_PROP_MEDIA_NAME, "Virtual Surround Sink Stream from %s", pa_proplist_gets(u->sink->proplist, PA_PROP_DEVICE_DESCRIPTION)); + pa_proplist_setf(sink_input_data.proplist, PA_PROP_MEDIA_NAME, + "Virtual Surround Sink Stream from %s", pa_sink_get_description(u->sink)); pa_proplist_sets(sink_input_data.proplist, PA_PROP_MEDIA_ROLE, "filter"); pa_sink_input_new_data_set_sample_spec(&sink_input_data, &sink_input_ss); pa_sink_input_new_data_set_channel_map(&sink_input_data, &sink_input_map); diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c index 85c97b3..68496b0 100644 --- a/src/pulsecore/cli-text.c +++ b/src/pulsecore/cli-text.c @@ -184,13 +184,13 @@ char *pa_card_list_to_string(pa_core *c) { if (!pa_idxset_isempty(card->sinks)) { pa_strbuf_puts(s, "\tsinks:\n"); PA_IDXSET_FOREACH(sink, card->sinks, sidx) - pa_strbuf_printf(s, "\t\t%s/#%u: %s\n", sink->name, sink->index, pa_strna(pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_DESCRIPTION))); + pa_strbuf_printf(s, "\t\t%s/#%u: %s\n", sink->name, sink->index, pa_sink_get_description(sink)); } if (!pa_idxset_isempty(card->sources)) { pa_strbuf_puts(s, "\tsources:\n"); PA_IDXSET_FOREACH(source, card->sources, sidx) - pa_strbuf_printf(s, "\t\t%s/#%u: %s\n", source->name, source->index, pa_strna(pa_proplist_gets(source->proplist, PA_PROP_DEVICE_DESCRIPTION))); + pa_strbuf_printf(s, "\t\t%s/#%u: %s\n", source->name, source->index, pa_source_get_description(source)); } append_port_list(s, card->ports); diff --git a/src/pulsecore/protocol-http.c b/src/pulsecore/protocol-http.c index 52571d3..34f2e95 100644 --- a/src/pulsecore/protocol-http.c +++ b/src/pulsecore/protocol-http.c @@ -471,7 +471,7 @@ static void handle_listen(struct connection *c) { PA_IDXSET_FOREACH(sink, c->protocol->core->sinks, idx) { char *t, *m; - t = escape_html(pa_strna(pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_DESCRIPTION))); + t = escape_html(pa_sink_get_description(sink)); m = pa_sample_spec_to_mime_type_mimefy(&sink->sample_spec, &sink->channel_map); pa_ioline_printf(c->line, @@ -493,7 +493,7 @@ static void handle_listen(struct connection *c) { if (source->monitor_of) continue; - t = escape_html(pa_strna(pa_proplist_gets(source->proplist, PA_PROP_DEVICE_DESCRIPTION))); + t = escape_html(pa_source_get_description(source)); m = pa_sample_spec_to_mime_type_mimefy(&source->sample_spec, &source->channel_map); pa_ioline_printf(c->line, diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 708878e..6d5b388 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -3129,7 +3129,7 @@ static void sink_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sin t, PA_TAG_U32, sink->index, PA_TAG_STRING, sink->name, - PA_TAG_STRING, pa_strnull(pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_DESCRIPTION)), + PA_TAG_STRING, pa_sink_get_description(sink), PA_TAG_SAMPLE_SPEC, &fixed_ss, PA_TAG_CHANNEL_MAP, &sink->channel_map, PA_TAG_U32, sink->module ? sink->module->index : PA_INVALID_INDEX, @@ -3199,7 +3199,7 @@ static void source_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_s t, PA_TAG_U32, source->index, PA_TAG_STRING, source->name, - PA_TAG_STRING, pa_strnull(pa_proplist_gets(source->proplist, PA_PROP_DEVICE_DESCRIPTION)), + PA_TAG_STRING, pa_source_get_description(source), PA_TAG_SAMPLE_SPEC, &fixed_ss, PA_TAG_CHANNEL_MAP, &source->channel_map, PA_TAG_U32, source->module ? source->module->index : PA_INVALID_INDEX, diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 4599f8a..c6699ef 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -1378,6 +1378,13 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) { pa_sink_unref(s); } +/* Called from the main thread. */ +const char *pa_sink_get_description(pa_sink *s) { + pa_assert(s); + + return pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION); +} + /* Called from main thread */ pa_bool_t pa_sink_update_rate(pa_sink *s, uint32_t rate, pa_bool_t passthrough) { diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h index 3c0fc39..8a14bc0 100644 --- a/src/pulsecore/sink.h +++ b/src/pulsecore/sink.h @@ -411,6 +411,7 @@ unsigned pa_device_init_priority(pa_proplist *p); /**** May be called by everyone, from main context */ +const char *pa_sink_get_description(pa_sink *s); pa_bool_t pa_sink_update_rate(pa_sink *s, uint32_t rate, pa_bool_t passthrough); void pa_sink_set_latency_offset(pa_sink *s, int64_t offset); diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c index b3b4d2a..bb4179f 100644 --- a/src/pulsecore/source.c +++ b/src/pulsecore/source.c @@ -2557,6 +2557,13 @@ void pa_source_set_fixed_latency_within_thread(pa_source *s, pa_usec_t latency) pa_source_invalidate_requested_latency(s, FALSE); } +/* Called from the main thread. */ +const char *pa_source_get_description(pa_source *s) { + pa_assert(s); + + return pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION); +} + /* Called from main thread */ void pa_source_set_latency_offset(pa_source *s, int64_t offset) { pa_source_assert_ref(s); diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h index 224155b..d3b61ad 100644 --- a/src/pulsecore/source.h +++ b/src/pulsecore/source.h @@ -344,6 +344,7 @@ void pa_source_update_flags(pa_source *s, pa_source_flags_t mask, pa_source_flag /*** May be called by everyone, from main context */ +const char *pa_source_get_description(pa_source *s); void pa_source_set_latency_offset(pa_source *s, int64_t offset); /* The returned value is supposed to be in the time domain of the sound card! */ -- 1.8.1.2