sound_device_type_e device_type = SOUND_DEVICE_BUILTIN_RECEIVER;
sound_manager_get_device_type(device, &device_type);
+ info("Device connected cb invoked!! [%s] is [%s]",
+ __callmgr_audio_convert_device_type_to_string(device_type),
+ is_connected ? "Connected" : "Disconnected");
+
+ /* Set current device list */
if (device_type == SOUND_DEVICE_AUDIO_JACK) {
if (is_connected)
audio_handle->current_device_list |= CALLMGR_AUDIO_DEVICE_EARJACK_E;
- else
+ else if (audio_handle->current_device_list & CALLMGR_AUDIO_DEVICE_EARJACK_E)
audio_handle->current_device_list -= CALLMGR_AUDIO_DEVICE_EARJACK_E;
} else if (device_type == SOUND_DEVICE_BLUETOOTH) {
- if (is_connected)
- audio_handle->current_device_list |= CALLMGR_AUDIO_DEVICE_BT_E;
- else
- audio_handle->current_device_list -= CALLMGR_AUDIO_DEVICE_BT_E;
+ if (is_connected) {
+ int modes;
+ sound_manager_get_bt_device_avail_modes(device, &modes);
+ if (modes & SOUND_DEVICE_BLUETOOTH_MODE_VOICE) {
+ dbg("BT device is connected and BT Voice is enabled.");
+ audio_handle->current_device_list |= CALLMGR_AUDIO_DEVICE_BT_E;
+ } else {
+ dbg("BT device is connected. But, BT Voice is disabled.");
+ is_connected = FALSE;
+ }
+ } else {
+ if (audio_handle->current_device_list & CALLMGR_AUDIO_DEVICE_BT_E)
+ audio_handle->current_device_list -= CALLMGR_AUDIO_DEVICE_BT_E;
+ }
}
- info("[%s] is [%s], current device list [0x%x]",
- __callmgr_audio_convert_device_type_to_string(device_type),
- is_connected ? "Connected" : "Disconnected", audio_handle->current_device_list);
-
+ /* Invoke device changed cb */
if (device_type == SOUND_DEVICE_AUDIO_JACK)
audio_handle->cb_fn(CM_AUDIO_EVENT_EARJACK_CHANGED_E, (void *)is_connected, audio_handle->user_data);
else if (device_type == SOUND_DEVICE_BLUETOOTH)
audio_handle->cb_fn(CM_AUDIO_EVENT_BT_CHANGED_E, (void *)is_connected, audio_handle->user_data);
}
+static void __callmgr_audio_device_information_changed_cb(sound_device_h device, sound_device_changed_info_e changed_info, void *user_data)
+{
+ CM_RETURN_IF_FAIL(user_data);
+ CM_RETURN_IF_FAIL(device);
+ callmgr_audio_handle_h audio_handle = (callmgr_audio_handle_h)user_data;
+ sound_device_type_e device_type = SOUND_DEVICE_BUILTIN_RECEIVER;
+ int ret = SOUND_MANAGER_ERROR_NONE;
+
+ ret = sound_manager_get_device_type(device, &device_type);
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ err("sound_manager_get_device_type() get failed with err[0x%x][%s]", ret, get_error_message(ret));
+ return;
+ }
+
+ if (device_type == SOUND_DEVICE_BLUETOOTH) {
+ int modes;
+ bool is_connected;
+ sound_manager_get_bt_device_avail_modes(device, &modes);
+
+ /* Set current device list */
+ if (modes & SOUND_DEVICE_BLUETOOTH_MODE_VOICE) {
+ dbg("BT Voice is enabled");
+ audio_handle->current_device_list |= CALLMGR_AUDIO_DEVICE_BT_E;
+ is_connected = TRUE;
+ } else {
+ dbg("BT Voice is disabled");
+ if (audio_handle->current_device_list & CALLMGR_AUDIO_DEVICE_BT_E)
+ audio_handle->current_device_list -= CALLMGR_AUDIO_DEVICE_BT_E;
+ is_connected = FALSE;
+ }
+
+ /* Invoke device changed cb */
+ audio_handle->cb_fn(CM_AUDIO_EVENT_BT_CHANGED_E, (void *)is_connected, audio_handle->user_data);
+ }
+}
+
int _callmgr_audio_init(callmgr_audio_handle_h *audio_handle, audio_event_cb cb_fn, void *user_data)
{
struct __audio_data *handle = NULL;
/* Set current device list */
while (sound_manager_get_next_device(device_list, &device) == SOUND_MANAGER_ERROR_NONE) {
sound_manager_get_device_type(device, &device_type);
- if (device_type == SOUND_DEVICE_AUDIO_JACK)
+ if (device_type == SOUND_DEVICE_AUDIO_JACK) {
handle->current_device_list |= CALLMGR_AUDIO_DEVICE_EARJACK_E;
- else if (device_type == SOUND_DEVICE_BLUETOOTH)
- handle->current_device_list |= CALLMGR_AUDIO_DEVICE_BT_E;
+ } else if (device_type == SOUND_DEVICE_BLUETOOTH) {
+ int modes;
+ sound_manager_get_bt_device_avail_modes(device, &modes);
+ if (modes & SOUND_DEVICE_BLUETOOTH_MODE_VOICE) {
+ dbg("BT device is connected and BT Voice is enabled.");
+ handle->current_device_list |= CALLMGR_AUDIO_DEVICE_BT_E;
+ } else {
+ dbg("BT device is connected. But, BT Voice is disabled.");
+ }
+ }
}
dbg("Current device list [0x%x]", handle->current_device_list);
return -1;
}
+ /* Set device information changed cb */
+ ret = sound_manager_set_device_information_changed_cb(SOUND_DEVICE_ALL_MASK, __callmgr_audio_device_information_changed_cb, handle);
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ err("sound_manager_set_device_information_changed_cb() failed. [%d][%s]", ret, get_error_message(ret));
+ return -1;
+ }
+
dbg("Audio init done");
return 0;
}
/* TODO: Release all handles */
sound_manager_unset_device_connected_cb();
+ sound_manager_unset_device_information_changed_cb();
_callmgr_audio_destroy_call_sound_session(audio_handle);
g_free(audio_handle);
return 0;
}
-static void __callmgr_audio_active_device_changed_cb(sound_device_h device, sound_device_changed_info_e changed_info, void *user_data)
-{
- CM_RETURN_IF_FAIL(user_data);
- CM_RETURN_IF_FAIL(device);
- callmgr_audio_handle_h audio_handle = (callmgr_audio_handle_h)user_data;
- sound_device_io_direction_e io_direction = SOUND_DEVICE_IO_DIRECTION_BOTH;
- sound_device_type_e device_type = SOUND_DEVICE_BUILTIN_RECEIVER;
- sound_device_state_e state = SOUND_DEVICE_STATE_DEACTIVATED;
- callmgr_audio_device_e cm_device = CALLMGR_AUDIO_DEVICE_NONE_E;
- int ret = SOUND_MANAGER_ERROR_NONE;
-
- ret = sound_manager_get_device_io_direction(device, &io_direction);
- if (ret != SOUND_MANAGER_ERROR_NONE)
- err("sound_manager_get_device_io_direction() get failed with err[0x%x]", ret);
-
- ret = sound_manager_get_device_state(device, &state);
- if (ret != SOUND_MANAGER_ERROR_NONE)
- err("sound_manager_get_device_state() get failed with err[0x%x]", ret);
-
- ret = sound_manager_get_device_type(device, &device_type);
- if (ret != SOUND_MANAGER_ERROR_NONE)
- err("sound_manager_get_device_type() get failed with err[0x%x]", ret);
-
- info("Active device[%s], IO direction[%s], State[%s]",
- __callmgr_audio_convert_device_type_to_string(device_type),
- __callmgr_audio_convert_io_direction_to_string(io_direction),
- __callmgr_audio_convert_device_state_to_string(state));
-
- if ((io_direction == SOUND_DEVICE_IO_DIRECTION_IN) || (state == SOUND_DEVICE_STATE_DEACTIVATED)) {
- info("No need to inform callmgr-core of this change");
- return;
- }
-
- switch (device_type) {
- case SOUND_DEVICE_BUILTIN_SPEAKER:
- cm_device = CALLMGR_AUDIO_DEVICE_SPEAKER_E;
- break;
- case SOUND_DEVICE_BUILTIN_RECEIVER:
- cm_device = CALLMGR_AUDIO_DEVICE_RECEIVER_E;
- break;
- case SOUND_DEVICE_AUDIO_JACK:
- cm_device = CALLMGR_AUDIO_DEVICE_EARJACK_E;
- break;
- case SOUND_DEVICE_BLUETOOTH:
- cm_device = CALLMGR_AUDIO_DEVICE_BT_E;
- break;
- default:
- warn("Not available : %d", device_type);
- break;
- }
-
- if ((cm_device == audio_handle->current_device) || cm_device == CALLMGR_AUDIO_DEVICE_NONE_E) {
- warn("Do not update");
- } else {
- //audio_handle->current_device = cm_device;
- //audio_handle->cb_fn(CM_AUDIO_EVENT_PATH_CHANGED_E, (void*)cm_device, audio_handle->user_data);
- }
-}
-
static void __callmgr_audio_call_stream_focus_state_cb(sound_stream_info_h stream_info,
sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data)
{
return -1;
}
- /* Path is changed by other modules */
- ret = sound_manager_set_device_information_changed_cb(SOUND_DEVICE_ALL_MASK, __callmgr_audio_active_device_changed_cb, audio_handle);
- if (ret != SOUND_MANAGER_ERROR_NONE) {
- err("sound_manager_set_device_information_changed_cb() failed. [%d]", ret);
- return -1;
- }
-
return 0;
}
CM_RETURN_VAL_IF_FAIL(audio_handle->sound_stream_handle, -1);
sound_manager_unset_volume_changed_cb();
- sound_manager_unset_device_information_changed_cb();
ret = sound_manager_release_focus(audio_handle->sound_stream_handle, SOUND_STREAM_FOCUS_FOR_PLAYBACK|SOUND_STREAM_FOCUS_FOR_RECORDING, NULL);
if (ret != SOUND_MANAGER_ERROR_NONE) {