mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
dbusiface-device: Save one level of identation by returning early.
This commit is contained in:
parent
b528715179
commit
70ff96b8ab
1 changed files with 92 additions and 89 deletions
|
|
@ -1075,126 +1075,129 @@ static void handle_source_get_all(DBusConnection *conn, DBusMessage *msg, void *
|
||||||
|
|
||||||
static void subscription_cb(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata) {
|
static void subscription_cb(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata) {
|
||||||
pa_dbusiface_device *d = userdata;
|
pa_dbusiface_device *d = userdata;
|
||||||
|
DBusMessage *signal = NULL;
|
||||||
|
const pa_cvolume *new_volume = NULL;
|
||||||
|
pa_bool_t new_muted = FALSE;
|
||||||
|
pa_sink_state_t new_sink_state = 0;
|
||||||
|
pa_source_state_t new_source_state = 0;
|
||||||
|
pa_device_port *new_active_port = NULL;
|
||||||
|
pa_proplist *new_proplist = NULL;
|
||||||
|
unsigned i = 0;
|
||||||
|
|
||||||
pa_assert(c);
|
pa_assert(c);
|
||||||
pa_assert(d);
|
pa_assert(d);
|
||||||
|
|
||||||
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE) {
|
if ((d->type == DEVICE_TYPE_SINK && idx != d->sink->index) || (d->type == DEVICE_TYPE_SOURCE && idx != d->source->index))
|
||||||
DBusMessage *signal = NULL;
|
return;
|
||||||
const pa_cvolume *new_volume = NULL;
|
|
||||||
pa_bool_t new_muted = FALSE;
|
|
||||||
pa_sink_state_t new_sink_state = 0;
|
|
||||||
pa_source_state_t new_source_state = 0;
|
|
||||||
pa_device_port *new_active_port = NULL;
|
|
||||||
pa_proplist *new_proplist = NULL;
|
|
||||||
unsigned i = 0;
|
|
||||||
|
|
||||||
pa_assert(((d->type == DEVICE_TYPE_SINK)
|
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) != PA_SUBSCRIPTION_EVENT_CHANGE)
|
||||||
&& ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK))
|
return;
|
||||||
|| ((d->type == DEVICE_TYPE_SOURCE)
|
|
||||||
&& ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE)));
|
|
||||||
|
|
||||||
new_volume = (d->type == DEVICE_TYPE_SINK)
|
pa_assert(((d->type == DEVICE_TYPE_SINK)
|
||||||
? pa_sink_get_volume(d->sink, FALSE, FALSE)
|
&& ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK))
|
||||||
: pa_source_get_volume(d->source, FALSE);
|
|| ((d->type == DEVICE_TYPE_SOURCE)
|
||||||
|
&& ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE)));
|
||||||
|
|
||||||
if (!pa_cvolume_equal(&d->volume, new_volume)) {
|
new_volume = (d->type == DEVICE_TYPE_SINK)
|
||||||
dbus_uint32_t volume[PA_CHANNELS_MAX];
|
? pa_sink_get_volume(d->sink, FALSE, FALSE)
|
||||||
dbus_uint32_t *volume_ptr = volume;
|
: pa_source_get_volume(d->source, FALSE);
|
||||||
|
|
||||||
d->volume = *new_volume;
|
if (!pa_cvolume_equal(&d->volume, new_volume)) {
|
||||||
|
dbus_uint32_t volume[PA_CHANNELS_MAX];
|
||||||
|
dbus_uint32_t *volume_ptr = volume;
|
||||||
|
|
||||||
for (i = 0; i < d->volume.channels; ++i)
|
d->volume = *new_volume;
|
||||||
volume[i] = d->volume.values[i];
|
|
||||||
|
|
||||||
pa_assert_se(signal = dbus_message_new_signal(d->path,
|
for (i = 0; i < d->volume.channels; ++i)
|
||||||
PA_DBUSIFACE_DEVICE_INTERFACE,
|
volume[i] = d->volume.values[i];
|
||||||
signals[SIGNAL_VOLUME_UPDATED].name));
|
|
||||||
pa_assert_se(dbus_message_append_args(signal,
|
|
||||||
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &volume_ptr, d->volume.channels,
|
|
||||||
DBUS_TYPE_INVALID));
|
|
||||||
|
|
||||||
pa_dbus_protocol_send_signal(d->dbus_protocol, signal);
|
pa_assert_se(signal = dbus_message_new_signal(d->path,
|
||||||
dbus_message_unref(signal);
|
PA_DBUSIFACE_DEVICE_INTERFACE,
|
||||||
signal = NULL;
|
signals[SIGNAL_VOLUME_UPDATED].name));
|
||||||
}
|
pa_assert_se(dbus_message_append_args(signal,
|
||||||
|
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &volume_ptr, d->volume.channels,
|
||||||
|
DBUS_TYPE_INVALID));
|
||||||
|
|
||||||
new_muted = (d->type == DEVICE_TYPE_SINK) ? pa_sink_get_mute(d->sink, FALSE) : pa_source_get_mute(d->source, FALSE);
|
pa_dbus_protocol_send_signal(d->dbus_protocol, signal);
|
||||||
|
dbus_message_unref(signal);
|
||||||
|
signal = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (d->is_muted != new_muted) {
|
new_muted = (d->type == DEVICE_TYPE_SINK) ? pa_sink_get_mute(d->sink, FALSE) : pa_source_get_mute(d->source, FALSE);
|
||||||
d->is_muted = new_muted;
|
|
||||||
|
|
||||||
pa_assert_se(signal = dbus_message_new_signal(d->path,
|
if (d->is_muted != new_muted) {
|
||||||
PA_DBUSIFACE_DEVICE_INTERFACE,
|
d->is_muted = new_muted;
|
||||||
signals[SIGNAL_MUTE_UPDATED].name));
|
|
||||||
pa_assert_se(dbus_message_append_args(signal, DBUS_TYPE_BOOLEAN, &d->is_muted, DBUS_TYPE_INVALID));
|
|
||||||
|
|
||||||
pa_dbus_protocol_send_signal(d->dbus_protocol, signal);
|
pa_assert_se(signal = dbus_message_new_signal(d->path,
|
||||||
dbus_message_unref(signal);
|
PA_DBUSIFACE_DEVICE_INTERFACE,
|
||||||
signal = NULL;
|
signals[SIGNAL_MUTE_UPDATED].name));
|
||||||
}
|
pa_assert_se(dbus_message_append_args(signal, DBUS_TYPE_BOOLEAN, &d->is_muted, DBUS_TYPE_INVALID));
|
||||||
|
|
||||||
|
pa_dbus_protocol_send_signal(d->dbus_protocol, signal);
|
||||||
|
dbus_message_unref(signal);
|
||||||
|
signal = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d->type == DEVICE_TYPE_SINK)
|
||||||
|
new_sink_state = pa_sink_get_state(d->sink);
|
||||||
|
else
|
||||||
|
new_source_state = pa_source_get_state(d->source);
|
||||||
|
|
||||||
|
if ((d->type == DEVICE_TYPE_SINK && d->sink_state != new_sink_state)
|
||||||
|
|| (d->type == DEVICE_TYPE_SOURCE && d->source_state != new_source_state)) {
|
||||||
|
dbus_uint32_t state = 0;
|
||||||
|
|
||||||
if (d->type == DEVICE_TYPE_SINK)
|
if (d->type == DEVICE_TYPE_SINK)
|
||||||
new_sink_state = pa_sink_get_state(d->sink);
|
d->sink_state = new_sink_state;
|
||||||
else
|
else
|
||||||
new_source_state = pa_source_get_state(d->source);
|
d->source_state = new_source_state;
|
||||||
|
|
||||||
if ((d->type == DEVICE_TYPE_SINK && d->sink_state != new_sink_state)
|
state = (d->type == DEVICE_TYPE_SINK) ? d->sink_state : d->source_state;
|
||||||
|| (d->type == DEVICE_TYPE_SOURCE && d->source_state != new_source_state)) {
|
|
||||||
dbus_uint32_t state = 0;
|
|
||||||
|
|
||||||
if (d->type == DEVICE_TYPE_SINK)
|
pa_assert_se(signal = dbus_message_new_signal(d->path,
|
||||||
d->sink_state = new_sink_state;
|
PA_DBUSIFACE_DEVICE_INTERFACE,
|
||||||
else
|
signals[SIGNAL_STATE_UPDATED].name));
|
||||||
d->source_state = new_source_state;
|
pa_assert_se(dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state, DBUS_TYPE_INVALID));
|
||||||
|
|
||||||
state = (d->type == DEVICE_TYPE_SINK) ? d->sink_state : d->source_state;
|
pa_dbus_protocol_send_signal(d->dbus_protocol, signal);
|
||||||
|
dbus_message_unref(signal);
|
||||||
|
signal = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
pa_assert_se(signal = dbus_message_new_signal(d->path,
|
new_active_port = (d->type == DEVICE_TYPE_SINK) ? d->sink->active_port : d->source->active_port;
|
||||||
PA_DBUSIFACE_DEVICE_INTERFACE,
|
|
||||||
signals[SIGNAL_STATE_UPDATED].name));
|
|
||||||
pa_assert_se(dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state, DBUS_TYPE_INVALID));
|
|
||||||
|
|
||||||
pa_dbus_protocol_send_signal(d->dbus_protocol, signal);
|
if (d->active_port != new_active_port) {
|
||||||
dbus_message_unref(signal);
|
const char *object_path = NULL;
|
||||||
signal = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_active_port = (d->type == DEVICE_TYPE_SINK) ? d->sink->active_port : d->source->active_port;
|
d->active_port = new_active_port;
|
||||||
|
object_path = pa_dbusiface_device_port_get_path(pa_hashmap_get(d->ports, d->active_port->name));
|
||||||
|
|
||||||
if (d->active_port != new_active_port) {
|
pa_assert_se(signal = dbus_message_new_signal(d->path,
|
||||||
const char *object_path = NULL;
|
PA_DBUSIFACE_DEVICE_INTERFACE,
|
||||||
|
signals[SIGNAL_ACTIVE_PORT_UPDATED].name));
|
||||||
|
pa_assert_se(dbus_message_append_args(signal, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
|
||||||
|
|
||||||
d->active_port = new_active_port;
|
pa_dbus_protocol_send_signal(d->dbus_protocol, signal);
|
||||||
object_path = pa_dbusiface_device_port_get_path(pa_hashmap_get(d->ports, d->active_port->name));
|
dbus_message_unref(signal);
|
||||||
|
signal = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
pa_assert_se(signal = dbus_message_new_signal(d->path,
|
new_proplist = (d->type == DEVICE_TYPE_SINK) ? d->sink->proplist : d->source->proplist;
|
||||||
PA_DBUSIFACE_DEVICE_INTERFACE,
|
|
||||||
signals[SIGNAL_ACTIVE_PORT_UPDATED].name));
|
|
||||||
pa_assert_se(dbus_message_append_args(signal, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
|
|
||||||
|
|
||||||
pa_dbus_protocol_send_signal(d->dbus_protocol, signal);
|
if (!pa_proplist_equal(d->proplist, new_proplist)) {
|
||||||
dbus_message_unref(signal);
|
DBusMessageIter msg_iter;
|
||||||
signal = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_proplist = (d->type == DEVICE_TYPE_SINK) ? d->sink->proplist : d->source->proplist;
|
pa_proplist_update(d->proplist, PA_UPDATE_SET, new_proplist);
|
||||||
|
|
||||||
if (!pa_proplist_equal(d->proplist, new_proplist)) {
|
pa_assert_se(signal = dbus_message_new_signal(d->path,
|
||||||
DBusMessageIter msg_iter;
|
PA_DBUSIFACE_DEVICE_INTERFACE,
|
||||||
|
signals[SIGNAL_PROPERTY_LIST_UPDATED].name));
|
||||||
|
dbus_message_iter_init_append(signal, &msg_iter);
|
||||||
|
pa_dbus_append_proplist(&msg_iter, d->proplist);
|
||||||
|
|
||||||
pa_proplist_update(d->proplist, PA_UPDATE_SET, new_proplist);
|
pa_dbus_protocol_send_signal(d->dbus_protocol, signal);
|
||||||
|
dbus_message_unref(signal);
|
||||||
pa_assert_se(signal = dbus_message_new_signal(d->path,
|
signal = NULL;
|
||||||
PA_DBUSIFACE_DEVICE_INTERFACE,
|
|
||||||
signals[SIGNAL_PROPERTY_LIST_UPDATED].name));
|
|
||||||
dbus_message_iter_init_append(signal, &msg_iter);
|
|
||||||
pa_dbus_append_proplist(&msg_iter, d->proplist);
|
|
||||||
|
|
||||||
pa_dbus_protocol_send_signal(d->dbus_protocol, signal);
|
|
||||||
dbus_message_unref(signal);
|
|
||||||
signal = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue