From 00797b8b6ea7978f862facb7181fb04895caf23c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 5 Jun 2009 19:05:07 +0200 Subject: core: add a suspend cause flags field --- src/pulsecore/sink.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/pulsecore/sink.c') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 28b3440c..3c4adc6c 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -190,6 +190,7 @@ pa_sink* pa_sink_new( s->core = core; s->state = PA_SINK_INIT; s->flags = flags; + s->suspend_cause = 0; s->name = pa_xstrdup(name); s->proplist = pa_proplist_copy(data->proplist); s->driver = pa_xstrdup(pa_path_get_filename(data->driver)); @@ -499,11 +500,19 @@ int pa_sink_update_status(pa_sink*s) { } /* Called from main context */ -int pa_sink_suspend(pa_sink *s, pa_bool_t suspend) { +int pa_sink_suspend(pa_sink *s, pa_bool_t suspend, pa_suspend_cause_t cause) { pa_sink_assert_ref(s); pa_assert(PA_SINK_IS_LINKED(s->state)); + pa_assert(cause != 0); if (suspend) + s->suspend_cause |= cause; + else + s->suspend_cause &= ~cause; + + pa_log_debug("Suspend cause of sink %s is 0x%04x, %s", s->name, s->suspend_cause, s->suspend_cause ? "suspending" : "resuming"); + + if (s->suspend_cause) return sink_set_state(s, PA_SINK_SUSPENDED); else return sink_set_state(s, pa_sink_used_by(s) ? PA_SINK_RUNNING : PA_SINK_IDLE); @@ -1823,17 +1832,18 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse } /* Called from main thread */ -int pa_sink_suspend_all(pa_core *c, pa_bool_t suspend) { +int pa_sink_suspend_all(pa_core *c, pa_bool_t suspend, pa_suspend_cause_t cause) { pa_sink *sink; uint32_t idx; int ret = 0; pa_core_assert_ref(c); + pa_assert(cause != 0); for (sink = PA_SINK(pa_idxset_first(c->sinks, &idx)); sink; sink = PA_SINK(pa_idxset_next(c->sinks, &idx))) { int r; - if ((r = pa_sink_suspend(sink, suspend)) < 0) + if ((r = pa_sink_suspend(sink, suspend, cause)) < 0) ret = r; } -- cgit From 69eab1e057e000951516cfd381846c33abc8aaf1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 6 Jun 2009 15:31:46 +0200 Subject: core: suppress suspending/resume when we are already in the right state --- src/pulsecore/sink.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/pulsecore/sink.c') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 3c4adc6c..a087e42d 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -510,6 +510,9 @@ int pa_sink_suspend(pa_sink *s, pa_bool_t suspend, pa_suspend_cause_t cause) { else s->suspend_cause &= ~cause; + if ((pa_sink_get_state(s) == PA_SINK_SUSPENDED) == !!s->suspend_cause) + return 0; + pa_log_debug("Suspend cause of sink %s is 0x%04x, %s", s->name, s->suspend_cause, s->suspend_cause ? "suspending" : "resuming"); if (s->suspend_cause) -- cgit From d1646f78af6a43928cb0cd6b3e8d45578c489cb1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 6 Jun 2009 15:32:45 +0200 Subject: core: monitor sources need to inherit the suspend cause from their sinks --- src/pulsecore/sink.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/pulsecore/sink.c') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index a087e42d..141084d6 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -505,10 +505,13 @@ int pa_sink_suspend(pa_sink *s, pa_bool_t suspend, pa_suspend_cause_t cause) { pa_assert(PA_SINK_IS_LINKED(s->state)); pa_assert(cause != 0); - if (suspend) + if (suspend) { s->suspend_cause |= cause; - else + s->monitor_source->suspend_cause |= cause; + } else { s->suspend_cause &= ~cause; + s->monitor_source->suspend_cause &= ~cause; + } if ((pa_sink_get_state(s) == PA_SINK_SUSPENDED) == !!s->suspend_cause) return 0; -- cgit From 8eaea3aa6471b7d0e78d110752847db5b213c85a Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Thu, 14 May 2009 09:42:52 +0300 Subject: optimization: Optimized pa_sink_render_full. This is finally the latest version of the patch. --- src/pulsecore/sink.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/pulsecore/sink.c') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 141084d6..db9b4f3a 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -1025,14 +1025,13 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) { pa_memchunk chunk; size_t l, d; pa_memchunk_make_writable(result, length); - result->length = length; l = length - result->length; d = result->index + result->length; while (l > 0) { chunk = *result; - chunk.index += d; - chunk.length -= d - result->index; + chunk.index = d; + chunk.length = l; pa_sink_render_into(s, &chunk); -- cgit From 587fc2ab1c7b53ddd28f35e19aad55caa804de1f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 8 Jun 2009 00:02:15 +0200 Subject: core: make sure soft mute status stays in sync with hw mute status This should close rhbz #494851, mandriva bz #51234. Probably the same as our own #572, launchpad #352732. --- src/pulsecore/sink.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/pulsecore/sink.c') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index db9b4f3a..5d54d839 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -1365,8 +1365,12 @@ pa_bool_t pa_sink_get_mute(pa_sink *s, pa_bool_t force_refresh) { pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_GET_MUTE, NULL, 0, NULL) == 0); - if (old_muted != s->muted) + if (old_muted != s->muted) { pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index); + + /* Make sure the soft mute status stays in sync */ + pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_MUTE, NULL, 0, NULL) == 0); + } } return s->muted; -- cgit From e7a6d53118315ff12896707e42528bda5e5d9eab Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 8 Jun 2009 00:12:20 +0200 Subject: core: replace tabs by spaces --- src/pulsecore/sink.c | 62 ++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'src/pulsecore/sink.c') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 5d54d839..13f0e11e 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -973,21 +973,21 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) { n = fill_mix_info(s, &length1st, info, MAX_MIX_CHANNELS); if (n == 0) { - pa_silence_memchunk_get(&s->core->silence_cache, - s->core->mempool, - result, - &s->sample_spec, - length1st); + pa_silence_memchunk_get(&s->core->silence_cache, + s->core->mempool, + result, + &s->sample_spec, + length1st); } else if (n == 1) { - pa_cvolume volume; + pa_cvolume volume; - *result = info[0].chunk; - pa_memblock_ref(result->memblock); + *result = info[0].chunk; + pa_memblock_ref(result->memblock); - if (result->length > length) - result->length = length; + if (result->length > length) + result->length = length; - pa_sw_cvolume_multiply(&volume, &s->thread_info.soft_volume, &info[0].volume); + pa_sw_cvolume_multiply(&volume, &s->thread_info.soft_volume, &info[0].volume); if (s->thread_info.soft_muted || !pa_cvolume_is_norm(&volume)) { if (s->thread_info.soft_muted || pa_cvolume_is_muted(&volume)) { @@ -1005,10 +1005,10 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) { } else { void *ptr; - result->index = 0; - result->memblock = pa_memblock_new(s->core->mempool, length); + result->index = 0; + result->memblock = pa_memblock_new(s->core->mempool, length); - ptr = pa_memblock_acquire(result->memblock); + ptr = pa_memblock_acquire(result->memblock); result->length = pa_mix(info, n, (uint8_t*) ptr + result->index, length1st, @@ -1022,23 +1022,23 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) { inputs_drop(s, info, n, result); if (result->length < length) { - pa_memchunk chunk; - size_t l, d; - pa_memchunk_make_writable(result, length); - - l = length - result->length; - d = result->index + result->length; - while (l > 0) { - chunk = *result; - chunk.index = d; - chunk.length = l; - - pa_sink_render_into(s, &chunk); - - d += chunk.length; - l -= chunk.length; - } - result->length = length; + pa_memchunk chunk; + size_t l, d; + pa_memchunk_make_writable(result, length); + + l = length - result->length; + d = result->index + result->length; + while (l > 0) { + chunk = *result; + chunk.index = d; + chunk.length = l; + + pa_sink_render_into(s, &chunk); + + d += chunk.length; + l -= chunk.length; + } + result->length = length; } pa_sink_unref(s); -- cgit From f13bbd576fef8911275c8eed41ef425163b70398 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 8 Jun 2009 16:58:45 +0200 Subject: prop: introduce new PA_PROP_DEVICE_INTENDED_ROLES property --- src/pulsecore/sink.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/pulsecore/sink.c') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 13f0e11e..1da094af 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -177,6 +177,7 @@ pa_sink* pa_sink_new( pa_device_init_description(data->proplist); pa_device_init_icon(data->proplist, TRUE); + pa_device_init_intended_roles(data->proplist); if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_FIXATE], data) < 0) { pa_xfree(s); @@ -2287,3 +2288,19 @@ pa_bool_t pa_device_init_description(pa_proplist *p) { return FALSE; } + +pa_bool_t pa_device_init_intended_roles(pa_proplist *p) { + const char *s; + pa_assert(p); + + if (pa_proplist_contains(p, PA_PROP_DEVICE_INTENDED_ROLES)) + return TRUE; + + if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_FORM_FACTOR))) + if (pa_streq(s, "handset") || pa_streq(s, "hands-free")) { + pa_proplist_sets(p, PA_PROP_DEVICE_INTENDED_ROLES, "phone"); + return TRUE; + } + + return FALSE; +} -- cgit From 31575f7766d6ff39665b64a3a04412eff1c39957 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 Jun 2009 03:45:14 +0200 Subject: alsa: rework mixer logic Completely rework mixer logic. This now allows controlling a full set of elements from a single sink's volume slider/mute button. This also introduces sink and source "ports" that can be used to choose different input or output ports with the UI. (i.e. "mic"/"line-in" or "speaker"/"headphones". The mixer paths and device maps are now configered in external configuration files and can be tweaked as necessary. --- src/pulsecore/sink.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 132 insertions(+), 12 deletions(-) (limited to 'src/pulsecore/sink.c') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 1da094af..47792293 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -100,11 +100,51 @@ void pa_sink_new_data_set_muted(pa_sink_new_data *data, pa_bool_t mute) { data->muted = !!mute; } +void pa_sink_new_data_set_port(pa_sink_new_data *data, const char *port) { + pa_assert(data); + + pa_xfree(data->active_port); + data->active_port = pa_xstrdup(port); +} + void pa_sink_new_data_done(pa_sink_new_data *data) { pa_assert(data); - pa_xfree(data->name); pa_proplist_free(data->proplist); + + if (data->ports) { + pa_device_port *p; + + while ((p = pa_hashmap_steal_first(data->ports))) + pa_device_port_free(p); + + pa_hashmap_free(data->ports, NULL, NULL); + } + + pa_xfree(data->name); + pa_xfree(data->active_port); +} + +pa_device_port *pa_device_port_new(const char *name, const char *description, size_t extra) { + pa_device_port *p; + + pa_assert(name); + + p = pa_xmalloc(PA_ALIGN(sizeof(pa_device_port)) + extra); + p->name = pa_xstrdup(name); + p->description = pa_xstrdup(description); + + p->priority = 0; + + return p; +} + +void pa_device_port_free(pa_device_port *p) { + pa_assert(p); + + pa_xfree(p->name); + pa_xfree(p->description); + pa_xfree(p); } /* Called from main context */ @@ -118,6 +158,7 @@ static void reset_callbacks(pa_sink *s) { s->set_mute = NULL; s->request_rewind = NULL; s->update_requested_latency = NULL; + s->set_port = NULL; } /* Called from main context */ @@ -152,6 +193,8 @@ pa_sink* pa_sink_new( return NULL; } + /* FIXME, need to free s here on failure */ + pa_return_null_if_fail(!data->driver || pa_utf8_valid(data->driver)); pa_return_null_if_fail(data->name && pa_utf8_valid(data->name) && data->name[0]); @@ -219,6 +262,30 @@ pa_sink* pa_sink_new( s->asyncmsgq = NULL; s->rtpoll = NULL; + /* As a minor optimization we just steal the list instead of + * copying it here */ + s->ports = data->ports; + data->ports = NULL; + + s->active_port = NULL; + s->save_port = FALSE; + + if (data->active_port && s->ports) + if ((s->active_port = pa_hashmap_get(s->ports, data->active_port))) + s->save_port = data->save_port; + + if (!s->active_port && s->ports) { + void *state; + pa_device_port *p; + + PA_HASHMAP_FOREACH(p, s->ports, state) + if (!s->active_port || p->priority > s->active_port->priority) + s->active_port = p; + } + + s->save_volume = data->save_volume; + s->save_muted = data->save_muted; + pa_silence_memchunk_get( &core->silence_cache, core->mempool, @@ -467,6 +534,15 @@ static void sink_free(pa_object *o) { if (s->proplist) pa_proplist_free(s->proplist); + if (s->ports) { + pa_device_port *p; + + while ((p = pa_hashmap_steal_first(s->ports))) + pa_device_port_free(p); + + pa_hashmap_free(s->ports, NULL, NULL); + } + pa_xfree(s); } @@ -485,6 +561,7 @@ void pa_sink_set_rtpoll(pa_sink *s, pa_rtpoll *p) { pa_sink_assert_ref(s); s->rtpoll = p; + if (s->monitor_source) pa_source_set_rtpoll(s->monitor_source, p); } @@ -526,15 +603,15 @@ int pa_sink_suspend(pa_sink *s, pa_bool_t suspend, pa_suspend_cause_t cause) { } /* Called from main context */ -pa_queue *pa_sink_move_all_start(pa_sink *s) { - pa_queue *q; +pa_queue *pa_sink_move_all_start(pa_sink *s, pa_queue *q) { pa_sink_input *i, *n; uint32_t idx; pa_sink_assert_ref(s); pa_assert(PA_SINK_IS_LINKED(s->state)); - q = pa_queue_new(); + if (!q) + q = pa_queue_new(); for (i = PA_SINK_INPUT(pa_idxset_first(s->inputs, &idx)); i; i = n) { n = PA_SINK_INPUT(pa_idxset_next(s->inputs, &idx)); @@ -1237,7 +1314,7 @@ void pa_sink_propagate_flat_volume(pa_sink *s) { } /* Called from main thread */ -void pa_sink_set_volume(pa_sink *s, const pa_cvolume *volume, pa_bool_t propagate, pa_bool_t sendmsg, pa_bool_t become_reference) { +void pa_sink_set_volume(pa_sink *s, const pa_cvolume *volume, pa_bool_t propagate, pa_bool_t sendmsg, pa_bool_t become_reference, pa_bool_t save) { pa_bool_t virtual_volume_changed; pa_sink_assert_ref(s); @@ -1248,6 +1325,7 @@ void pa_sink_set_volume(pa_sink *s, const pa_cvolume *volume, pa_bool_t propagat virtual_volume_changed = !pa_cvolume_equal(volume, &s->virtual_volume); s->virtual_volume = *volume; + s->save_volume = (!virtual_volume_changed && s->save_volume) || save; if (become_reference) s->reference_volume = s->virtual_volume; @@ -1318,15 +1396,17 @@ const pa_cvolume *pa_sink_get_volume(pa_sink *s, pa_bool_t force_refresh, pa_boo } /* Called from main thread */ -void pa_sink_volume_changed(pa_sink *s, const pa_cvolume *new_volume) { +void pa_sink_volume_changed(pa_sink *s, const pa_cvolume *new_volume, pa_bool_t save) { pa_sink_assert_ref(s); /* The sink implementor may call this if the volume changed to make sure everyone is notified */ - - if (pa_cvolume_equal(&s->virtual_volume, new_volume)) + if (pa_cvolume_equal(&s->virtual_volume, new_volume)) { + s->save_volume = s->save_volume || save; return; + } s->reference_volume = s->virtual_volume = *new_volume; + s->save_volume = save; if (s->flags & PA_SINK_FLAT_VOLUME) pa_sink_propagate_flat_volume(s); @@ -1335,7 +1415,7 @@ void pa_sink_volume_changed(pa_sink *s, const pa_cvolume *new_volume) { } /* Called from main thread */ -void pa_sink_set_mute(pa_sink *s, pa_bool_t mute) { +void pa_sink_set_mute(pa_sink *s, pa_bool_t mute, pa_bool_t save) { pa_bool_t old_muted; pa_sink_assert_ref(s); @@ -1343,6 +1423,7 @@ void pa_sink_set_mute(pa_sink *s, pa_bool_t mute) { old_muted = s->muted; s->muted = mute; + s->save_muted = (old_muted == s->muted && s->save_muted) || save; if (s->set_mute) s->set_mute(s); @@ -1378,15 +1459,19 @@ pa_bool_t pa_sink_get_mute(pa_sink *s, pa_bool_t force_refresh) { } /* Called from main thread */ -void pa_sink_mute_changed(pa_sink *s, pa_bool_t new_muted) { +void pa_sink_mute_changed(pa_sink *s, pa_bool_t new_muted, pa_bool_t save) { pa_sink_assert_ref(s); /* The sink implementor may call this if the volume changed to make sure everyone is notified */ - if (s->muted == new_muted) + if (s->muted == new_muted) { + s->save_muted = s->save_muted || save; return; + } s->muted = new_muted; + s->save_muted = save; + pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index); } @@ -1484,7 +1569,7 @@ unsigned pa_sink_check_suspend(pa_sink *s) { ret = 0; - for (i = PA_SINK_INPUT(pa_idxset_first(s->inputs, &idx)); i; i = PA_SINK_INPUT(pa_idxset_next(s->inputs, &idx))) { + PA_IDXSET_FOREACH(i, s->inputs, idx) { pa_sink_input_state_t st; st = pa_sink_input_get_state(i); @@ -2194,6 +2279,41 @@ size_t pa_sink_get_max_request(pa_sink *s) { return r; } +/* Called from main context */ +int pa_sink_set_port(pa_sink *s, const char *name, pa_bool_t save) { + pa_device_port *port; + + pa_assert(s); + + if (!s->set_port) { + pa_log_debug("set_port() operation not implemented for sink %u \"%s\"", s->index, s->name); + return -PA_ERR_NOTIMPLEMENTED; + } + + if (!s->ports) + return -PA_ERR_NOENTITY; + + if (!(port = pa_hashmap_get(s->ports, name))) + return -PA_ERR_NOENTITY; + + if (s->active_port == port) { + s->save_port = s->save_port || save; + return 0; + } + + if ((s->set_port(s, port)) < 0) + return -PA_ERR_NOENTITY; + + pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index); + + pa_log_info("Changed port of sink %u \"%s\" to %s", s->index, s->name, port->name); + + s->active_port = port; + s->save_port = save; + + return 0; +} + /* Called from main context */ pa_bool_t pa_device_init_icon(pa_proplist *p, pa_bool_t is_sink) { const char *ff, *c, *t = NULL, *s = "", *profile, *bus; -- cgit From 39b37a2bac34df671a3ff5a5d4ea8b4003f09fc9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 18 Jun 2009 03:40:47 +0200 Subject: core: be a bit more verbose when registering a sink/source fails --- src/pulsecore/sink.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/pulsecore/sink.c') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 47792293..7e4513e7 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -181,6 +181,7 @@ pa_sink* pa_sink_new( s = pa_msgobject_new(pa_sink); if (!(name = pa_namereg_register(core, data->name, PA_NAMEREG_SINK, s, data->namereg_fail))) { + pa_log_debug("Failed to register name %s.", data->name); pa_xfree(s); return NULL; } -- cgit From 8fe50b0d7cd4a93be85887bdb7efd2663face50d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 18 Jun 2009 04:38:59 +0200 Subject: alsa,core: include mapping name in description strings --- src/pulsecore/sink.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src/pulsecore/sink.c') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 7e4513e7..d8f3c7d1 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -2384,30 +2384,35 @@ pa_bool_t pa_device_init_icon(pa_proplist *p, pa_bool_t is_sink) { } pa_bool_t pa_device_init_description(pa_proplist *p) { - const char *s; + const char *s, *d = NULL, *k; pa_assert(p); if (pa_proplist_contains(p, PA_PROP_DEVICE_DESCRIPTION)) return TRUE; if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_FORM_FACTOR))) - if (pa_streq(s, "internal")) { - pa_proplist_sets(p, PA_PROP_DEVICE_DESCRIPTION, _("Internal Audio")); - return TRUE; - } + if (pa_streq(s, "internal")) + d = _("Internal Audio"); - if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_CLASS))) - if (pa_streq(s, "modem")) { - pa_proplist_sets(p, PA_PROP_DEVICE_DESCRIPTION, _("Modem")); - return TRUE; - } + if (!d) + if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_CLASS))) + if (pa_streq(s, "modem")) + d = _("Modem"); - if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_PRODUCT_NAME))) { - pa_proplist_sets(p, PA_PROP_DEVICE_DESCRIPTION, s); - return TRUE; - } + if (!d) + d = pa_proplist_gets(p, PA_PROP_DEVICE_PRODUCT_NAME); - return FALSE; + if (!d) + return FALSE; + + k = pa_proplist_gets(p, PA_PROP_DEVICE_PROFILE_DESCRIPTION); + + if (d && k) + pa_proplist_setf(p, PA_PROP_DEVICE_DESCRIPTION, _("%s %s"), d, k); + else if (d) + pa_proplist_sets(p, PA_PROP_DEVICE_DESCRIPTION, d); + + return TRUE; } pa_bool_t pa_device_init_intended_roles(pa_proplist *p) { -- cgit