[pulseaudio-commits] 2 commits - src/modules
David Henningsson
diwic at kemper.freedesktop.org
Mon Oct 19 02:05:01 PDT 2015
src/modules/dbus/iface-card-profile.c | 19 +++++++++
src/modules/dbus/iface-card.c | 51 +++++++++++++++++++++++---
src/modules/dbus/iface-device-port.c | 65 ++++++++++++++++++++++++++++++++--
3 files changed, 127 insertions(+), 8 deletions(-)
New commits:
commit f8cd444de0c6dc46cbb7d3d5a0f50b398a60c3bb
Author: John Horan <knasher at gmail.com>
Date: Sun Apr 19 15:29:27 2015 +0100
make availability of ports visible over dbus
diff --git a/src/modules/dbus/iface-device-port.c b/src/modules/dbus/iface-device-port.c
index 1b26756..4892443 100644
--- a/src/modules/dbus/iface-device-port.c
+++ b/src/modules/dbus/iface-device-port.c
@@ -34,6 +34,7 @@ static void handle_get_index(DBusConnection *conn, DBusMessage *msg, void *userd
static void handle_get_name(DBusConnection *conn, DBusMessage *msg, void *userdata);
static void handle_get_description(DBusConnection *conn, DBusMessage *msg, void *userdata);
static void handle_get_priority(DBusConnection *conn, DBusMessage *msg, void *userdata);
+static void handle_get_available(DBusConnection *conn, DBusMessage *msg, void *userdata);
static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdata);
@@ -41,6 +42,9 @@ struct pa_dbusiface_device_port {
uint32_t index;
pa_device_port *port;
char *path;
+
+ pa_hook_slot *available_changed_slot;
+
pa_dbus_protocol *dbus_protocol;
};
@@ -49,6 +53,7 @@ enum property_handler_index {
PROPERTY_HANDLER_NAME,
PROPERTY_HANDLER_DESCRIPTION,
PROPERTY_HANDLER_PRIORITY,
+ PROPERTY_HANDLER_AVAILABLE,
PROPERTY_HANDLER_MAX
};
@@ -57,6 +62,18 @@ static pa_dbus_property_handler property_handlers[PROPERTY_HANDLER_MAX] = {
[PROPERTY_HANDLER_NAME] = { .property_name = "Name", .type = "s", .get_cb = handle_get_name, .set_cb = NULL },
[PROPERTY_HANDLER_DESCRIPTION] = { .property_name = "Description", .type = "s", .get_cb = handle_get_description, .set_cb = NULL },
[PROPERTY_HANDLER_PRIORITY] = { .property_name = "Priority", .type = "u", .get_cb = handle_get_priority, .set_cb = NULL },
+ [PROPERTY_HANDLER_AVAILABLE] = { .property_name = "Available", .type = "u", .get_cb = handle_get_available, .set_cb = NULL }
+};
+
+enum signal_index {
+ SIGNAL_AVAILABLE_CHANGED,
+ SIGNAL_MAX
+};
+
+static pa_dbus_arg_info available_changed_args[] = { { "available", "u", NULL } };
+
+static pa_dbus_signal_info signals[SIGNAL_MAX] = {
+ [SIGNAL_AVAILABLE_CHANGED] = { .name = "AvailableChanged", .arguments = available_changed_args, .n_arguments = 1 }
};
static pa_dbus_interface_info port_interface_info = {
@@ -66,8 +83,8 @@ static pa_dbus_interface_info port_interface_info = {
.property_handlers = property_handlers,
.n_property_handlers = PROPERTY_HANDLER_MAX,
.get_all_properties_cb = handle_get_all,
- .signals = NULL,
- .n_signals = 0
+ .signals = signals,
+ .n_signals = SIGNAL_MAX
};
static void handle_get_index(DBusConnection *conn, DBusMessage *msg, void *userdata) {
@@ -113,6 +130,20 @@ static void handle_get_priority(DBusConnection *conn, DBusMessage *msg, void *us
pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &priority);
}
+static void handle_get_available(DBusConnection *conn, DBusMessage *msg, void *userdata) {
+ pa_dbusiface_device_port *p = userdata;
+ dbus_uint32_t available = 0;
+
+ pa_assert(conn);
+ pa_assert(msg);
+ pa_assert(p);
+
+ available = p->port->available;
+
+ pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &available);
+}
+
+
static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdata) {
pa_dbusiface_device_port *p = userdata;
DBusMessage *reply = NULL;
@@ -135,6 +166,7 @@ static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdat
pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_NAME].property_name, DBUS_TYPE_STRING, &p->port->name);
pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_DESCRIPTION].property_name, DBUS_TYPE_STRING, &p->port->description);
pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_PRIORITY].property_name, DBUS_TYPE_UINT32, &priority);
+ pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_AVAILABLE].property_name, DBUS_TYPE_UINT32, &p->port->available);
pa_assert_se(dbus_message_iter_close_container(&msg_iter, &dict_iter));
@@ -142,6 +174,32 @@ static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdat
dbus_message_unref(reply);
}
+static pa_hook_result_t available_changed_cb(void *hook_data, void *call_data, void *slot_data) {
+ pa_dbusiface_device_port *p = slot_data;
+ pa_device_port *port = call_data;
+ DBusMessage *signal_msg;
+ uint32_t available;
+
+ pa_assert(p);
+ pa_assert(port);
+
+ if(p->port != port)
+ return PA_HOOK_OK;
+
+ available = port->available;
+
+ pa_assert_se(signal_msg = dbus_message_new_signal(p->path,
+ PA_DBUSIFACE_DEVICE_PORT_INTERFACE,
+ signals[SIGNAL_AVAILABLE_CHANGED].name));
+ pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_UINT32, &available, DBUS_TYPE_INVALID));
+
+ pa_dbus_protocol_send_signal(p->dbus_protocol, signal_msg);
+ dbus_message_unref(signal_msg);
+
+ return PA_HOOK_OK;
+}
+
+
pa_dbusiface_device_port *pa_dbusiface_device_port_new(
pa_dbusiface_device *device,
pa_core *core,
@@ -158,6 +216,8 @@ pa_dbusiface_device_port *pa_dbusiface_device_port_new(
p->port = port;
p->path = pa_sprintf_malloc("%s/%s%u", pa_dbusiface_device_get_path(device), OBJECT_NAME, idx);
p->dbus_protocol = pa_dbus_protocol_get(core);
+ p->available_changed_slot = pa_hook_connect(&port->core->hooks[PA_CORE_HOOK_PORT_AVAILABLE_CHANGED],
+ PA_HOOK_NORMAL, available_changed_cb, p);
pa_assert_se(pa_dbus_protocol_add_interface(p->dbus_protocol, p->path, &port_interface_info, p) >= 0);
@@ -169,6 +229,7 @@ void pa_dbusiface_device_port_free(pa_dbusiface_device_port *p) {
pa_assert_se(pa_dbus_protocol_remove_interface(p->dbus_protocol, p->path, port_interface_info.name) >= 0);
+ pa_hook_slot_free(p->available_changed_slot);
pa_dbus_protocol_unref(p->dbus_protocol);
pa_xfree(p->path);
commit 2261567758bb0b07315f87dd6c19a79fb697a26b
Author: Juho Hämäläinen <juho.hamalainen at tieto.com>
Date: Thu Mar 19 13:51:00 2015 +0200
dbus: Add card profile availability info to API
[diwic: Profile availability to boolean bug fixed]
diff --git a/src/modules/dbus/iface-card-profile.c b/src/modules/dbus/iface-card-profile.c
index e39c24d..bb8b642 100644
--- a/src/modules/dbus/iface-card-profile.c
+++ b/src/modules/dbus/iface-card-profile.c
@@ -36,6 +36,7 @@ static void handle_get_description(DBusConnection *conn, DBusMessage *msg, void
static void handle_get_sinks(DBusConnection *conn, DBusMessage *msg, void *userdata);
static void handle_get_sources(DBusConnection *conn, DBusMessage *msg, void *userdata);
static void handle_get_priority(DBusConnection *conn, DBusMessage *msg, void *userdata);
+static void handle_get_available(DBusConnection *conn, DBusMessage *msg, void *userdata);
static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdata);
@@ -53,6 +54,7 @@ enum property_handler_index {
PROPERTY_HANDLER_SINKS,
PROPERTY_HANDLER_SOURCES,
PROPERTY_HANDLER_PRIORITY,
+ PROPERTY_HANDLER_AVAILABLE,
PROPERTY_HANDLER_MAX
};
@@ -63,6 +65,7 @@ static pa_dbus_property_handler property_handlers[PROPERTY_HANDLER_MAX] = {
[PROPERTY_HANDLER_SINKS] = { .property_name = "Sinks", .type = "u", .get_cb = handle_get_sinks, .set_cb = NULL },
[PROPERTY_HANDLER_SOURCES] = { .property_name = "Sources", .type = "u", .get_cb = handle_get_sources, .set_cb = NULL },
[PROPERTY_HANDLER_PRIORITY] = { .property_name = "Priority", .type = "u", .get_cb = handle_get_priority, .set_cb = NULL },
+ [PROPERTY_HANDLER_AVAILABLE] = { .property_name = "Available", .type = "b", .get_cb = handle_get_available, .set_cb = NULL },
};
static pa_dbus_interface_info profile_interface_info = {
@@ -145,6 +148,19 @@ static void handle_get_priority(DBusConnection *conn, DBusMessage *msg, void *us
pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &priority);
}
+static void handle_get_available(DBusConnection *conn, DBusMessage *msg, void *userdata) {
+ pa_dbusiface_card_profile *p = userdata;
+ dbus_bool_t available;
+
+ pa_assert(conn);
+ pa_assert(msg);
+ pa_assert(p);
+
+ available = p->profile->available != PA_AVAILABLE_NO;
+
+ pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_BOOLEAN, &available);
+}
+
static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdata) {
pa_dbusiface_card_profile *p = userdata;
DBusMessage *reply = NULL;
@@ -153,6 +169,7 @@ static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdat
dbus_uint32_t sinks = 0;
dbus_uint32_t sources = 0;
dbus_uint32_t priority = 0;
+ dbus_bool_t available;
pa_assert(conn);
pa_assert(msg);
@@ -161,6 +178,7 @@ static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdat
sinks = p->profile->n_sinks;
sources = p->profile->n_sources;
priority = p->profile->priority;
+ available = p->profile->available != PA_AVAILABLE_NO;
pa_assert_se((reply = dbus_message_new_method_return(msg)));
@@ -173,6 +191,7 @@ static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdat
pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_SINKS].property_name, DBUS_TYPE_UINT32, &sinks);
pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_SOURCES].property_name, DBUS_TYPE_UINT32, &sources);
pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_PRIORITY].property_name, DBUS_TYPE_UINT32, &priority);
+ pa_dbus_append_basic_variant_dict_entry(&dict_iter, property_handlers[PROPERTY_HANDLER_AVAILABLE].property_name, DBUS_TYPE_BOOLEAN, &available);
pa_assert_se(dbus_message_iter_close_container(&msg_iter, &dict_iter));
diff --git a/src/modules/dbus/iface-card.c b/src/modules/dbus/iface-card.c
index d0f13c9..1b705ba 100644
--- a/src/modules/dbus/iface-card.c
+++ b/src/modules/dbus/iface-card.c
@@ -60,6 +60,7 @@ struct pa_dbusiface_card {
pa_hook_slot *card_profile_added_slot;
pa_hook_slot *card_profile_changed_slot;
+ pa_hook_slot *card_profile_available_slot;
pa_dbus_protocol *dbus_protocol;
};
@@ -107,18 +108,22 @@ static pa_dbus_method_handler method_handlers[METHOD_HANDLER_MAX] = {
enum signal_index {
SIGNAL_ACTIVE_PROFILE_UPDATED,
SIGNAL_NEW_PROFILE,
+ SIGNAL_PROFILE_AVAILABLE_CHANGED,
SIGNAL_PROPERTY_LIST_UPDATED,
SIGNAL_MAX
};
-static pa_dbus_arg_info active_profile_updated_args[] = { { "profile", "o", NULL } };
-static pa_dbus_arg_info new_profile_args[] = { { "profile", "o", NULL } };
-static pa_dbus_arg_info property_list_updated_args[] = { { "property_list", "a{say}", NULL } };
+static pa_dbus_arg_info active_profile_updated_args[] = { { "profile", "o", NULL } };
+static pa_dbus_arg_info new_profile_args[] = { { "profile", "o", NULL } };
+static pa_dbus_arg_info profile_available_changed_args[] = { { "profile", "o", NULL },
+ { "available", "b", NULL } };
+static pa_dbus_arg_info property_list_updated_args[] = { { "property_list", "a{say}", NULL } };
static pa_dbus_signal_info signals[SIGNAL_MAX] = {
- [SIGNAL_ACTIVE_PROFILE_UPDATED] = { .name = "ActiveProfileUpdated", .arguments = active_profile_updated_args, .n_arguments = 1 },
- [SIGNAL_NEW_PROFILE] = { .name = "NewProfile", .arguments = new_profile_args, .n_arguments = 1 },
- [SIGNAL_PROPERTY_LIST_UPDATED] = { .name = "PropertyListUpdated", .arguments = property_list_updated_args, .n_arguments = 1 }
+ [SIGNAL_ACTIVE_PROFILE_UPDATED] = { .name = "ActiveProfileUpdated", .arguments = active_profile_updated_args, .n_arguments = 1 },
+ [SIGNAL_NEW_PROFILE] = { .name = "NewProfile", .arguments = new_profile_args, .n_arguments = 1 },
+ [SIGNAL_PROFILE_AVAILABLE_CHANGED] = { .name = "ProfileAvailableChanged", .arguments = profile_available_changed_args, .n_arguments = 2 },
+ [SIGNAL_PROPERTY_LIST_UPDATED] = { .name = "PropertyListUpdated", .arguments = property_list_updated_args, .n_arguments = 1 }
};
static pa_dbus_interface_info card_interface_info = {
@@ -507,6 +512,37 @@ static pa_hook_result_t card_profile_added_cb(void *hook_data, void *call_data,
return PA_HOOK_OK;
}
+static pa_hook_result_t card_profile_available_changed_cb(void *hook_data, void *call_data, void *slot_data) {
+ pa_dbusiface_card *c = slot_data;
+ pa_card_profile *profile = call_data;
+ pa_dbusiface_card_profile *p;
+ const char *object_path;
+ dbus_bool_t available;
+ DBusMessage *signal_msg;
+
+ if (profile->card != c->card)
+ return PA_HOOK_OK;
+
+ pa_assert_se((p = pa_hashmap_get(c->profiles, profile->name)));
+
+ object_path = pa_dbusiface_card_profile_get_path(p);
+ available = profile->available != PA_AVAILABLE_NO;
+
+ pa_assert_se(signal_msg = dbus_message_new_signal(c->path,
+ PA_DBUSIFACE_CARD_INTERFACE,
+ signals[SIGNAL_PROFILE_AVAILABLE_CHANGED].name));
+ pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path,
+ DBUS_TYPE_BOOLEAN, &available,
+ DBUS_TYPE_INVALID));
+
+ pa_dbus_protocol_send_signal(c->dbus_protocol, signal_msg);
+ dbus_message_unref(signal_msg);
+
+ check_card_proplist(c);
+
+ return PA_HOOK_OK;
+}
+
pa_dbusiface_card *pa_dbusiface_card_new(pa_dbusiface_core *core, pa_card *card) {
pa_dbusiface_card *c = NULL;
pa_card_profile *profile;
@@ -537,6 +573,8 @@ pa_dbusiface_card *pa_dbusiface_card_new(pa_dbusiface_core *core, pa_card *card)
card_profile_changed_cb, c);
c->card_profile_added_slot = pa_hook_connect(&card->core->hooks[PA_CORE_HOOK_CARD_PROFILE_ADDED], PA_HOOK_NORMAL,
card_profile_added_cb, c);
+ c->card_profile_available_slot = pa_hook_connect(&card->core->hooks[PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED], PA_HOOK_NORMAL,
+ card_profile_available_changed_cb, c);
return c;
}
@@ -548,6 +586,7 @@ void pa_dbusiface_card_free(pa_dbusiface_card *c) {
pa_hook_slot_free(c->card_profile_added_slot);
pa_hook_slot_free(c->card_profile_changed_slot);
+ pa_hook_slot_free(c->card_profile_available_slot);
pa_hashmap_free(c->profiles);
pa_proplist_free(c->proplist);
More information about the pulseaudio-commits
mailing list