* some targets use several pcm card as per their purpose.
* e.g) using a specific pcm card during voice call. */
if (data->occupying_role) {
- if (pa_streq(data->occupying_role, STREAM_ROLE_CALL_VOICE)) {
- data->device_role = DEVICE_ROLE_CALL_VOICE;
+ if (IS_ROLE_COMMUNICATION(data->occupying_role)) {
+ CONVERT_TO_DEVICE_ROLE(data->occupying_role, data->device_role);
pa_log_info("[SELECT] current occupying stream role is [%s], set deivce role to [%s]", data->occupying_role, data->device_role);
}
}
if ((device = pa_device_manager_get_device_by_id(u->device_manager, *device_id))) {
/* FIXME : This is temparary code, until App could give
* proper BT-SCO device for call-voice */
- if (pa_streq(route_info.role, STREAM_ROLE_CALL_VOICE) && pa_streq(device->type, DEVICE_TYPE_BT_SCO)) {
+ if (IS_ROLE_COMMUNICATION(route_info.role) && pa_streq(device->type, DEVICE_TYPE_BT_SCO)) {
pa_tz_device *sco_device;
if ((sco_device = _get_sco_connected_device(u->device_manager)) == NULL) {
pa_log_error(" ** could not find BT SCO");
pa_log_debug(" ** found a matched device: type[%-16s], direction[0x%x]",
dm_device_type, dm_device_direction);
/* Check for BT SCO in case of call routing */
- if (pa_streq(route_info.role, STREAM_ROLE_CALL_VOICE) && pa_streq(dm_device_type, DEVICE_TYPE_BT_SCO)) {
+ if (IS_ROLE_COMMUNICATION(route_info.role) && pa_streq(dm_device_type, DEVICE_TYPE_BT_SCO)) {
/* update BT SCO: open */
if (update_bt_sco_state(u->device_manager, true)) {
pa_log_error(" ** could not open BT SCO");
/* move stream(s) to a proper sink/source if needed */
if (device && data->stream && data->origins_from_new_data) {
- if (pa_streq(data->stream_role, STREAM_ROLE_CALL_VOICE)) {
+ if (IS_ROLE_COMMUNICATION(data->stream_role)) {
+ const char *device_role;
+
+ CONVERT_TO_DEVICE_ROLE(data->stream_role, device_role);
if (data->stream_type == STREAM_SINK_INPUT) {
if (!(sink = pa_tz_device_get_sink(device, DEVICE_ROLE_NORMAL)) ||
- !(dst_sink = pa_tz_device_get_sink(device, DEVICE_ROLE_CALL_VOICE)) ||
+ !(dst_sink = pa_tz_device_get_sink(device, device_role)) ||
sink == dst_sink)
- pa_log_info("[ROUTE][CALL-VOICE] no need to move streams, sink(%p), dst_sink(%p)", sink, dst_sink);
+ pa_log_info("[ROUTE][%s] no need to move streams, sink(%p), dst_sink(%p)", data->stream_role, sink, dst_sink);
else
streams = sink->inputs;
} else if (data->stream_type == STREAM_SOURCE_OUTPUT) {
if (!(source = pa_tz_device_get_source(device, DEVICE_ROLE_NORMAL)) ||
- !(dst_source = pa_tz_device_get_source(device, DEVICE_ROLE_CALL_VOICE)) ||
+ !(dst_source = pa_tz_device_get_source(device, device_role)) ||
source == dst_source)
- pa_log_info("[ROUTE][CALL-VOICE] no need to move streams, source(%p), dst_source(%p)", source, dst_source);
+ pa_log_info("[ROUTE][%s] no need to move streams, source(%p), dst_source(%p)", data->stream_role, source, dst_source);
else
streams = source->outputs;
}
PA_IDXSET_FOREACH(s, streams, idx) {
if (data->stream_type == STREAM_SINK_INPUT) {
pa_sink_input_move_to(s, dst_sink, false);
- pa_log_info("[ROUTE][CALL-VOICE] *** sink-input(%p,%u) moves to sink(%p,%s)",
- s, ((pa_sink_input*)s)->index, dst_sink, dst_sink->name);
+ pa_log_info("[ROUTE][%s] *** sink-input(%p,%u) moves to sink(%p,%s)",
+ data->stream_role, s, ((pa_sink_input*)s)->index, dst_sink, dst_sink->name);
} else if (data->stream_type == STREAM_SOURCE_OUTPUT) {
pa_source_output_move_to(s, dst_source, false);
- pa_log_info("[ROUTE][CALL-VOICE] *** source-output(%p,%u) moves to source(%p,%s)",
- s, ((pa_source_output*)s)->index, dst_source, dst_source->name);
+ pa_log_info("[ROUTE][%s] *** source-output(%p,%u) moves to source(%p,%s)",
+ data->stream_role, s, ((pa_source_output*)s)->index, dst_source, dst_source->name);
}
}
/* make sure the previous device is closed */
#define CONVERT_TO_DEVICE_DIRECTION(stream_type) \
((stream_type == STREAM_SINK_INPUT) ? DM_DEVICE_DIRECTION_OUT : DM_DEVICE_DIRECTION_IN)
-#define CONVERT_TO_DEVICE_ROLE(x_stream_role, x_device_role) { \
- pa_assert(x_stream_role); \
- if (pa_streq(x_stream_role, STREAM_ROLE_CALL_VOICE)) \
- x_device_role = DEVICE_ROLE_CALL_VOICE; \
- else if (pa_streq(x_stream_role, STREAM_ROLE_CALL_VIDEO)) \
- x_device_role = DEVICE_ROLE_CALL_VIDEO; \
- else if (pa_streq(x_stream_role, STREAM_ROLE_VOIP)) \
- x_device_role = DEVICE_ROLE_VOIP; \
- else \
- x_device_role = DEVICE_ROLE_NORMAL; \
-} \
-
static void do_notify(pa_stream_manager *m, notify_command_type_t command, stream_type_t type, bool is_new_data, void *user_data);
static process_stream_result_t process_stream(pa_stream_manager *m, void *stream, stream_type_t type, process_command_type_t command, bool is_new_data);
prop = PA_SOURCE_OUTPUT(stream)->proplist;
stream_role = pa_proplist_gets(prop, PA_PROP_MEDIA_ROLE);
-
- if (pa_safe_streq(stream_role, STREAM_ROLE_CALL_VOICE))
- return true;
- else if (pa_safe_streq(stream_role, STREAM_ROLE_CALL_VIDEO))
- return true;
- else if (pa_safe_streq(stream_role, STREAM_ROLE_VOIP))
+ if (stream_role && IS_ROLE_COMMUNICATION(stream_role))
return true;
return false;
#define IS_ROUTE_TYPE_FOR_AUTO_LAST_CONN(route_type_str, route_type) \
(route_type_str && !pa_atoi(route_type_str, (int32_t*)&route_type) && (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED))
+#define IS_ROLE_COMMUNICATION(stream_role) \
+ (pa_streq(stream_role, STREAM_ROLE_CALL_VOICE) || pa_streq(stream_role, STREAM_ROLE_CALL_VIDEO) || pa_streq(stream_role, STREAM_ROLE_VOIP))
+
+#define CONVERT_TO_DEVICE_ROLE(x_stream_role, x_device_role) \
+do { \
+ pa_assert(x_stream_role); \
+ if (pa_streq(x_stream_role, STREAM_ROLE_CALL_VOICE)) \
+ x_device_role = DEVICE_ROLE_CALL_VOICE; \
+ else if (pa_streq(x_stream_role, STREAM_ROLE_CALL_VIDEO)) \
+ x_device_role = DEVICE_ROLE_CALL_VIDEO; \
+ else if (pa_streq(x_stream_role, STREAM_ROLE_VOIP)) \
+ x_device_role = DEVICE_ROLE_VOIP; \
+ else \
+ x_device_role = DEVICE_ROLE_NORMAL; \
+} while (0)
+
#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)