mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -05:00
add logic for initializing a useful icon name
This commit is contained in:
parent
784ac5b0da
commit
671b927955
10 changed files with 95 additions and 20 deletions
|
|
@ -33,6 +33,7 @@
|
|||
#include <pulse/xmalloc.h>
|
||||
#include <pulse/timeval.h>
|
||||
#include <pulse/util.h>
|
||||
#include <pulse/i18n.h>
|
||||
|
||||
#include <pulsecore/sink-input.h>
|
||||
#include <pulsecore/namereg.h>
|
||||
|
|
@ -172,6 +173,9 @@ pa_sink* pa_sink_new(
|
|||
if (data->card)
|
||||
pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->card->proplist);
|
||||
|
||||
pa_device_init_description(data->proplist);
|
||||
pa_device_init_icon(data->proplist, TRUE);
|
||||
|
||||
if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_FIXATE], data) < 0) {
|
||||
pa_xfree(s);
|
||||
pa_namereg_unregister(core, name);
|
||||
|
|
@ -1886,3 +1890,68 @@ size_t pa_sink_get_max_request(pa_sink *s) {
|
|||
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Called from main context */
|
||||
pa_bool_t pa_device_init_icon(pa_proplist *p, pa_bool_t is_sink) {
|
||||
const char *ff, *t = NULL, *s = "", *profile, *bus;
|
||||
|
||||
pa_assert(p);
|
||||
|
||||
if (pa_proplist_contains(p, PA_PROP_DEVICE_ICON_NAME))
|
||||
return TRUE;
|
||||
|
||||
if ((ff = pa_proplist_gets(p, PA_PROP_DEVICE_FORM_FACTOR))) {
|
||||
|
||||
if (pa_streq(ff, "microphone"))
|
||||
t = "audio-input-microphone";
|
||||
else if (pa_streq(ff, "webcam"))
|
||||
t = "camera-web";
|
||||
else if (pa_streq(ff, "computer"))
|
||||
t = "computer";
|
||||
else if (pa_streq(ff, "handset"))
|
||||
t = "phone";
|
||||
}
|
||||
|
||||
if (!t) {
|
||||
if (is_sink)
|
||||
t = "audio-card";
|
||||
else
|
||||
t = "audio-input-microphone";
|
||||
}
|
||||
|
||||
if ((profile = pa_proplist_gets(p, PA_PROP_DEVICE_PROFILE_NAME))) {
|
||||
if (strstr(profile, "analog"))
|
||||
s = "-analog";
|
||||
else if (strstr(profile, "iec958"))
|
||||
s = "-iec958";
|
||||
else if (strstr(profile, "hdmi"))
|
||||
s = "-hdmi";
|
||||
}
|
||||
|
||||
bus = pa_proplist_gets(p, PA_PROP_DEVICE_BUS);
|
||||
|
||||
pa_proplist_setf(p, PA_PROP_DEVICE_ICON_NAME, "%s%s%s%s", t, pa_strempty(s), bus ? "-" : "", pa_strempty(bus));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
pa_bool_t pa_device_init_description(pa_proplist *p) {
|
||||
const char *s;
|
||||
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 ((s = pa_proplist_gets(p, PA_PROP_DEVICE_PRODUCT_NAME))) {
|
||||
pa_proplist_sets(p, PA_PROP_DEVICE_DESCRIPTION, s);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue