From: Sangchul Lee Date: Fri, 10 Feb 2017 08:18:56 +0000 (+0900) Subject: Support 3P/4P audiojack device in voip session mode X-Git-Tag: submit/tizen_3.0/20170210.094941^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=81883b677e51ccb518d4abfdf6cf4c48e857a8fe;p=platform%2Fcore%2Fapi%2Fsound-manager.git Support 3P/4P audiojack device in voip session mode [Version] 0.3.100 [Profile] common [Issue Type] Backward compatibilty Change-Id: Ic6d7de203548a5a9a8b6d843bb26605fd171f56b Signed-off-by: Sangchul Lee --- diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index 2e75e17..04fce9c 100755 --- a/packaging/capi-media-sound-manager.spec +++ b/packaging/capi-media-sound-manager.spec @@ -1,6 +1,6 @@ Name: capi-media-sound-manager Summary: Sound Manager library -Version: 0.3.99 +Version: 0.3.100 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index 9840fcf..5db7ff1 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -1322,6 +1322,7 @@ int _set_session_mode(_session_mode_e mode) MMSoundDevice_t tmp_device = NULL; MMSoundDevice_t proper_device = NULL; MMSoundDevice_t proper_device2 = NULL; + MMSoundDevice_t proper_device_builtin_mic = NULL; MMSoundDevice_t prev_device = NULL; MMSoundDevice_t prev_device2 = NULL; mm_sound_device_type_e type; @@ -1332,8 +1333,7 @@ int _set_session_mode(_session_mode_e mode) return ret; } - switch (mode) { - case _SESSION_MODE_RINGTONE: + if (mode == _SESSION_MODE_RINGTONE) { if (g_voip_vstream_h) { /* stop vstream and destroy vstream */ _stop_virtual_stream(g_voip_vstream_h); @@ -1374,11 +1374,12 @@ int _set_session_mode(_session_mode_e mode) if ((ret = _start_virtual_stream(g_voip_vstream_h))) goto ERROR_CASE; - break; - case _SESSION_MODE_VOICE_WITH_BUILTIN_RECEIVER: /* Built-in RCV and Built-in MIC */ - case _SESSION_MODE_VOICE_WITH_BUILTIN_SPEAKER: /* Built-in SPK and Built-in MIC */ - case _SESSION_MODE_VOICE_WITH_AUDIO_JACK: /* Earphone spk & mic */ - case _SESSION_MODE_VOICE_WITH_BLUETOOTH_SCO: /* Bluetooth spk & mic */ + } else { + /* _SESSION_MODE_VOICE_WITH_BUILTIN_RECEIVER: Built-in RCV and Built-in MIC + * _SESSION_MODE_VOICE_WITH_BUILTIN_SPEAKER : Built-in SPK and Built-in MIC + * _SESSION_MODE_VOICE_WITH_AUDIO_JACK : Earphone SPK & MIC(4P) or Earphone SPK & Built-in MIC(3P) + * _SESSION_MODE_VOICE_WITH_BLUETOOTH_SCO : Bluetooth SPK & MIC */ + /* check if the device is available now */ if ((ret = mm_sound_get_device_list(MM_SOUND_DEVICE_ALL_FLAG, &device_list))) { LOGE("failed to get current device list"); @@ -1391,28 +1392,36 @@ int _set_session_mode(_session_mode_e mode) if ((ret = mm_sound_get_device_id(tmp_device, &id))) goto ERROR_CASE; - if (g_cached_voip_device_id == id) + if (g_cached_voip_device_id == id || g_cached_voip_device_id2 == id) CHECK_AND_SET_DEVICE(prev_device, prev_device2, tmp_device); - else if (g_cached_voip_device_id2 == id) - CHECK_AND_SET_DEVICE(prev_device, prev_device2, tmp_device); - switch (mode) { case _SESSION_MODE_VOICE_WITH_BUILTIN_RECEIVER: - if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER) - CHECK_AND_SET_DEVICE(proper_device, proper_device2, tmp_device); - else if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_MIC) + if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER || type == MM_SOUND_DEVICE_TYPE_BUILTIN_MIC) CHECK_AND_SET_DEVICE(proper_device, proper_device2, tmp_device); break; case _SESSION_MODE_VOICE_WITH_BUILTIN_SPEAKER: - if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER) - CHECK_AND_SET_DEVICE(proper_device, proper_device2, tmp_device); - else if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_MIC) + if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER || type == MM_SOUND_DEVICE_TYPE_BUILTIN_MIC) CHECK_AND_SET_DEVICE(proper_device, proper_device2, tmp_device); break; case _SESSION_MODE_VOICE_WITH_AUDIO_JACK: - if (type == MM_SOUND_DEVICE_TYPE_AUDIOJACK) - CHECK_AND_SET_DEVICE(proper_device, proper_device2, tmp_device); + if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_MIC) + proper_device_builtin_mic = tmp_device; + + if (type == MM_SOUND_DEVICE_TYPE_AUDIOJACK) { + mm_sound_device_io_direction_e direction; + if ((ret = mm_sound_get_device_io_direction(tmp_device, &direction))) + goto ERROR_CASE; + if (direction == MM_SOUND_DEVICE_IO_DIRECTION_BOTH) { /* 4P earpiece */ + CHECK_AND_SET_DEVICE(proper_device, proper_device2, tmp_device); + } else if (direction == MM_SOUND_DEVICE_IO_DIRECTION_OUT) { /* 3P earpiece */ + proper_device = proper_device_builtin_mic; + proper_device2 = tmp_device; + } else { + LOGE("invalid direction[%d] for audiojack device", direction); + goto ERROR_CASE; + } + } break; case _SESSION_MODE_VOICE_WITH_BLUETOOTH_SCO: if (type == MM_SOUND_DEVICE_TYPE_BLUETOOTH_SCO) @@ -1499,7 +1508,6 @@ int _set_session_mode(_session_mode_e mode) if ((ret = _apply_stream_routing(g_voip_stream_info))) goto ERROR_CASE_NO_DESTROY; } - break; } g_cached_session_mode = mode; g_cached_voip_device_id = -1;