return pa_streq(pulse_device_string, device_string);
}
-static dm_device* _device_item_set_active_profile(dm_device *device_item, const char *device_profile) {
- dm_device_profile *profile_item = NULL;
- uint32_t idx, active_profile_idx = PA_INVALID_INDEX, prev_active_profile = PA_INVALID_INDEX;
-
- if (!device_item || !device_item->profiles) {
- pa_log_error("Invalid Parameter");
- return NULL;
- }
-
- prev_active_profile = device_item->active_profile;
- PA_IDXSET_FOREACH(profile_item, device_item->profiles, idx) {
- if (!compare_device_profile(profile_item->profile, device_profile)) {
- active_profile_idx = idx;
- }
- }
-
- if (active_profile_idx != PA_INVALID_INDEX) {
- device_item->active_profile = active_profile_idx;
- } else {
- return NULL;
- }
-
- if (prev_active_profile != device_item->active_profile) {
- pa_log_debug("%s's active profile : %u", device_item->name, device_item->active_profile);
- notify_device_info_changed(device_item, DM_DEVICE_CHANGED_INFO_IO_DIRECTION, device_item->dm);
- }
-
- return device_item;
-}
-
static int get_profile_priority(const char *device_profile) {
if (!device_profile) {
return 0;
static dm_device* handle_device_type_available(struct device_type_info *type_info, const char *name, pa_device_manager *dm) {
dm_device_profile *profile_item = NULL;
dm_device *device_item = NULL;
- pa_bool_t made_newly = FALSE;
dm_device_direction_t direction;
pa_hashmap *playback = NULL, *capture = NULL;
if (!(device_item = _device_manager_get_device(dm->device_list, type_info->type))) {
pa_log_debug("No device item for %s, Create", type_info->type);
device_item = create_device_item(type_info->type, name, profile_item, dm);
- made_newly = TRUE;
} else {
_device_item_add_profile(device_item, profile_item, NULL, dm);
}
pa_assert(device_string_key);
pa_assert(json_object_is_type(device_file_o, json_type_object));
- if ((device_file_prop_o = json_object_object_get(device_file_o, "device-string")) && json_object_is_type(device_file_prop_o, json_type_string)) {
+ if (json_object_object_get_ex(device_file_o, "device-string", &device_file_prop_o) && json_object_is_type(device_file_prop_o, json_type_string)) {
if ((device_string = json_object_get_string(device_file_prop_o))) {
pa_log_debug("[DEBUG_PARSE] ---------------- Device File '%s' ----------------", device_string);
} else {
return NULL;
}
- if ((device_file_prop_o = json_object_object_get(device_file_o, DEVICE_TYPE_PROP_ROLE))) {
+ if (json_object_object_get_ex(device_file_o, DEVICE_TYPE_PROP_ROLE, &device_file_prop_o)) {
if (!(roles = parse_device_role_object(device_file_prop_o))) {
pa_log_error("Parse device role for '%s' failed", device_string);
goto failed;
file_map = pa_xmalloc0(sizeof(struct device_file_map));
- if ((device_files_o = json_object_object_get(o, DEVICE_FILE_OBJECT)) && json_object_is_type(device_files_o, json_type_object)) {
- if ((playback_devices_o = json_object_object_get(device_files_o, "playback-devices"))) {
+ if (json_object_object_get_ex(o, DEVICE_FILE_OBJECT, &device_files_o) && json_object_is_type(device_files_o, json_type_object)) {
+ if (json_object_object_get_ex(device_files_o, "playback-devices", &playback_devices_o)) {
pa_log_debug("[DEBUG_PARSE] ----------------- Playback Device Files ------------------");
file_map->playback = parse_device_file_array_object(playback_devices_o);
}
- if ((capture_devices_o = json_object_object_get(device_files_o, "capture-devices"))) {
+ if (json_object_object_get_ex(device_files_o, "capture-devices", &capture_devices_o)) {
pa_log_debug("[DEBUG_PARSE] ----------------- Capture Device Files ------------------");
file_map->capture = parse_device_file_array_object(capture_devices_o);
}
pa_log_debug("\n[DEBUG_PARSE] ==================== Parse device types ====================");
type_infos = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
- if ((device_array_o = json_object_object_get(o, DEVICE_TYPE_OBJECT)) && json_object_is_type(device_array_o, json_type_array)) {
+ if (json_object_object_get_ex(o, DEVICE_TYPE_OBJECT, &device_array_o) && json_object_is_type(device_array_o, json_type_array)) {
device_type_num = json_object_array_length(device_array_o);
for (device_type_idx = 0; device_type_idx < device_type_num ; device_type_idx++) {
json_object *device_o;
const char *device_type = NULL, *device_profile = NULL;
type_info = pa_xmalloc0(sizeof(struct device_type_info));
- if ((device_prop_o = json_object_object_get(device_o, "device-type")) && json_object_is_type(device_prop_o, json_type_string)) {
+ if (json_object_object_get_ex(device_o, "device-type", &device_prop_o) && json_object_is_type(device_prop_o, json_type_string)) {
device_type = json_object_get_string(device_prop_o);
pa_log_debug("[DEBUG_PARSE] ---------------- Parse device '%s' ----------------", device_type);
type_info->type = device_type;
pa_log_error("Get device type failed");
goto failed;
}
- if ((device_prop_o = json_object_object_get(device_o, "profile")) && json_object_is_type(device_prop_o, json_type_string)) {
+ if (json_object_object_get_ex(device_o, "profile", &device_prop_o) && json_object_is_type(device_prop_o, json_type_string)) {
device_profile = json_object_get_string(device_prop_o);
pa_log_debug("[DEBUG_PARSE] Profile: %s", device_profile);
type_info->profile = device_profile;
}
- if ((device_prop_o = json_object_object_get(device_o, DEVICE_TYPE_PROP_BUILTIN)) && json_object_is_type(device_prop_o, json_type_boolean)) {
+ if (json_object_object_get_ex(device_o, DEVICE_TYPE_PROP_BUILTIN, &device_prop_o) && json_object_is_type(device_prop_o, json_type_boolean)) {
builtin = json_object_get_boolean(device_prop_o);
pa_log_debug("[DEBUG_PARSE] builtin: %d", builtin);
type_info->builtin = builtin;
pa_log_error("Get device prop '%s' failed", DEVICE_TYPE_PROP_BUILTIN);
}
- if ((device_prop_o = json_object_object_get(device_o, DEVICE_TYPE_PROP_DIRECTION)) && json_object_is_type(device_prop_o, json_type_array)) {
+ if (json_object_object_get_ex(device_o, DEVICE_TYPE_PROP_DIRECTION, &device_prop_o) && json_object_is_type(device_prop_o, json_type_array)) {
const char *direction;
array_len = json_object_array_length(device_prop_o);
if ((array_len = json_object_array_length(device_prop_o)) > DEVICE_DIRECTION_MAX) {
pa_log_error("Get device prop '%s' failed", DEVICE_TYPE_PROP_DIRECTION);
}
- if ((device_prop_o = json_object_object_get(device_o, "avail-condition")) && json_object_is_type(device_prop_o, json_type_array)) {
+ if (json_object_object_get_ex(device_o, "avail-condition", &device_prop_o) && json_object_is_type(device_prop_o, json_type_array)) {
const char *avail_cond;
if ((array_len = json_object_array_length(device_prop_o)) > DEVICE_AVAIL_COND_NUM_MAX) {
pa_log_error("Invalid case, The number of avail-condition is too big (%d)", array_len);
pa_log_error("Get device prop 'avail-condition' failed");
}
- if ((device_prop_o = json_object_object_get(device_o, "playback-devices")) && json_object_is_type(device_prop_o, json_type_object)) {
+ if (json_object_object_get_ex(device_o, "playback-devices", &device_prop_o) && json_object_is_type(device_prop_o, json_type_object)) {
pa_log_debug("[DEBUG_PARSE] ------ playback devices ------");
type_info->playback_devices = parse_device_role_map(device_prop_o);
}
- if ((device_prop_o = json_object_object_get(device_o, "capture-devices")) && json_object_is_type(device_prop_o, json_type_object)) {
+ if (json_object_object_get_ex(device_o, "capture-devices", &device_prop_o) && json_object_is_type(device_prop_o, json_type_object)) {
pa_log_debug("[DEBUG_PARSE] ------ capture devices ------");
type_info->capture_devices = parse_device_role_map(device_prop_o);
}
}
int pa_device_manager_bt_sco_open(pa_device_manager *dm) {
- struct device_status_info *status_info;
dm_device *bt_device;
pa_assert(dm);
}
int pa_device_manager_bt_sco_close(pa_device_manager *dm) {
- struct device_status_info *status_info;
dm_device *bt_device;
pa_assert(dm);
/* Volumes */
m->volume_infos = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
- if ((volume_array_o = json_object_object_get(o, STREAM_MAP_VOLUMES)) && json_object_is_type(volume_array_o, json_type_array)) {
+ if (json_object_object_get_ex(o, STREAM_MAP_VOLUMES, &volume_array_o) && json_object_is_type(volume_array_o, json_type_array)) {
num_of_volume_types = json_object_array_length(volume_array_o);
for (i = 0; i < num_of_volume_types; i++) {
if ((volume_o = json_object_array_get_idx(volume_array_o, i)) && json_object_is_type(volume_o, json_type_object)) {
v = pa_xmalloc0(sizeof(volume_info));
pa_log_debug("volume found [%d]", i);
- if ((volume_type_o = json_object_object_get(volume_o, STREAM_MAP_VOLUME_TYPE)) && json_object_is_type(volume_type_o, json_type_string)) {
+ if (json_object_object_get_ex(volume_o, STREAM_MAP_VOLUME_TYPE, &volume_type_o) && json_object_is_type(volume_type_o, json_type_string)) {
volume_type = json_object_get_string(volume_type_o);
pa_log_debug(" - type : %s", volume_type);
} else {
pa_log_error("Get volume type failed");
goto failed;
}
- if ((is_hal_volume_o = json_object_object_get(volume_o, STREAM_MAP_VOLUME_IS_FOR_HAL)) && json_object_is_type(is_hal_volume_o, json_type_int)) {
+ if (json_object_object_get_ex(volume_o, STREAM_MAP_VOLUME_IS_FOR_HAL, &is_hal_volume_o) && json_object_is_type(is_hal_volume_o, json_type_int)) {
v->is_hal_volume_type = (pa_bool_t)json_object_get_int(is_hal_volume_o);
pa_log_debug(" - is-hal-volume : %d", v->is_hal_volume_type);
} else {
/* Streams */
m->stream_infos = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
- if ((stream_array_o = json_object_object_get(o, STREAM_MAP_STREAMS)) && json_object_is_type(stream_array_o, json_type_array)) {
+ if (json_object_object_get_ex(o, STREAM_MAP_STREAMS, &stream_array_o) && json_object_is_type(stream_array_o, json_type_array)) {
num_of_stream_types = json_object_array_length(stream_array_o);
for (i = 0; i < num_of_stream_types; i++) {
if ((stream_o = json_object_array_get_idx(stream_array_o, i)) && json_object_is_type(stream_o, json_type_object)) {
s = pa_xmalloc0(sizeof(stream_info));
pa_log_debug("stream found [%d]", i);
- if ((role_o = json_object_object_get(stream_o, STREAM_MAP_STREAM_ROLE)) && json_object_is_type(role_o, json_type_string)) {
+ if (json_object_object_get_ex(stream_o, STREAM_MAP_STREAM_ROLE, &role_o) && json_object_is_type(role_o, json_type_string)) {
role = json_object_get_string(role_o);
pa_log_debug(" - role : %s", role);
} else {
pa_log_error("Get stream role failed");
goto failed;
}
- if ((priority_o = json_object_object_get(stream_o, STREAM_MAP_STREAM_PRIORITY)) && json_object_is_type(priority_o, json_type_int)) {
+ if (json_object_object_get_ex(stream_o, STREAM_MAP_STREAM_PRIORITY, &priority_o) && json_object_is_type(priority_o, json_type_int)) {
s->priority = json_object_get_int(priority_o);
pa_log_debug(" - priority : %d", s->priority);
} else {
pa_log_error("Get stream priority failed");
goto failed;
}
- if ((route_type_o = json_object_object_get(stream_o, STREAM_MAP_STREAM_ROUTE_TYPE)) && json_object_is_type(route_type_o, json_type_string)) {
+ if (json_object_object_get_ex(stream_o, STREAM_MAP_STREAM_ROUTE_TYPE, &route_type_o) && json_object_is_type(route_type_o, json_type_string)) {
if (convert_route_type(&(s->route_type), json_object_get_string(route_type_o))) {
pa_log_error("convert stream route-type failed");
goto failed;
pa_log_error("Get stream route-type failed");
goto failed;
}
- if ((volume_types_o = json_object_object_get(stream_o, STREAM_MAP_STREAM_VOLUME_TYPES)) && json_object_is_type(volume_types_o, json_type_object)) {
- if ((volume_type_in_o = json_object_object_get(volume_types_o, STREAM_MAP_STREAM_VOLUME_TYPE_IN)) && json_object_is_type(volume_type_in_o, json_type_string))
+ if (json_object_object_get_ex(stream_o, STREAM_MAP_STREAM_VOLUME_TYPES, &volume_types_o) && json_object_is_type(volume_types_o, json_type_object)) {
+ if (json_object_object_get_ex(volume_types_o, STREAM_MAP_STREAM_VOLUME_TYPE_IN, &volume_type_in_o) && json_object_is_type(volume_type_in_o, json_type_string))
s->volume_types[STREAM_DIRECTION_IN] = json_object_get_string(volume_type_in_o);
else {
pa_log_error("Get stream volume-type-in failed");
goto failed;
}
- if ((volume_type_out_o = json_object_object_get(volume_types_o, STREAM_MAP_STREAM_VOLUME_TYPE_OUT)) && json_object_is_type(volume_type_out_o, json_type_string))
+ if (json_object_object_get_ex(volume_types_o, STREAM_MAP_STREAM_VOLUME_TYPE_OUT, &volume_type_out_o) && json_object_is_type(volume_type_out_o, json_type_string))
s->volume_types[STREAM_DIRECTION_OUT] = json_object_get_string(volume_type_out_o);
else {
pa_log_error("Get stream volume-type-out failed");
pa_log_error("Get stream volume-types failed");
goto failed;
}
- if ((avail_in_devices_o = json_object_object_get(stream_o, STREAM_MAP_STREAM_AVAIL_IN_DEVICES)) && json_object_is_type(avail_in_devices_o, json_type_array)) {
+ if (json_object_object_get_ex(stream_o, STREAM_MAP_STREAM_AVAIL_IN_DEVICES, &avail_in_devices_o) && json_object_is_type(avail_in_devices_o, json_type_array)) {
j = 0;
s->idx_avail_in_devices = pa_idxset_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
num_of_avail_in_devices = json_object_array_length(avail_in_devices_o);
pa_log_error("Get stream avail-in-devices failed");
goto failed;
}
- if ((avail_out_devices_o = json_object_object_get(stream_o, STREAM_MAP_STREAM_AVAIL_OUT_DEVICES)) && json_object_is_type(avail_out_devices_o, json_type_array)) {
+ if (json_object_object_get_ex(stream_o, STREAM_MAP_STREAM_AVAIL_OUT_DEVICES, &avail_out_devices_o) && json_object_is_type(avail_out_devices_o, json_type_array)) {
j = 0;
s->idx_avail_out_devices = pa_idxset_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
num_of_avail_out_devices = json_object_array_length(avail_out_devices_o);
pa_log_error("Get stream avail-out-devices failed");
goto failed;
}
- if ((avail_frameworks_o = json_object_object_get(stream_o, STREAM_MAP_STREAM_AVAIL_FRAMEWORKS)) && json_object_is_type(avail_frameworks_o, json_type_array)) {
+ if (json_object_object_get_ex(stream_o, STREAM_MAP_STREAM_AVAIL_FRAMEWORKS, &avail_frameworks_o) && json_object_is_type(avail_frameworks_o, json_type_array)) {
j = 0;
s->idx_avail_frameworks = pa_idxset_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
num_of_avail_frameworks = json_object_array_length(avail_frameworks_o);
}
static int init_ipc(pa_stream_manager *m) {
+ DBusError err;
+ pa_dbus_connection *conn = NULL;
+ static const DBusObjectPathVTable vtable = {
+ .message_function = method_handler_for_vt,
+ };
+
pa_assert(m);
pa_log_info("Initialization for IPC");
#ifdef HAVE_DBUS
pa_assert_se(pa_dbus_protocol_add_interface(m->dbus_protocol, STREAM_MANAGER_OBJECT_PATH, &stream_manager_interface_info, m) >= 0);
pa_assert_se(pa_dbus_protocol_register_extension(m->dbus_protocol, STREAM_MANAGER_INTERFACE) >= 0);
#else
- DBusError err;
- pa_dbus_connection *conn = NULL;
- static const DBusObjectPathVTable vtable = {
- .message_function = method_handler_for_vt,
- };
dbus_error_init(&err);