Support 3P/4P audiojack device in voip session mode 80/114180/1 accepted/tizen/3.0/common/20170213.160832 accepted/tizen/3.0/ivi/20170213.035334 accepted/tizen/3.0/mobile/20170213.035215 accepted/tizen/3.0/tv/20170213.035256 accepted/tizen/3.0/wearable/20170213.035321 submit/tizen_3.0/20170210.094941
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 10 Feb 2017 08:18:56 +0000 (17:18 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 10 Feb 2017 08:18:56 +0000 (17:18 +0900)
[Version] 0.3.100
[Profile] common
[Issue Type] Backward compatibilty

Change-Id: Ic6d7de203548a5a9a8b6d843bb26605fd171f56b
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-sound-manager.spec
src/sound_manager_private.c

index 2e75e17..04fce9c 100755 (executable)
@@ -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
index 9840fcf..5db7ff1 100644 (file)
@@ -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;