/* if the device type is forwarding, keep going to next device for proper UCM setting */
if (pa_streq(dm_device_type, DEVICE_TYPE_FORWARDING))
continue;
+ if (pa_streq(dm_device_type, DEVICE_TYPE_BT))
+ continue;
hal_direction = CONVERT_TO_HAL_DIRECTION(data->stream_type);
route_info.num_of_devices++;
route_info.device_infos = pa_xrealloc(route_info.device_infos, sizeof(hal_device_info)*route_info.num_of_devices);
return PA_HOOK_OK;
}
-/* Update connected device list when a device's information has been changed */
+/* Update connected device list when a device profile has been changed */
static pa_hook_result_t device_profile_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_profile_changed *conn, struct userdata *u) {
dm_device_direction_t device_direction = DM_DEVICE_DIRECTION_OUT;
int* ptr_in = NULL;
}
} else if (!is_connected) {
/* DISCONNECTED: find a connected device that has the next priority */
- if (sink && (sink == ((pa_sink_input*)s)->sink)) {
+ if (sink) {
find_next_device_for_auto_route(m, route_type, role, stream_type, device_type, &next_device);
if (next_device) {
if ((next_sink = pa_tz_device_get_sink(next_device, DEVICE_ROLE_NORMAL))) {
s, ((pa_sink_input*)s)->index, null_sink, null_sink->name);
}
- } else if (source && (source == ((pa_source_output*)s)->source)) {
+ } else if (source) {
find_next_device_for_auto_route(m, route_type, role, stream_type, device_type, &next_device);
if (next_device) {
if ((next_source = pa_tz_device_get_source(next_device, DEVICE_ROLE_NORMAL))) {
return PA_HOOK_OK;
}
+/* Update connected device list when a device profile has been changed */
+static pa_hook_result_t device_profile_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_profile_changed *conn, pa_stream_manager *m) {
+ dm_device_direction_t device_direction = DM_DEVICE_DIRECTION_OUT;
+ bool use_internal_codec = false;
+ bool bt_sink_available = false;
+
+ pa_assert(c);
+ pa_assert(conn);
+ pa_assert(m);
+
+ device_direction = pa_tz_device_get_direction(conn->device);
+ use_internal_codec = pa_tz_device_is_use_internal_codec(conn->device);
+
+ pa_log_info("[SM][CONN] device_profile_changed_hook_cb is called. conn(%p), changed(%d), device(%p), direction(0x%x), use_internal_codec(%d)",
+ conn, conn->changed, conn->device, device_direction, use_internal_codec);
+
+ if (conn->changed == PA_TZ_DEVICE_ACTIVE_PROFILE_CHANGED) {
+ if (pa_streq(pa_tz_device_get_type(conn->device), DEVICE_TYPE_BT)) {
+ pa_log_info("[SM][CONN] BT: active profile changed to [%s]", pa_tz_device_get_profile(conn->device));
+ if (use_internal_codec)
+ bt_sink_available = false; /* already bt device is connected and A2DP is newly deactivated, now SCO is only activated */
+ else
+ bt_sink_available = true; /* already bt device is connected and A2DP is newly activated */
+ }
+ if (device_direction & DM_DEVICE_DIRECTION_OUT) {
+ update_sink_or_source_as_device_change(STREAM_ROUTE_TYPE_AUTO, m->core->sink_inputs,
+ STREAM_SINK_INPUT, conn->device, bt_sink_available, m);
+ update_sink_or_source_as_device_change(STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED, m->core->sink_inputs,
+ STREAM_SINK_INPUT, conn->device, bt_sink_available, m);
+ }
+ }
+
+ return PA_HOOK_OK;
+}
+
static void subscribe_cb(pa_core *core, pa_subscription_event_type_t t, uint32_t idx, pa_stream_manager *m) {
pa_client *client = NULL;
stream_parent *sp = NULL;
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_profile_changed_slot = pa_hook_connect(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_DEVICE_PROFILE_CHANGED),
+ PA_HOOK_EARLY + 10, (pa_hook_cb_t)device_profile_changed_hook_cb, m);
m->comm.comm_hook_event_fully_handled_slot = pa_hook_connect(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_EVENT_FULLY_HANDLED),
PA_HOOK_EARLY + 10, (pa_hook_cb_t)event_fully_handled_hook_cb, m);