[pulseaudio-discuss] [PATCH v2 9/9] device-port: Add pa_device_port_update_proplist
Tanu Kaskinen
tanuk at iki.fi
Wed Feb 20 10:24:04 PST 2013
---
src/modules/alsa/module-alsa-card.c | 25 +++++++++++++------------
src/pulsecore/device-port.c | 12 ++++++++++++
src/pulsecore/device-port.h | 2 ++
3 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index 3b96cea..5c4bad5 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -404,10 +404,9 @@ static pa_device_port* find_port_with_eld_device(pa_hashmap *ports, int device)
static int hdmi_eld_changed(snd_hctl_elem_t *elem, unsigned int mask) {
struct userdata *u = snd_hctl_elem_get_callback_private(elem);
int device = snd_hctl_elem_get_device(elem);
- const char *old_monitor_name;
pa_device_port *p;
pa_hdmi_eld eld;
- bool changed = false;
+ pa_proplist_update_info *info;
p = find_port_with_eld_device(u->card->ports, device);
if (p == NULL) {
@@ -418,17 +417,19 @@ static int hdmi_eld_changed(snd_hctl_elem_t *elem, unsigned int mask) {
if (pa_alsa_get_hdmi_eld(u->hctl_handle, device, &eld) < 0)
memset(&eld, 0, sizeof(eld));
- old_monitor_name = pa_proplist_gets(p->proplist, PA_PROP_DEVICE_PRODUCT_NAME);
- if (eld.monitor_name[0] == '\0') {
- changed |= old_monitor_name != NULL;
- pa_proplist_unset(p->proplist, PA_PROP_DEVICE_PRODUCT_NAME);
- } else {
- changed |= (old_monitor_name == NULL) || (strcmp(old_monitor_name, eld.monitor_name) != 0);
- pa_proplist_sets(p->proplist, PA_PROP_DEVICE_PRODUCT_NAME, eld.monitor_name);
- }
+ info = pa_proplist_update_info_new();
+
+ if (eld.monitor_name[0] == '\0')
+ pa_proplist_update_info_add(info,
+ PA_PROPLIST_OPERATION_UNSET, PA_PROP_DEVICE_PRODUCT_NAME,
+ PA_PROPLIST_OPERATION_INVALID);
+ else
+ pa_proplist_update_info_add(info,
+ PA_PROPLIST_OPERATION_SETS, PA_PROP_DEVICE_PRODUCT_NAME, eld.monitor_name,
+ PA_PROPLIST_OPERATION_INVALID);
- if (changed && mask != 0)
- pa_subscription_post(u->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, u->card->index);
+ pa_device_port_update_proplist(p, info);
+ pa_proplist_update_info_free(info);
return 0;
}
diff --git a/src/pulsecore/device-port.c b/src/pulsecore/device-port.c
index ad885d3..22966c6 100644
--- a/src/pulsecore/device-port.c
+++ b/src/pulsecore/device-port.c
@@ -121,3 +121,15 @@ void pa_device_port_set_latency_offset(pa_device_port *p, int64_t offset) {
pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, p->card->index);
pa_hook_fire(&core->hooks[PA_CORE_HOOK_PORT_LATENCY_OFFSET_CHANGED], p);
}
+
+void pa_device_port_update_proplist(pa_device_port *port, pa_proplist_update_info *info) {
+ bool changed;
+
+ pa_assert(port);
+ pa_assert(info);
+
+ changed = pa_proplist_apply_update_info(port->proplist, info);
+
+ if (changed && port->linked)
+ pa_subscription_post(port->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, port->card->index);
+}
diff --git a/src/pulsecore/device-port.h b/src/pulsecore/device-port.h
index be7dd4c..9c30c0a 100644
--- a/src/pulsecore/device-port.h
+++ b/src/pulsecore/device-port.h
@@ -73,4 +73,6 @@ void pa_device_port_set_available(pa_device_port *p, pa_available_t available);
void pa_device_port_set_latency_offset(pa_device_port *p, int64_t offset);
+void pa_device_port_update_proplist(pa_device_port *port, pa_proplist_update_info *info);
+
#endif
--
1.7.10.4
More information about the pulseaudio-discuss
mailing list