/* A macro to ease iteration through all entries */
#define PA_HASHMAP_FOREACH_KEY(e, h, state, key) \
- for ((state) = NULL, (e) = pa_hashmap_iterate((h), &(state),(const void**)&(key)); (e); (e) = pa_hashmap_iterate((h), &(state), (const void**)&(key)))
+ for ((state) = NULL, (e) = pa_hashmap_iterate((h), &(state), (const void**)&(key)); (e); (e) = pa_hashmap_iterate((h), &(state), (const void**)&(key)))
#define PA_DEVICE(pulse_device, pdt) \
pdt == PA_DEVICE_TYPE_SINK ? ((pa_sink *) pulse_device) : ((pa_source *) pulse_device)
}
if ((api_name = pa_proplist_gets(prop, PA_PROP_DEVICE_API))) {
- if (pa_streq (api_name, DEVICE_API_ALSA)) {
+ if (pa_streq(api_name, DEVICE_API_ALSA)) {
return TRUE;
} else {
return FALSE;
}
if ((api_name = pa_proplist_gets(prop, PA_PROP_DEVICE_API))) {
- if (pa_streq (api_name, DEVICE_API_BLUEZ)) {
+ if (pa_streq(api_name, DEVICE_API_BLUEZ)) {
return TRUE;
} else {
return FALSE;
const char *bus_name = NULL;
if ((bus_name = pa_proplist_gets(prop, PA_PROP_DEVICE_BUS))) {
- if (pa_streq (bus_name, DEVICE_BUS_USB)) {
+ if (pa_streq(bus_name, DEVICE_BUS_USB)) {
return TRUE;
} else {
return FALSE;
}
static void dump_capture_device_list(pa_hashmap *capture_devices) {
- pa_source *source= NULL;
+ pa_source *source = NULL;
void *state = NULL;
const char *role;
const char *device_class = NULL;
if ((device_class = pa_proplist_gets(prop, PA_PROP_DEVICE_CLASS))) {
- if (device_class && pa_streq (device_class, DEVICE_CLASS_SOUND)) {
+ if (device_class && pa_streq(device_class, DEVICE_CLASS_SOUND)) {
return TRUE;
} else {
return FALSE;
}
if ((device_class = pa_proplist_gets(prop, PA_PROP_DEVICE_CLASS))) {
- if (device_class && pa_streq (device_class, DEVICE_CLASS_MONITOR)) {
+ if (device_class && pa_streq(device_class, DEVICE_CLASS_MONITOR)) {
return TRUE;
} else {
return FALSE;
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 ) {
+ if (!device_item || !device_item->profiles) {
pa_log_error("Invalid Parameter");
return NULL;
}
uint32_t idx, prev_active_profile;
unsigned int device_size;
- if (!device_item || !device_item->profiles ) {
+ if (!device_item || !device_item->profiles) {
pa_log_error("Invalid Parameter");
return NULL;
}
if (pdt == PA_DEVICE_TYPE_SINK) {
if (!(profile_item->playback_devices))
profile_item->playback_devices = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
- if(pa_hashmap_put(profile_item->playback_devices, (void *)role, pulse_device) < 0)
+ if (pa_hashmap_put(profile_item->playback_devices, (void *)role, pulse_device) < 0)
return NULL;
} else {
if (!(profile_item->capture_devices))
profile_item->capture_devices = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
- if(pa_hashmap_put(profile_item->capture_devices, (void *)role, pulse_device) < 0)
+ if (pa_hashmap_put(profile_item->capture_devices, (void *)role, pulse_device) < 0)
return NULL;
}
if (!(profile_item->playback_devices))
profile_item->playback_devices = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
- if(pa_hashmap_put(profile_item->playback_devices, (void *)role, sink) < 0)
+ if (pa_hashmap_put(profile_item->playback_devices, (void *)role, sink) < 0)
return NULL;
return profile_item;
if (!(profile_item->capture_devices))
profile_item->capture_devices = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
- if(pa_hashmap_put(profile_item->capture_devices, (void *)role, source) < 0)
+ if (pa_hashmap_put(profile_item->capture_devices, (void *)role, source) < 0)
return NULL;
return profile_item;
return NULL;
}
- if (!(source= pa_hashmap_get(profile_item->capture_devices, role))) {
+ if (!(source = pa_hashmap_get(profile_item->capture_devices, role))) {
pa_log_warn("cannot get source for %s", role);
return NULL;
}
else
direc = DM_DEVICE_DIRECTION_IN;
- if(!(profile_item = create_device_profile(device_profile, direc, NULL, NULL))) {
+ if (!(profile_item = create_device_profile(device_profile, direc, NULL, NULL))) {
pa_log_error("create_device_profile failed");
goto failed;
}
}
return profile_item;
-failed :
+failed:
if (profile_item)
pa_xfree(profile_item);
return NULL;
}
}
- if(!(profile_item = handle_not_predefined_device_profile(pulse_device, pdt, device_profile))) {
+ if (!(profile_item = handle_not_predefined_device_profile(pulse_device, pdt, device_profile))) {
pa_log_error("failed to handle unknown device profile");
goto failed;
}
_device_profile_update_direction(profile_item);
if (device_class == DM_DEVICE_CLASS_BT) {
- if((device_item = _device_manager_get_device(dm->device_list, DEVICE_TYPE_BT))) {
+ if ((device_item = _device_manager_get_device(dm->device_list, DEVICE_TYPE_BT))) {
pa_log_debug("found bt device");
_device_item_add_profile(device_item, profile_item, NULL, dm);
goto end;
return device_item;
-failed :
+failed:
if (playback)
pa_hashmap_free(playback);
if (capture)
Check device_item is already exists.
If already exists, add loaded sink or source to that.
*/
- if((device_item = _device_manager_get_device(dm->device_list, type_info->type))) {
- if((profile_item = _device_item_get_profile(device_item, type_info->profile))) {
+ if ((device_item = _device_manager_get_device(dm->device_list, type_info->type))) {
+ if ((profile_item = _device_item_get_profile(device_item, type_info->profile))) {
pa_log_debug("device_item for %s.%s already exists", type_info->type, type_info->profile);
if (!_device_profile_add_pulse_device(profile_item, role, pulse_device, pdt))
pa_log_error("add pulse device to profile_item failed");
}
static void handle_sink_unloaded(pa_sink *sink, pa_device_manager *dm) {
- dm_device_profile *profile_item= NULL;
+ dm_device_profile *profile_item = NULL;
struct device_type_info *type_info;
dm_device *device_item;
uint32_t device_idx = 0, profile_idx;
}
static void handle_source_unloaded(pa_source *source, pa_device_manager *dm) {
- dm_device_profile *profile_item= NULL;
+ dm_device_profile *profile_item = NULL;
struct device_type_info *type_info;
dm_device *device_item;
uint32_t device_idx = 0, profile_idx;
void *state = NULL;
const char *role;
- if (!source|| !dm) {
+ if (!source || !dm) {
pa_log_error("Invalid Paramter");
return;
}
if (!pa_hashmap_size(profile_item->capture_devices)) {
pa_hashmap_free(profile_item->capture_devices);
- profile_item->capture_devices= NULL;
+ profile_item->capture_devices = NULL;
if (profile_item->direction == DM_DEVICE_DIRECTION_BOTH) {
type_info = _device_manager_get_type_info(dm->type_infos, profile_item->device_item->type, profile_item->profile);
pa_log_debug("argument null");
return PA_HOOK_OK;
}
- if(!(role = device_file_info_get_role_with_params(file_info, device_string_removed_params))) {
+ if (!(role = device_file_info_get_role_with_params(file_info, device_string_removed_params))) {
pa_log_error("No role for %s", file_info->device_string);
return PA_HOOK_OK;
}
pa_log_debug("argument null");
return PA_HOOK_OK;
}
- if(!(role = device_file_info_get_role_with_params(file_info, device_string_removed_params))) {
+ if (!(role = device_file_info_get_role_with_params(file_info, device_string_removed_params))) {
pa_log_error("No role for %s", file_info->device_string);
return PA_HOOK_OK;
}
return file_info;
-failed :
+failed:
return NULL;
}
pa_log_debug("[DEBUG_PARSE] ----------------- Capture Device Files ------------------");
file_map->capture = parse_device_file_array_object(capture_devices_o);
}
- }
- else {
+ } else {
pa_log_error("Get device files object failed");
return NULL;
}
return roles;
-failed :
+failed:
if (roles)
pa_xfree(roles);
if ((device_prop_o = json_object_object_get(device_o, "profile")) && 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;
+ type_info->profile = device_profile;
} else {
pa_log_debug("no device-profile");
}
}
pa_idxset_put(type_infos, type_info, NULL);
- }
- else {
+ } else {
pa_log_debug("Get device type object failed");
}
}
- }
- else {
+ } else {
pa_log_debug("Get device type array object failed");
}
return type_infos;
-failed :
+failed:
if (type_infos)
pa_xfree(type_infos);
return -1;
}
- if((device_item = _device_manager_get_device(dm->device_list, type_info->type))) {
- if((profile_item = _device_item_get_profile(device_item, type_info->profile))) {
+ if ((device_item = _device_manager_get_device(dm->device_list, type_info->type))) {
+ if ((profile_item = _device_item_get_profile(device_item, type_info->profile))) {
pa_log_debug("device_item for %s.%s already exists", type_info->type, type_info->profile);
return 0;
}
PA_IDXSET_FOREACH(device_item, dm->device_list, device_idx) {
if (pa_streq(device_item->type, device_type)) {
- if((profile_item = _device_item_get_profile(device_item, device_profile))) {
+ if ((profile_item = _device_item_get_profile(device_item, device_profile))) {
if (_device_item_get_size(device_item) == 1) {
_device_list_remove_device(dm->device_list, device_item, dm);
notify_device_connection_changed(device_item, FALSE, dm);
}
if (need_to_check_for_state) {
match = FALSE;
- if ((COMPOUND_STATE(profile_item)== DM_DEVICE_STATE_DEACTIVATED) && (device_flags & DEVICE_STATE_DEACTIVATED_FLAG))
+ if ((COMPOUND_STATE(profile_item) == DM_DEVICE_STATE_DEACTIVATED) && (device_flags & DEVICE_STATE_DEACTIVATED_FLAG))
match = TRUE;
else if ((COMPOUND_STATE(profile_item) == DM_DEVICE_STATE_ACTIVATED) && (device_flags & DEVICE_STATE_ACTIVATED_FLAG))
match = TRUE;
continue;
dbus_message_iter_get_basic(&dict_entry_val, &codec);
pa_log_debug("Codec = [%d]", codec);
- *is_wide_band= codec == BT_MSBC_CODEC_ID ? TRUE : FALSE;
+ *is_wide_band = (codec == BT_MSBC_CODEC_ID) ? TRUE : FALSE;
} else if (pa_streq("nrec", property) && nrec) {
dbus_message_iter_next(&dict_entry);
dbus_message_iter_recurse(&dict_entry, &dict_entry_val);
pa_assert_se(dbus_message_iter_open_container(&msg_iter, DBUS_TYPE_ARRAY, "(isiis)", &array_iter));
PA_IDXSET_FOREACH(device_item, dm->device_list, device_idx) {
- if(!(profile_item = pa_idxset_get_by_index(device_item->profiles, device_item->active_profile))) {
+ if (!(profile_item = pa_idxset_get_by_index(device_item->profiles, device_item->active_profile))) {
pa_log_error("no active profile");
continue;
}
pa_assert_se((reply = dbus_message_new_method_return(msg)));
dbus_error_init(&error);
- if(!dbus_message_get_args(msg, NULL,
+ if (!dbus_message_get_args(msg, NULL,
DBUS_TYPE_STRING, &device_type,
DBUS_TYPE_STRING, &device_profile,
DBUS_TYPE_INT32, &status,
pa_assert(userdata);
for (method_idx = 0; method_idx < METHOD_HANDLER_MAX; method_idx++) {
- if (dbus_message_is_method_call(msg, DBUS_INTERFACE_DEVICE_MANAGER, method_handlers[method_idx].method_name )) {
+ if (dbus_message_is_method_call(msg, DBUS_INTERFACE_DEVICE_MANAGER, method_handlers[method_idx].method_name)) {
method_handlers[method_idx].receive_cb(conn, msg, userdata);
return DBUS_HANDLER_RESULT_HANDLED;
}
/* Macros */
#define CONVERT_TO_DEVICE_DIRECTION(stream_type)\
- ((stream_type==STREAM_SINK_INPUT)?DM_DEVICE_DIRECTION_OUT:DM_DEVICE_DIRECTION_IN)
+ ((stream_type == STREAM_SINK_INPUT) ? DM_DEVICE_DIRECTION_OUT : DM_DEVICE_DIRECTION_IN)
#define IS_AVAILABLE_DIRECTION(stream_type, device_direction) \
- ((stream_type==STREAM_SINK_INPUT)?(device_direction & DM_DEVICE_DIRECTION_OUT):(device_direction & DM_DEVICE_DIRECTION_IN))
+ ((stream_type == STREAM_SINK_INPUT) ? (device_direction & DM_DEVICE_DIRECTION_OUT) : (device_direction & DM_DEVICE_DIRECTION_IN))
/* PCM Dump */
#define PA_DUMP_INI_DEFAULT_PATH "/usr/etc/mmfw_audio_pcm_dump.ini"
pa_log_warn(" -- could not get combine_sink_arg1");
} else if (!combine_sink_arg2) {
sink = combine_sink_arg2 = pa_device_manager_get_sink(device, DEVICE_ROLE_NORMAL);
- if(sink && !pa_streq(sink->name, combine_sink_arg1->name)) {
+ if (sink && !pa_streq(sink->name, combine_sink_arg1->name)) {
pa_log_debug(" -- combine_sink_arg2[%s]", sink->name);
/* load combine sink */
if (!u->module_combine_sink_for_ex) {
pa_xfree(args);
}
sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_COMBINED_EX, PA_NAMEREG_SINK);
- PA_IDXSET_FOREACH (s, combine_sink_arg1->inputs, s_idx) {
+ PA_IDXSET_FOREACH(s, combine_sink_arg1->inputs, s_idx) {
if (s == data->stream) {
pa_sink_input_move_to(s, sink, FALSE);
pa_log_debug(" -- *** sink-input(%p,%u) moves to sink(%p,%s)", s, ((pa_sink_input*)s)->index, sink, sink->name);
}
}
} else if (!sink) {
- pa_log_warn (" -- could not get combine_sink_arg2");
+ pa_log_warn(" -- could not get combine_sink_arg2");
}
}
if (data->origins_from_new_data)
pa_source_output_move_to(data->stream, source, FALSE);
}
} else
- pa_log_warn (" -- could not get source");
+ pa_log_warn(" -- could not get source");
}
}
}
}
}
- if ((data->stream_type==STREAM_SINK_INPUT)?!(*(data->proper_sink)):!(*(data->proper_source))) {
+ if ((data->stream_type == STREAM_SINK_INPUT) ? !(*(data->proper_sink)) : !(*(data->proper_source))) {
pa_log_warn("[SELECT] could not find a proper sink/source, set it to null sink/source");
if (data->stream_type == STREAM_SINK_INPUT)
*(data->proper_sink) = null_sink;
}
route_info.num_of_devices = 1;
route_info.device_infos = pa_xmalloc0(sizeof(hal_device_info)*route_info.num_of_devices);
- route_info.device_infos[0].direction = (data->stream_type==STREAM_SINK_INPUT)?DIRECTION_OUT:DIRECTION_IN;
+ route_info.device_infos[0].direction = (data->stream_type == STREAM_SINK_INPUT) ? DIRECTION_OUT : DIRECTION_IN;
/* unload combine sink */
- if (data->stream_type==STREAM_SINK_INPUT && u->module_combine_sink) {
+ if (data->stream_type == STREAM_SINK_INPUT && u->module_combine_sink) {
pa_log_info("[ROUTE][RESET] unload module[%s]", SINK_NAME_COMBINED);
combine_sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_COMBINED, PA_NAMEREG_SINK);
null_sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_NULL, PA_NAMEREG_SINK);
if (!combine_sink || !null_sink)
pa_log_error("[ROUTE][RESET] could not get combine_sink(%p) or null_sink(%p)", combine_sink, null_sink);
else {
- PA_IDXSET_FOREACH (s, combine_sink->inputs, s_idx) {
+ PA_IDXSET_FOREACH(s, combine_sink->inputs, s_idx) {
pa_sink_input_move_to(s, null_sink, FALSE);
pa_log_debug("[ROUTE][RESET] *** sink-input(%p,%u) moves to sink(%p,%s)", s, ((pa_sink_input*)s)->index, null_sink, null_sink->name);
}
pa_log_debug(" ** found a matched device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction);
use_internal_codec = pa_device_manager_is_device_use_internal_codec(device, CONVERT_TO_DEVICE_DIRECTION(data->stream_type), DEVICE_ROLE_NORMAL);
if (use_internal_codec) {
- hal_direction = (data->stream_type==STREAM_SINK_INPUT)?DIRECTION_OUT:DIRECTION_IN;
+ hal_direction = (data->stream_type == STREAM_SINK_INPUT) ? DIRECTION_OUT : DIRECTION_IN;
route_info.num_of_devices++;
route_info.device_infos = pa_xrealloc(route_info.device_infos, sizeof(hal_device_info)*route_info.num_of_devices);
route_info.device_infos[route_info.num_of_devices-1].type = dm_device_type;
if (data->route_type == STREAM_ROUTE_TYPE_AUTO) {
/* check if this device uses internal codec */
use_internal_codec = pa_device_manager_is_device_use_internal_codec(device, CONVERT_TO_DEVICE_DIRECTION(data->stream_type), DEVICE_ROLE_NORMAL);
- if(use_internal_codec) {
+ if (use_internal_codec) {
/* set other device's state to deactivated */
PA_IDXSET_FOREACH(_device, conn_devices, conn_idx) {
if (device == _device)
sink = pa_device_manager_get_sink(device, DEVICE_ROLE_NORMAL);
/* unload combine sink */
- if (data->stream_type==STREAM_SINK_INPUT && u->module_combine_sink) {
+ if (data->stream_type == STREAM_SINK_INPUT && u->module_combine_sink) {
if ((combine_sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_COMBINED, PA_NAMEREG_SINK))) {
- PA_IDXSET_FOREACH (s, combine_sink->inputs, s_idx) {
+ PA_IDXSET_FOREACH(s, combine_sink->inputs, s_idx) {
pa_sink_input_move_to(s, sink, FALSE);
pa_log_debug("[ROUTE][AUTO] *** sink-input(%p,%u) moves to sink(%p,%s)", s, ((pa_sink_input*)s)->index, sink, sink->name);
}
pa_xfree(args);
}
if ((sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_COMBINED, PA_NAMEREG_SINK))) {
- PA_IDXSET_FOREACH (s, combine_sink_arg1->inputs, s_idx) {
+ PA_IDXSET_FOREACH(s, combine_sink_arg1->inputs, s_idx) {
if (s == data->stream) {
pa_sink_input_move_to(s, sink, FALSE);
pa_log_debug("[ROUTE][AUTO_ALL] *** sink-nput(%p,%u) moves to sink(%p,%s)",
} else {
/* move sink-inputs/source-outputs if needed */
if (data->idx_streams) {
- PA_IDXSET_FOREACH (s, data->idx_streams, s_idx) { /* data->idx_streams: null_sink */
+ PA_IDXSET_FOREACH(s, data->idx_streams, s_idx) { /* data->idx_streams: null_sink */
if (!pa_stream_manager_get_route_type(s, FALSE, data->stream_type, &route_type) &&
(route_type == STREAM_ROUTE_TYPE_AUTO_ALL)) {
if ((data->stream_type == STREAM_SINK_INPUT) && (sink && (sink != ((pa_sink_input*)s)->sink))) {
dm_device_id = pa_device_manager_get_device_id(latest_device);
use_internal_codec = pa_device_manager_is_device_use_internal_codec(latest_device, CONVERT_TO_DEVICE_DIRECTION(data->stream_type), DEVICE_ROLE_NORMAL);
if (use_internal_codec) {
- hal_direction = (data->stream_type==STREAM_SINK_INPUT)?DIRECTION_OUT:DIRECTION_IN;
+ hal_direction = (data->stream_type == STREAM_SINK_INPUT) ? DIRECTION_OUT : DIRECTION_IN;
route_info.num_of_devices++;
route_info.device_infos = pa_xrealloc(route_info.device_infos, sizeof(hal_device_info)*route_info.num_of_devices);
route_info.device_infos[route_info.num_of_devices-1].type = dm_device_type;
/* unload combine sink */
if (data->stream_type == STREAM_SINK_INPUT && u->module_combine_sink) {
if ((combine_sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_COMBINED, PA_NAMEREG_SINK))) {
- PA_IDXSET_FOREACH (s, combine_sink->inputs, s_idx) {
+ PA_IDXSET_FOREACH(s, combine_sink->inputs, s_idx) {
pa_sink_input_move_to(s, sink, FALSE);
pa_log_debug("[ROUTE][AUTO_LAST_CONN] *** sink-input(%p,%u) moves to sink(%p,%s)", s, ((pa_sink_input*)s)->index, sink, sink->name);
}
route_info.num_of_devices++;
route_info.device_infos = pa_xrealloc(route_info.device_infos, sizeof(hal_device_info)*route_info.num_of_devices);
route_info.device_infos[route_info.num_of_devices-1].type = dm_device_type;
- route_info.device_infos[route_info.num_of_devices-1].direction = (data->stream_type==STREAM_SINK_INPUT)?DIRECTION_OUT:DIRECTION_IN;
+ route_info.device_infos[route_info.num_of_devices-1].direction = (data->stream_type == STREAM_SINK_INPUT) ? DIRECTION_OUT : DIRECTION_IN;
pa_log_info(" ** found a matched device and set state to ACTIVATED: type[%-16s], direction[0x%x]",
route_info.device_infos[route_info.num_of_devices-1].type, dm_device_direction);
/* set device state to activated */
else if (data->stream_type == STREAM_SOURCE_OUTPUT)
source = pa_device_manager_get_source(device, DEVICE_ROLE_NORMAL);
if (data->idx_streams) {
- PA_IDXSET_FOREACH (s, data->idx_streams, idx) {
+ PA_IDXSET_FOREACH(s, data->idx_streams, idx) {
if (sink && (sink != ((pa_sink_input*)s)->sink)) {
pa_sink_input_move_to(s, sink, FALSE);
pa_log_debug("[ROUTE][MANUAL] *** sink-input(%p,%u) moves to sink(%p,%s)", s, ((pa_sink_input*)s)->index, sink, sink->name);
if (route_info.device_infos) {
/* send information to HAL to set routing */
- if(pa_hal_manager_do_route (u->hal_manager, &route_info))
+ if (pa_hal_manager_do_route(u->hal_manager, &route_info))
pa_log_error("[ROUTE] Failed to pa_hal_manager_do_route()");
pa_xfree(route_info.device_infos);
}
route_option.value = data->value;
/* send information to HAL to update routing option */
- if(pa_hal_manager_update_route_option (u->hal_manager, &route_option))
+ if (pa_hal_manager_update_route_option(u->hal_manager, &route_option))
pa_log_error("[ROUTE_OPT] Failed to pa_hal_manager_update_route_option()");
return PA_HOOK_OK;
if (combine_sink->inputs) {
if (!sink)
sink = null_sink;
- PA_IDXSET_FOREACH (s, combine_sink->inputs, idx) {
+ PA_IDXSET_FOREACH(s, combine_sink->inputs, idx) {
/* re-route this stream to the remaining device using internal codec */
pa_sink_input_move_to(s, sink, FALSE);
pa_log_debug("[CONN] *** sink-input(%p,%u) moves to sink(%p,%s)", s, ((pa_sink_input*)s)->index, sink, sink->name);
/* unload combine sink for external devices */
if ((combine_sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_COMBINED_EX, PA_NAMEREG_SINK))) {
if (combine_sink->inputs) {
- PA_IDXSET_FOREACH (s, combine_sink->inputs, idx) {
+ PA_IDXSET_FOREACH(s, combine_sink->inputs, idx) {
pa_sink_input_move_to(s, null_sink, FALSE);
pa_log_debug("[CONN] *** sink-input(%p,%u) moves to sink(%p,%s)", s, ((pa_sink_input*)s)->index, null_sink, null_sink->name);
}
pa_assert(userdata);
- if(dbus_message_get_type(s)!=DBUS_MESSAGE_TYPE_SIGNAL)
+ if (dbus_message_get_type(s) != DBUS_MESSAGE_TYPE_SIGNAL)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
pa_log_info("Audio handler received msg");
DBUS_TYPE_STRING, &arg_s,
DBUS_TYPE_INVALID)) {
goto fail;
- } else{
+ } else {
_do_something2(arg_s, userdata);
}
} else if (dbus_message_is_signal(s, AUDIO_CLIENT_INTERFACE_NAME, "TestSignalFromClient1")) {
DBUS_TYPE_STRING, &arg_s,
DBUS_TYPE_INVALID)) {
goto fail;
- } else{
+ } else {
_do_something2(arg_s, userdata);
}
} else {
}
}
}
- else{
+ else {
pa_log_warn("Not our interface, not handle it");
}
- } else{
+ } else {
pa_log_warn("Wrong Signature");
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_SIGNATURE, "Wrong Signature, Expected (ss)");
}
handle_get_all(conn, msg, userdata);
return DBUS_HANDLER_RESULT_HANDLED;
}
- else{
+ else {
pa_log_warn("Not our interface, not handle it");
}
- } else{
+ } else {
pa_log_warn("Wrong Signature");
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_SIGNATURE, "Wrong Signature, Expected (ss)");
}
if (pa_streq(interface_name, INTERFACE_POLICY)) {
for (prop_idx = 0; prop_idx < PROPERTY_MAX; prop_idx++) {
if (pa_streq(property_name, property_handlers[prop_idx].property_name)) {
- if (pa_streq(property_handlers[prop_idx].type,property_sig)) {
+ if (pa_streq(property_handlers[prop_idx].type, property_sig)) {
property_handlers[prop_idx].set_cb(conn, msg, &variant_iter, userdata);
return DBUS_HANDLER_RESULT_HANDLED;
}
- else{
+ else {
pa_log_warn("Wrong Property Signature");
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_SIGNATURE, "Wrong Signature, Expected (ssv)");
}
}
}
}
- else{
+ else {
pa_log_warn("Not our interface, not handle it");
}
- } else{
+ } else {
pa_log_warn("Wrong Signature");
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_SIGNATURE, "Wrong Signature, Expected (ssv)");
}
pa_assert(userdata);
for (method_idx = 0; method_idx < METHOD_HANDLER_MAX; method_idx++) {
- if (dbus_message_is_method_call(msg, INTERFACE_POLICY, method_handlers[method_idx].method_name )) {
+ if (dbus_message_is_method_call(msg, INTERFACE_POLICY, method_handlers[method_idx].method_name)) {
if (pa_streq(dbus_message_get_signature(msg), method_arg_signatures[method_idx])) {
method_handlers[method_idx].receive_cb(conn, msg, userdata);
return DBUS_HANDLER_RESULT_HANDLED;
}
- else{
+ else {
pa_log_warn("Wrong Argument Signature");
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_SIGNATURE, "Wrong Signature, Expected %s", method_arg_signatures[method_idx]);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
return handle_introspect(c, m, u);
- } else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "Get")){
+ } else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "Get")) {
return handle_get_property(c, m, u);
- } else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "Set")){
+ } else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "Set")) {
return handle_set_property(c, m, u);
- } else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "GetAll")){
+ } else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "GetAll")) {
return handle_get_all_property(c, m, u);
- } else{
+ } else {
return handle_policy_methods(c, m, u);
}
pa_log_debug("Dbus endpoint init");
if (u && u->dbus_conn) {
- if(!dbus_connection_register_object_path(pa_dbus_connection_get(u->dbus_conn), OBJECT_PATH, &vtable_endpoint, u))
+ if (!dbus_connection_register_object_path(pa_dbus_connection_get(u->dbus_conn), OBJECT_PATH, &vtable_endpoint, u))
pa_log_error("Failed to register object path");
- } else{
+ } else {
pa_log_error("Cannot get dbus connection to register object path");
}
}
{
pa_log_debug("Dbus endpoint done");
if (u && u->dbus_conn) {
- if(!dbus_connection_unregister_object_path(pa_dbus_connection_get(u->dbus_conn), OBJECT_PATH))
+ if (!dbus_connection_unregister_object_path(pa_dbus_connection_get(u->dbus_conn), OBJECT_PATH))
pa_log_error("Failed to unregister object path");
- } else{
+ } else {
pa_log_error("Cannot get dbus connection to unregister object path");
}
}
}
pa_log_error("Unable to contact D-Bus system bus: %s: %s", error.name, error.message);
goto fail;
- } else{
+ } else {
pa_log_debug("Got dbus connection");
}
u->dbus_conn = connection;
- if( watch_signals(u) < 0 )
+ if (watch_signals(u) < 0)
pa_log_error("dbus watch signals failed");
else
pa_log_debug("dbus ready to get signals");
endpoint_done(u);
unwatch_signals(u);
- if (u->dbus_conn){
+ if (u->dbus_conn) {
pa_dbus_connection_unref(u->dbus_conn);
u->dbus_conn = NULL;
}
static pa_dbus_arg_info simple_play_args[] = { { "uri", "s", "in" },
{ "role", "s", "in" },
- { "volume_gain", "s", "in" }};
+ { "volume_gain", "s", "in" } };
static pa_dbus_arg_info sample_play_args[] = { { "sample_name", "s", "in" },
{ "role", "s", "in" },
- { "volume_gain", "s", "in" }};
+ { "volume_gain", "s", "in" } };
static const char* signature_args_for_in[] = { "sss", "sss" };
pa_assert(userdata);
for (idx = 0; idx < METHOD_HANDLER_MAX; idx++) {
- if (dbus_message_is_method_call(msg, SOUND_PLAYER_INTERFACE, method_handlers[idx].method_name )) {
+ if (dbus_message_is_method_call(msg, SOUND_PLAYER_INTERFACE, method_handlers[idx].method_name)) {
if (pa_streq(dbus_message_get_signature(msg), signature_args_for_in[idx])) {
method_handlers[idx].receive_cb(conn, msg, userdata);
return DBUS_HANDLER_RESULT_HANDLED;
}
#endif
-static int init_ipc (struct userdata *u) {
+static int init_ipc(struct userdata *u) {
int pre_mask;
#ifdef HAVE_DBUS
#ifndef USE_DBUS_PROTOCOL
pa_log_info("Initialization for IPC");
pre_mask = umask(0);
- if (mknod(KEYTONE_PATH,S_IFIFO|0660,0)<0)
+ if (mknod(KEYTONE_PATH, S_IFIFO|0660, 0) < 0)
pa_log_warn("mknod failed. errno=[%d][%s]", errno, strerror(errno));
umask(pre_mask);
fcntl(u->fd, F_SETFL, O_NONBLOCK);
/* change access mode so group can use keytone pipe */
- if (fchmod (u->fd, 0666) == -1)
+ if (fchmod(u->fd, 0666) == -1)
pa_log_warn("Changing keytone access mode is failed. errno=[%d][%s]", errno, strerror(errno));
/* change group due to security request */
- if (fchown (u->fd, -1, KEYTONE_GROUP) == -1)
+ if (fchown(u->fd, -1, KEYTONE_GROUP) == -1)
pa_log_warn("Changing keytone group is failed. errno=[%d][%s]", errno, strerror(errno));
u->io = u->module->core->mainloop->io_new(u->module->core->mainloop, u->fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_event_callback, u);
return -1;
}
-static void deinit_ipc (struct userdata *u) {
+static void deinit_ipc(struct userdata *u) {
pa_assert(u);
}
#else
if (u->dbus_conn) {
- if(!dbus_connection_unregister_object_path(pa_dbus_connection_get(u->dbus_conn), SOUND_PLAYER_OBJECT_PATH))
+ if (!dbus_connection_unregister_object_path(pa_dbus_connection_get(u->dbus_conn), SOUND_PLAYER_OBJECT_PATH))
pa_log_error("Failed to unregister object path");
u->dbus_conn = NULL;
}
NULL
};
-static int build_pollfd (struct userdata *u) {
+static int build_pollfd(struct userdata *u) {
int32_t ret;
struct pollfd *pollfd;
int fd = -1;
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
pa_sink_set_rtpoll(u->sink, u->rtpoll);
- unsuspend (u);
+ unsuspend(u);
u->block_usec = BLOCK_USEC;
u->timestamp = 0ULL;
NULL
};
-static int build_pollfd (struct userdata *u) {
+static int build_pollfd(struct userdata *u) {
int32_t ret;
struct pollfd *pollfd;
int fd = -1;
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
pa_source_set_rtpoll(u->source, u->rtpoll);
- unsuspend (u);
+ unsuspend(u);
u->block_usec = BLOCK_USEC;
u->latency_time = u->block_usec;
} stream_direction_t;
#define GET_STREAM_NEW_SAMPLE_SPEC_PTR(stream, type) \
- (type == STREAM_SINK_INPUT? &(((pa_sink_input_new_data*)stream)->sample_spec) : &(((pa_source_output_new_data*)stream)->sample_spec))
+ (type == STREAM_SINK_INPUT ? &(((pa_sink_input_new_data*)stream)->sample_spec) : &(((pa_source_output_new_data*)stream)->sample_spec))
#define GET_STREAM_NEW_SAMPLE_SPEC(stream, type) \
- (type == STREAM_SINK_INPUT? ((pa_sink_input_new_data*)stream)->sample_spec : ((pa_source_output_new_data*)stream)->sample_spec)
+ (type == STREAM_SINK_INPUT ? ((pa_sink_input_new_data*)stream)->sample_spec : ((pa_source_output_new_data*)stream)->sample_spec)
#define GET_STREAM_SAMPLE_SPEC(stream, type) \
- (type == STREAM_SINK_INPUT? ((pa_sink_input*)stream)->sample_spec : ((pa_source_output*)stream)->sample_spec)
+ (type == STREAM_SINK_INPUT ? ((pa_sink_input*)stream)->sample_spec : ((pa_source_output*)stream)->sample_spec)
#define IS_FOCUS_ACQUIRED(focus, type) \
- (type == STREAM_SINK_INPUT? (focus & STREAM_FOCUS_ACQUIRED_PLAYBACK) : (focus & STREAM_FOCUS_ACQUIRED_CAPTURE))
+ (type == STREAM_SINK_INPUT ? (focus & STREAM_FOCUS_ACQUIRED_PLAYBACK) : (focus & STREAM_FOCUS_ACQUIRED_CAPTURE))
typedef struct _stream_info {
int32_t priority;
};
/* TODO : after preparing gain map, we can remove it */
-static const char *__get_gain_type_string_by_idx (uint32_t gain_type_idx) {
+static const char *__get_gain_type_string_by_idx(uint32_t gain_type_idx) {
switch (gain_type_idx) {
case GAIN_TYPE_DEFAULT: return "default";
case GAIN_TYPE_DIALER: return "dialer";
}
}
-static int load_out_volume_conf_file (pa_stream_manager *m) {
+static int load_out_volume_conf_file(pa_stream_manager *m) {
int ret = 0;
dictionary *dict = NULL;
uint32_t gain_type_idx = 0;
/* convert dB volume to linear volume */
double *vol_value = pa_xmalloc0(sizeof(double));
*vol_value = 0.0f;
- if(strncmp(token, "0", strlen(token)))
+ if (strncmp(token, "0", strlen(token)))
*vol_value = pow(10.0, (atof(token) - 100) / 20.0);
if (!v->values[STREAM_DIRECTION_OUT].idx_volume_values)
v->values[STREAM_DIRECTION_OUT].idx_volume_values = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
if (get_volume_value(m, stream_type, is_hal_volume, volume_type, volume_level, &volume_linear))
return -1;
- PA_IDXSET_FOREACH(s, stream_type == STREAM_SINK_INPUT?m->core->sink_inputs:m->core->source_outputs, idx) {
+ PA_IDXSET_FOREACH(s, stream_type == STREAM_SINK_INPUT ? m->core->sink_inputs : m->core->source_outputs, idx) {
if ((volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE))) {
/* Get modifier for gain */
modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE);
}
}
} else {
- PA_IDXSET_FOREACH(s, stream_type == STREAM_SINK_INPUT?m->core->sink_inputs:m->core->source_outputs, idx) {
+ PA_IDXSET_FOREACH(s, stream_type == STREAM_SINK_INPUT ? m->core->sink_inputs : m->core->source_outputs, idx) {
if ((volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE))) {
/* Get modifier for gain */
modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE);
const char *modifier_gain = NULL;
pa_assert(m);
- s = pa_idxset_get_by_index(stream_type == STREAM_SINK_INPUT?m->core->sink_inputs:m->core->source_outputs, idx);
+ s = pa_idxset_get_by_index(stream_type == STREAM_SINK_INPUT ? m->core->sink_inputs : m->core->source_outputs, idx);
if ((volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE))) {
/* Get modifier for gain */
modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE);
return 0;
}
-static void dump_volumes (pa_stream_manager *m) {
+static void dump_volumes(pa_stream_manager *m) {
volume_info *s = NULL;
const char *volume_type = NULL;
const char *modifier_gain = NULL;
return;
}
-int32_t init_volumes (pa_stream_manager *m) {
+int32_t init_volumes(pa_stream_manager *m) {
int ret = 0;
void *state = NULL;
volume_info *v = NULL;
return ret;
}
-void deinit_volumes (pa_stream_manager *m) {
+void deinit_volumes(pa_stream_manager *m) {
volume_info *v = NULL;
void *state = NULL;
uint32_t idx = 0;
};
const char *dbus_str_none = "none";
-const char* stream_manager_dbus_ret_str[] = {"STREAM_MANAGER_RETURN_OK","STREAM_MANAGER_RETURN_ERROR", "STREAM_MANAGER_RETURN_ERROR_NO_STREAM"};
+const char* stream_manager_dbus_ret_str[] = {"STREAM_MANAGER_RETURN_OK", "STREAM_MANAGER_RETURN_ERROR", "STREAM_MANAGER_RETURN_ERROR_NO_STREAM"};
enum {
RET_MSG_INDEX_OK,
RET_MSG_INDEX_ERROR,
}
}
list->num_of_streams = i;
- pa_log_debug(" num_of_streams[%d]",i);
+ pa_log_debug(" num_of_streams[%d]", i);
} else {
pa_log_error("stream_map is not initialized..");
return -1;
memset(&list, 0, sizeof(stream_list));
pa_assert_se((reply = dbus_message_new_method_return(msg)));
dbus_message_iter_init_append(reply, &msg_iter);
- if(!get_available_streams(m, &list)) {
+ if (!get_available_streams(m, &list)) {
pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, &list.types, list.num_of_streams);
pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_INT32, &list.priorities, list.num_of_streams);
} else {
memset(&info, 0, sizeof(stream_info_per_type));
pa_assert_se((reply = dbus_message_new_method_return(msg)));
dbus_message_iter_init_append(reply, &msg_iter);
- if(!get_stream_info(m, type, &info)) {
+ if (!get_stream_info(m, type, &info)) {
pa_dbus_append_basic_variant(&msg_iter, DBUS_TYPE_INT32, &info.priority);
pa_dbus_append_basic_variant(&msg_iter, DBUS_TYPE_INT32, &info.route_type);
pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, &info.volume_types, STREAM_DIRECTION_MAX);
goto FAILURE;
}
- s = (stream_type == STREAM_SINK_INPUT)?(void*)(m->cur_highest_priority.sink_input):(void*)(m->cur_highest_priority.source_output);
+ s = (stream_type == STREAM_SINK_INPUT) ? (void*)(m->cur_highest_priority.sink_input) : (void*)(m->cur_highest_priority.source_output);
if (s) {
type = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE);
pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &type, DBUS_TYPE_INVALID));
count = pa_idxset_size(sp->idx_sink_inputs);
PA_IDXSET_FOREACH(stream, sp->idx_sink_inputs, idx) {
pa_proplist_sets(GET_STREAM_PROPLIST(stream, STREAM_SINK_INPUT), PA_PROP_MEDIA_FOCUS_STATUS,
- IS_FOCUS_ACQUIRED(sp->focus_status, STREAM_SINK_INPUT)?STREAM_FOCUS_PLAYBACK:STREAM_FOCUS_NONE);
+ IS_FOCUS_ACQUIRED(sp->focus_status, STREAM_SINK_INPUT) ? STREAM_FOCUS_PLAYBACK : STREAM_FOCUS_NONE);
if (--count == 0)
process_stream(m, stream, STREAM_SINK_INPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_FOCUS_CHANGED, FALSE);
}
count = pa_idxset_size(sp->idx_source_outputs);
PA_IDXSET_FOREACH(stream, sp->idx_source_outputs, idx) {
pa_proplist_sets(GET_STREAM_PROPLIST(stream, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_FOCUS_STATUS,
- IS_FOCUS_ACQUIRED(sp->focus_status, STREAM_SOURCE_OUTPUT)?STREAM_FOCUS_CAPTURE:STREAM_FOCUS_NONE);
+ IS_FOCUS_ACQUIRED(sp->focus_status, STREAM_SOURCE_OUTPUT) ? STREAM_FOCUS_CAPTURE : STREAM_FOCUS_NONE);
if (--count == 0)
process_stream(m, stream, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_FOCUS_CHANGED, FALSE);
}
pa_assert(m);
for (idx = 0; idx < METHOD_HANDLER_MAX; idx++) {
- if (dbus_message_is_method_call(msg, STREAM_MANAGER_INTERFACE, method_handlers[idx].method_name )) {
+ if (dbus_message_is_method_call(msg, STREAM_MANAGER_INTERFACE, method_handlers[idx].method_name)) {
pa_log_debug("Message signature [%s] (Expected [%s])", dbus_message_get_signature(msg), signature_args_for_in[idx]);
if (pa_streq(dbus_message_get_signature(msg), signature_args_for_in[idx])) {
method_handlers[idx].receive_cb(conn, msg, userdata);
return ret;
}
-static void dump_stream_map (pa_stream_manager *m) {
+static void dump_stream_map(pa_stream_manager *m) {
stream_info *s = NULL;
const char *role = NULL;
char *name = NULL;
return;
}
-static int init_stream_map (pa_stream_manager *m) {
+static int init_stream_map(pa_stream_manager *m) {
volume_info *v;
stream_info *s;
json_object *o;
pa_assert(m);
o = json_object_from_file(STREAM_MAP_FILE);
- if(is_error(o)) {
+ if (is_error(o)) {
pa_log_error("Read stream-map file(%s) failed", STREAM_MAP_FILE);
return -1;
}
/* 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 ((volume_array_o = json_object_object_get(o, STREAM_MAP_VOLUMES)) && 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)) {
+ 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 ((volume_type_o = json_object_object_get(volume_o, STREAM_MAP_VOLUME_TYPE)) && 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 ((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)) {
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 {
pa_log_error("Get is-hal-volume failed");
goto failed;
}
- pa_hashmap_put(m->volume_infos,(void*)volume_type, v);
+ pa_hashmap_put(m->volume_infos, (void*)volume_type, v);
}
}
}
/* 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 ((stream_array_o = json_object_object_get(o, STREAM_MAP_STREAMS)) && 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)) {
+ 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 ((role_o = json_object_object_get(stream_o, STREAM_MAP_STREAM_ROLE)) && 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 ((priority_o = json_object_object_get(stream_o, STREAM_MAP_STREAM_PRIORITY)) && 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 ((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 (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 ((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))
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 ((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))
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 ((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)) {
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_debug(" - avail-in-devices");
for (j = 0; j < num_of_avail_in_devices; j++) {
- if((in_device_o = json_object_array_get_idx(avail_in_devices_o, j)) && json_object_is_type(in_device_o, json_type_string)) {
+ if ((in_device_o = json_object_array_get_idx(avail_in_devices_o, j)) && json_object_is_type(in_device_o, json_type_string)) {
pa_idxset_put(s->idx_avail_in_devices, (void*)json_object_get_string(in_device_o), NULL);
pa_log_debug(" device[%d] : %s", j, json_object_get_string(in_device_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 ((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)) {
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_debug(" - avail-out-devices");
for (j = 0; j < num_of_avail_out_devices; j++) {
- if((out_device_o = json_object_array_get_idx(avail_out_devices_o, j)) && json_object_is_type(out_device_o, json_type_string)) {
+ if ((out_device_o = json_object_array_get_idx(avail_out_devices_o, j)) && json_object_is_type(out_device_o, json_type_string)) {
pa_idxset_put(s->idx_avail_out_devices, (void*)json_object_get_string(out_device_o), NULL);
pa_log_debug(" device[%d] : %s", j, json_object_get_string(out_device_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 ((avail_frameworks_o = json_object_object_get(stream_o, STREAM_MAP_STREAM_AVAIL_FRAMEWORKS)) && 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);
pa_log_debug(" - avail-frameworks");
for (j = 0; j < num_of_avail_frameworks; j++) {
- if((framework_o = json_object_array_get_idx(avail_frameworks_o, j)) && json_object_is_type(framework_o, json_type_string)) {
+ if ((framework_o = json_object_array_get_idx(avail_frameworks_o, j)) && json_object_is_type(framework_o, json_type_string)) {
pa_idxset_put(s->idx_avail_frameworks, (void*)json_object_get_string(framework_o), NULL);
pa_log_debug(" framework[%d] : %s", j, json_object_get_string(framework_o));
}
pa_log_error("Get stream avail-frameworks failed");
goto failed;
}
- pa_hashmap_put(m->stream_infos,(void*)role, s);
+ pa_hashmap_put(m->stream_infos, (void*)role, s);
}
}
} else {
return -1;
}
-static void deinit_stream_map (pa_stream_manager *m) {
+static void deinit_stream_map(pa_stream_manager *m) {
stream_info *s = NULL;
volume_info *v = NULL;
void *state = NULL;
case NOTIFY_COMMAND_UPDATE_ROUTE_OPTION: {
pa_assert(user_data);
memset(&hook_call_option_data, 0, sizeof(pa_stream_manager_hook_data_for_option));
- s = (type == STREAM_SINK_INPUT) ? (void*)(m->cur_highest_priority.sink_input):
+ s = (type == STREAM_SINK_INPUT) ? (void*)(m->cur_highest_priority.sink_input) :
(void*)(m->cur_highest_priority.source_output);
if (s) {
role = pa_proplist_gets(GET_STREAM_PROPLIST(s, type), PA_PROP_MEDIA_ROLE);
stream_conn_info.role = pa_proplist_gets(GET_STREAM_PROPLIST(s, type), PA_PROP_MEDIA_ROLE);
stream_conn_info.direction = (type == STREAM_SINK_INPUT) ? DIRECTION_OUT : DIRECTION_IN;
stream_conn_info.idx = (type == STREAM_SINK_INPUT) ? ((pa_sink_input*)s)->index : ((pa_source_output*)s)->index;
- stream_conn_info.is_connected = (command == NOTIFY_COMMAND_INFORM_STREAM_CONNECTED)?TRUE:FALSE;
+ stream_conn_info.is_connected = (command == NOTIFY_COMMAND_INFORM_STREAM_CONNECTED) ? TRUE : FALSE;
pa_hal_manager_update_stream_connection_info(m->hal, &stream_conn_info);
}
break;
/* set sample_spec */
rate_str = pa_proplist_gets(req_format->plist, PA_PROP_FORMAT_RATE);
ch_str = pa_proplist_gets(req_format->plist, PA_PROP_FORMAT_CHANNELS);
- if (pa_format_info_get_prop_string(req_format, PA_PROP_FORMAT_SAMPLE_FORMAT, &format_str)==0)
+ if (pa_format_info_get_prop_string(req_format, PA_PROP_FORMAT_SAMPLE_FORMAT, &format_str) == 0)
((pa_sink_input_new_data*)stream)->sample_spec.format = pa_parse_sample_format((const char*)format_str);
pa_log_info("req rate(%s), req ch(%s), req format(%s)", rate_str, ch_str, format_str);
if (ch_str)
- ((pa_sink_input_new_data*)stream)->sample_spec.channels = atoi (ch_str);
+ ((pa_sink_input_new_data*)stream)->sample_spec.channels = atoi(ch_str);
if (rate_str)
- ((pa_sink_input_new_data*)stream)->sample_spec.rate = atoi (rate_str);
+ ((pa_sink_input_new_data*)stream)->sample_spec.rate = atoi(rate_str);
/* set channel map if it is not set by client */
if (!((pa_sink_input_new_data*)stream)->channel_map_is_set) {
pa_channel_map_init_auto(&(((pa_sink_input_new_data*)stream)->channel_map),
((pa_sink_input_new_data*)stream)->sample_spec.channels, PA_CHANNEL_MAP_ALSA);
- pa_log_info("set default channel_map: channels(%u)",((pa_sink_input_new_data*)stream)->channel_map.channels);
+ pa_log_info("set default channel_map: channels(%u)", ((pa_sink_input_new_data*)stream)->channel_map.channels);
((pa_sink_input_new_data*)stream)->channel_map_is_set = TRUE;
}
}
state = pa_sink_input_get_state(i);
pa_log_info("start sink_input_state_changed_cb(), sink-input(%p), state(%d)", i, state);
- switch(state) {
+ switch (state) {
case PA_SINK_INPUT_CORKED: {
process_stream(m, i, STREAM_SINK_INPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_ENDED, FALSE);
break;
if (core->state == PA_CORE_SHUTDOWN)
return PA_HOOK_OK;
- pa_log_debug ("sink_input_move_start_cb, i(%p, index:%u)", i, i->index);
+ pa_log_debug("sink_input_move_start_cb, i(%p, index:%u)", i, i->index);
set_volume_mute_by_idx(m, i->index, STREAM_SINK_INPUT, TRUE);
if (core->state == PA_CORE_SHUTDOWN)
return PA_HOOK_OK;
- pa_log_debug ("sink_input_move_finish_cb, i(%p, index:%u)", i, i->index);
+ pa_log_debug("sink_input_move_finish_cb, i(%p, index:%u)", i, i->index);
set_volume_mute_by_idx(m, i->index, STREAM_SINK_INPUT, FALSE);
state = pa_source_output_get_state(o);
pa_log_debug("start source_output_state_changed_cb(), source-output(%p), state(%d)", o, state);
- switch(state) {
+ switch (state) {
case PA_SOURCE_OUTPUT_CORKED: {
process_stream(m, o, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_ENDED, FALSE);
break;
if (core->state == PA_CORE_SHUTDOWN)
return PA_HOOK_OK;
- pa_log_debug ("source_output_move_start_cb, o(%p, index:%u)", o, o->index);
+ pa_log_debug("source_output_move_start_cb, o(%p, index:%u)", o, o->index);
set_volume_mute_by_idx(m, o->index, STREAM_SINK_INPUT, TRUE);
if (core->state == PA_CORE_SHUTDOWN)
return PA_HOOK_OK;
- pa_log_debug ("source_output_move_finish_cb, o(%p, index:%u)", o, o->index);
+ pa_log_debug("source_output_move_finish_cb, o(%p, index:%u)", o, o->index);
set_volume_mute_by_idx(m, o->index, STREAM_SINK_INPUT, FALSE);
pa_source *null_source = NULL;
pa_bool_t available = FALSE;
pa_bool_t use_internal_codec = FALSE;
- cached_device_list cached_prev_dev_list[MAX_CACHED_LEN] = {{NULL,0},};
+ cached_device_list cached_prev_dev_list[MAX_CACHED_LEN] = {{NULL, 0}, };
uint32_t cnt = 0;
pa_sink *combine_sink = NULL;
else
source = pa_device_manager_get_source(device, DEVICE_ROLE_NORMAL);
- PA_IDXSET_FOREACH (s, streams, s_idx) { /* streams: core->source_outputs/core->sink_inputs */
+ PA_IDXSET_FOREACH(s, streams, s_idx) { /* streams: core->source_outputs/core->sink_inputs */
if (!pa_stream_manager_get_route_type(s, FALSE, stream_type, &route_type) && (route_type == stream_route_type)) {
role = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_ROLE);
pa_log_debug(" -- idx(%u), route_type(%d), role(%s)", s_idx, route_type, role);
/* set device state to deactivated */
if (cnt) {
- PA_IDXSET_FOREACH (s, streams, s_idx) { /* streams: core->source_outputs/core->sink_inputs */
+ PA_IDXSET_FOREACH(s, streams, s_idx) { /* streams: core->source_outputs/core->sink_inputs */
if ((cur_device_type = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV))) {
for (cnt = 0; cached_prev_dev_list[cnt].device_type; cnt++) {
pa_log_warn(" -- cur_device(%s), cached_device(%s)", cur_device_type, cached_prev_dev_list[cnt].device_type);
} else if (stream_route_type == STREAM_ROUTE_TYPE_MANUAL_EXT) {
pa_log_info("[SM][UPDATE_SINK_SOURCE][EXT] deivce_type(%s), is_connected(%d))", device_type, is_connected);
if (!is_connected) {
- PA_IDXSET_FOREACH (s, streams, s_idx) { /* streams: source->outputs/sink->inputs */
+ PA_IDXSET_FOREACH(s, streams, s_idx) { /* streams: source->outputs/sink->inputs */
if (!pa_stream_manager_get_route_type(s, FALSE, stream_type, &route_type) && route_type == stream_route_type) {
if (stream_type == STREAM_SOURCE_OUTPUT) {
/* move it to null source if this role is for external device */
if (!use_internal_codec && (device_direction & DM_DEVICE_DIRECTION_OUT)) {
if ((sink = pa_device_manager_get_sink(data->device, DEVICE_ROLE_NORMAL)))
update_sink_or_source_as_device_change(STREAM_ROUTE_TYPE_MANUAL_EXT, sink->inputs,
- STREAM_SINK_INPUT,data->device, data->is_connected, m);
+ STREAM_SINK_INPUT, data->device, data->is_connected, m);
else
pa_log_error("[SM][CONN] could not get sink");
}
if (!pa_stream_manager_get_route_type(m->cur_highest_priority.source_output, FALSE, STREAM_SOURCE_OUTPUT, &route_type)) {
if (route_type < STREAM_ROUTE_TYPE_MANUAL) {
if (use_internal_codec) {
- PA_IDXSET_FOREACH (s, m->cur_highest_priority.source_output->source->outputs, s_idx) {
+ PA_IDXSET_FOREACH(s, m->cur_highest_priority.source_output->source->outputs, s_idx) {
if (!data->is_connected && !pa_stream_manager_get_route_type(s, FALSE, STREAM_SOURCE_OUTPUT, &route_type) &&
((route_type == STREAM_ROUTE_TYPE_AUTO) || (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED))) {
/* remove activated device info. if it has the AUTO route type */
if (!pa_stream_manager_get_route_type(m->cur_highest_priority.sink_input, FALSE, STREAM_SINK_INPUT, &route_type)) {
if (route_type < STREAM_ROUTE_TYPE_MANUAL) {
if (use_internal_codec) {
- PA_IDXSET_FOREACH (s, m->cur_highest_priority.sink_input->sink->inputs, s_idx) {
+ PA_IDXSET_FOREACH(s, m->cur_highest_priority.sink_input->sink->inputs, s_idx) {
if (!data->is_connected && !pa_stream_manager_get_route_type(s, FALSE, STREAM_SINK_INPUT, &route_type) &&
((route_type == STREAM_ROUTE_TYPE_AUTO) || (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED))) {
/* remove activated device info. if it has the AUTO route type */
return;
}
name = pa_proplist_gets(client->proplist, PA_PROP_APPLICATION_NAME);
- if (name && strncmp (name, STREAM_MANAGER_CLIENT_NAME, strlen(STREAM_MANAGER_CLIENT_NAME))) {
+ if (name && strncmp(name, STREAM_MANAGER_CLIENT_NAME, strlen(STREAM_MANAGER_CLIENT_NAME))) {
pa_log_warn(" - this is not a client(%s) that we should take care of, skip it", name);
return;
}
}
}
-static int init_ipc (pa_stream_manager *m) {
+static int init_ipc(pa_stream_manager *m) {
#ifdef HAVE_DBUS
#ifdef USE_DBUS_PROTOCOL
pa_assert(m);
return -1;
}
-static void deinit_ipc (pa_stream_manager *m) {
+static void deinit_ipc(pa_stream_manager *m) {
pa_assert(m);
#ifdef HAVE_DBUS
}
#else
if (m->dbus_conn) {
- if(!dbus_connection_unregister_object_path(pa_dbus_connection_get(m->dbus_conn), STREAM_MANAGER_OBJECT_PATH))
+ if (!dbus_connection_unregister_object_path(pa_dbus_connection_get(m->dbus_conn), STREAM_MANAGER_OBJECT_PATH))
pa_log_error("failed to unregister object path");
m->dbus_conn = NULL;
}
m->subscription = pa_subscription_new(m->core, PA_SUBSCRIPTION_MASK_CLIENT | PA_SUBSCRIPTION_MASK_SAMPLE_CACHE, (pa_subscription_cb_t)subscribe_cb, m);
m->comm.comm = pa_communicator_get(c);
- m->comm.comm_hook_device_connection_changed_slot = pa_hook_connect(pa_communicator_hook(m->comm.comm,PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED),
- PA_HOOK_EARLY + 10, (pa_hook_cb_t) device_connection_changed_hook_cb, m);
+ m->comm.comm_hook_device_connection_changed_slot = pa_hook_connect(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED),
+ PA_HOOK_EARLY + 10, (pa_hook_cb_t)device_connection_changed_hook_cb, m);
return m;
(route_type_str && !pa_atoi(route_type_str, (int32_t*)&route_type) && (route_type == STREAM_ROUTE_TYPE_AUTO))
#define GET_STREAM_NEW_PROPLIST(stream, type) \
- (type == STREAM_SINK_INPUT? ((pa_sink_input_new_data*)stream)->proplist : ((pa_source_output_new_data*)stream)->proplist)
+ (type == STREAM_SINK_INPUT ? ((pa_sink_input_new_data*)stream)->proplist : ((pa_source_output_new_data*)stream)->proplist)
#define GET_STREAM_PROPLIST(stream, type) \
- (type == STREAM_SINK_INPUT? ((pa_sink_input*)stream)->proplist : ((pa_source_output*)stream)->proplist)
+ (type == STREAM_SINK_INPUT ? ((pa_sink_input*)stream)->proplist : ((pa_source_output*)stream)->proplist)
#define SINK_NAME_COMBINED "sink_combined"
#define SINK_NAME_NULL "sink_null"