static void handle_load_sink(DBusConnection *conn, DBusMessage *msg, void *userdata) {
pa_device_manager *dm;
char *type, *role;
+ pa_sink *sink;
DBusMessage *reply = NULL;
- pa_assert_se((reply = dbus_message_new_method_return(msg)));
dm = (pa_device_manager *) userdata;
pa_assert_se(dbus_message_get_args(msg, NULL,
DBUS_TYPE_STRING, &type,
DBUS_TYPE_STRING, &role,
DBUS_TYPE_INVALID));
- pa_device_manager_load_sink(dm, type, role);
+ if (!(sink = pa_device_manager_load_sink(dm, type, role))) {
+ pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED, "%s", "org.tizen.multimedia.audio.Internal");
+ return;
+ }
+
+ pa_assert_se((reply = dbus_message_new_method_return(msg)));
pa_assert_se(dbus_connection_send(conn, reply, NULL));
dbus_message_unref(reply);
}
}
}
-static struct device_type_info* _device_manager_get_type_info(pa_idxset *type_infos, const char *type) {
+static struct device_type_info* _device_manager_get_type_info(pa_idxset *type_infos, const char *type, const char *role) {
struct device_type_info *type_info;
uint32_t type_idx;
+ const char *device_string;
+ const char *_role;
+ void *state;
+
+ pa_assert(type_infos);
+ pa_assert(type);
PA_IDXSET_FOREACH(type_info, type_infos, type_idx) {
if (device_type_is_equal(type_info->type, type)) {
+ if (role) {
+ if (type_info->playback_devices) {
+ PA_HASHMAP_FOREACH_KV(_role, device_string, type_info->playback_devices, state) {
+ if (pa_safe_streq(_role, role))
+ return type_info;
+ }
+ }
+ if (type_info->capture_devices) {
+ PA_HASHMAP_FOREACH_KV(_role, device_string, type_info->capture_devices, state) {
+ if (pa_safe_streq(_role, role))
+ return type_info;
+ }
+ }
+ continue;
+ }
return type_info;
}
}
pa_log_info("Device connected, type(%s) name(%s) system_id(%s) detected_type(%d)",
type, pa_strempty(name), pa_strempty(system_id), detected_type);
- type_info = _device_manager_get_type_info(dm->type_infos, type);
+ type_info = _device_manager_get_type_info(dm->type_infos, type, NULL);
if (device_type_is_equal(type, DEVICE_TYPE_BT_SCO)) {
pa_tz_device_new_data_init(&data, dm->device_list, dm->comm, dm->dbus_conn);
pa_log_info("Load Sink for '%s.%s'", type, role);
PA_IDXSET_FOREACH(device, dm->device_list, device_idx) {
if (pa_safe_streq(type, pa_tz_device_get_type(device))) {
- if (pa_tz_device_get_sink(device, role)) {
+ if ((sink = pa_tz_device_get_sink(device, role))) {
pa_log_warn("Proper sink for '%s.%s' already loaded", type, role);
- return NULL;
+ return sink;
}
}
}
- if (!(type_info = _device_manager_get_type_info(dm->type_infos, type))) {
+ if (!(type_info = _device_manager_get_type_info(dm->type_infos, type, role))) {
pa_log_error("No type map for %s", type);
return NULL;
}
pa_log_info("Unload Sink for '%s.%s'", type, role);
- if (!(type_info = _device_manager_get_type_info(dm->type_infos, type))) {
+ if (!(type_info = _device_manager_get_type_info(dm->type_infos, type, role))) {
pa_log_error("No type map for %s", type);
return;
}
PA_IDXSET_FOREACH(device, dm->device_list, device_idx) {
if (pa_safe_streq(type, pa_tz_device_get_type(device))) {
- if (pa_tz_device_get_source(device, role)) {
+ if ((source = pa_tz_device_get_source(device, role))) {
pa_log_warn("Proper source for '%s.%s' already loaded", type, role);
- return NULL;
+ return source;
}
}
}
- if (!(type_info = _device_manager_get_type_info(dm->type_infos, type))) {
+ if (!(type_info = _device_manager_get_type_info(dm->type_infos, type, role))) {
pa_log_error("No type map for %s", type);
return NULL;
}
pa_log_info("Unload Source for '%s.%s'", type, role);
- if (!(type_info = _device_manager_get_type_info(dm->type_infos, type))) {
+ if (!(type_info = _device_manager_get_type_info(dm->type_infos, type, role))) {
pa_log_error("No type map for %s", type);
return;
}
pa_assert(type);
pa_assert(role);
- type_info = _device_manager_get_type_info(dm->type_infos, type);
+ type_info = _device_manager_get_type_info(dm->type_infos, type, role);
if (type_info == NULL) {
pa_log_error("No type info for %s", type);
return NULL;