From: Jeongho Mok Date: Mon, 28 Nov 2016 14:23:20 +0000 (+0900) Subject: divide bluetooth to a2dp and sco X-Git-Tag: submit/tizen/20161207.075356~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c371bd78a9efbbd0599bd431be29acc7eb6a2be;p=platform%2Fcore%2Fapi%2Fsound-manager.git divide bluetooth to a2dp and sco [Version] 0.3.82 [Profile] Common [Issue Type] Add/Deprecate API Change-Id: Id056e09712540f5a4d8fc7ac0f7b1a7a88abce0f --- diff --git a/include/sound_manager.h b/include/sound_manager.h index ab91f22..fa5cbff 100644 --- a/include/sound_manager.h +++ b/include/sound_manager.h @@ -265,11 +265,13 @@ typedef enum { SOUND_DEVICE_BUILTIN_RECEIVER, /**< Built-in receiver */ SOUND_DEVICE_BUILTIN_MIC, /**< Built-in mic */ SOUND_DEVICE_AUDIO_JACK, /**< Audio jack that can be connected to wired accessory such as headphone, headset, and so on */ - SOUND_DEVICE_BLUETOOTH, /**< Bluetooth */ + SOUND_DEVICE_BLUETOOTH, /**< Bluetooth (Deprecated since 3.0) */ + SOUND_DEVICE_BLUETOOTH_MEDIA = SOUND_DEVICE_BLUETOOTH, /**< Bluetooth device representing media (A2DP) profile (Since 3.0) */ SOUND_DEVICE_HDMI, /**< HDMI */ SOUND_DEVICE_MIRRORING, /**< MIRRORING (Deprecated since 3.0) */ - SOUND_DEVICE_FORWARDING = SOUND_DEVICE_MIRRORING, /**< Device for forwarding (Since 3.0) */ + SOUND_DEVICE_FORWARDING = SOUND_DEVICE_MIRRORING, /**< Device for forwarding (Since 3.0) */ SOUND_DEVICE_USB_AUDIO, /**< USB Audio */ + SOUND_DEVICE_BLUETOOTH_VOICE, /**< Bluetooth device representing voice (SCO) profile (Since 3.0) */ } sound_device_type_e; /** diff --git a/include/sound_manager_private.h b/include/sound_manager_private.h index e55dded..ec2d9f6 100644 --- a/include/sound_manager_private.h +++ b/include/sound_manager_private.h @@ -185,7 +185,7 @@ typedef enum { _SESSION_MODE_VOICE_WITH_BUILTIN_RECEIVER, /**< session mode(voip/call) for during call with built-in receiver */ _SESSION_MODE_VOICE_WITH_BUILTIN_SPEAKER, /**< session mode(voip/call) for during call with built-in speaker */ _SESSION_MODE_VOICE_WITH_AUDIO_JACK, /**< session mode(voip/call) for during call with audio jack */ - _SESSION_MODE_VOICE_WITH_BLUETOOTH, /**< session mode(voip/call) for during call with bluetooth */ + _SESSION_MODE_VOICE_WITH_BLUETOOTH_SCO, /**< session mode(voip/call) for during call with bluetooth */ } _session_mode_e; typedef struct { @@ -241,11 +241,11 @@ void _set_focus_availability(sound_stream_info_s *stream_info); int _convert_stream_type_to_change_reason(const char *stream_type, sound_stream_focus_change_reason_e *change_reason); -int _convert_device_type(sound_device_type_e device_type_enum, char **device_type); +int _convert_device_type_to_str(sound_device_type_e device_type_enum, char **device_type); -int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *sound_io_direction); +int _convert_device_type(mm_sound_device_type_e device_type, sound_device_type_e *sound_device_type); -int _convert_avail_mode(int avail_mode); +int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *sound_io_direction); const char* _convert_api_name(native_api_e api_name); diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index aaa0776..ff1d72b 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.81 +Version: 0.3.82 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager.c b/src/sound_manager.c index ff00fcb..0347f40 100644 --- a/src/sound_manager.c +++ b/src/sound_manager.c @@ -1102,8 +1102,11 @@ int sound_manager_get_prev_device(sound_device_list_h device_list, sound_device_ int sound_manager_get_device_type(sound_device_h device, sound_device_type_e *type) { int ret = MM_ERROR_NONE; + mm_sound_device_type_e mm_sound_device_type; - ret = mm_sound_get_device_type(device, (mm_sound_device_type_e*)type); + ret = mm_sound_get_device_type(device, &mm_sound_device_type); + if (ret == MM_ERROR_NONE) + _convert_device_type(mm_sound_device_type, type); return _convert_sound_manager_error_code(__func__, ret); } @@ -1150,32 +1153,24 @@ int sound_manager_get_device_state(sound_device_h device, sound_device_state_e * int sound_manager_get_bt_device_avail_modes(sound_device_h device, int *modes) { int ret = MM_ERROR_NONE; - int mm_avail_mode; - int _avail_mode; sound_device_type_e device_type; + mm_sound_device_type_e mm_sound_device_type; if (!device || !modes) return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); - ret = mm_sound_get_device_type(device, (mm_sound_device_type_e*)&device_type); + ret = mm_sound_get_device_type(device, (mm_sound_device_type_e*)&mm_sound_device_type); + if (ret == MM_ERROR_NONE) + _convert_device_type(mm_sound_device_type, &device_type); if (ret != MM_ERROR_NONE) goto LEAVE; - if (device_type != SOUND_DEVICE_BLUETOOTH) { + if (device_type != SOUND_DEVICE_BLUETOOTH_MEDIA && device_type != SOUND_DEVICE_BLUETOOTH_VOICE) { ret = MM_ERROR_INVALID_ARGUMENT; goto LEAVE; } - ret = mm_sound_get_device_bt_avail_mode(device, &mm_avail_mode); - if (ret != MM_ERROR_NONE) - goto LEAVE; - - if ((_avail_mode = _convert_avail_mode(mm_avail_mode)) < 0) { - LOGE("Invalid avail mode %d", mm_avail_mode); - ret = MM_ERROR_SOUND_INTERNAL; - goto LEAVE; - } - - *modes = _avail_mode; + /* temporary code, this API should be removed */ + *modes = SOUND_DEVICE_BLUETOOTH_MODE_MEDIA | SOUND_DEVICE_BLUETOOTH_MODE_VOICE; LEAVE: return _convert_sound_manager_error_code(__func__, ret); diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index 010549b..3297ce1 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -370,7 +370,7 @@ int _convert_sound_type_to_enum(const char *sound_type, sound_type_e *sound_type return MM_ERROR_NONE; } -int _convert_device_type(sound_device_type_e device_type_enum, char **device_type) +int _convert_device_type_to_str(sound_device_type_e device_type_enum, char **device_type) { SM_NULL_ARG_CHECK_FOR_PRIV(device_type); @@ -387,8 +387,11 @@ int _convert_device_type(sound_device_type_e device_type_enum, char **device_typ case SOUND_DEVICE_AUDIO_JACK: *device_type = "audio-jack"; break; - case SOUND_DEVICE_BLUETOOTH: - *device_type = "bt"; + case SOUND_DEVICE_BLUETOOTH_MEDIA: + *device_type = "bt-a2dp"; + break; + case SOUND_DEVICE_BLUETOOTH_VOICE: + *device_type = "bt-sco"; break; case SOUND_DEVICE_HDMI: *device_type = "hdmi"; @@ -409,6 +412,41 @@ int _convert_device_type(sound_device_type_e device_type_enum, char **device_typ return MM_ERROR_NONE; } +int _convert_device_type(mm_sound_device_type_e device_type, sound_device_type_e *sound_device_type) +{ + switch (device_type) { + case MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER: + *sound_device_type = SOUND_DEVICE_BUILTIN_SPEAKER; + break; + case MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER: + *sound_device_type = SOUND_DEVICE_BUILTIN_RECEIVER; + break; + case MM_SOUND_DEVICE_TYPE_BUILTIN_MIC: + *sound_device_type = SOUND_DEVICE_BUILTIN_MIC; + break; + case MM_SOUND_DEVICE_TYPE_AUDIOJACK: + *sound_device_type = SOUND_DEVICE_AUDIO_JACK; + break; + case MM_SOUND_DEVICE_TYPE_BLUETOOTH_A2DP: + *sound_device_type = SOUND_DEVICE_BLUETOOTH_MEDIA; + break; + case MM_SOUND_DEVICE_TYPE_BLUETOOTH_SCO: + *sound_device_type = SOUND_DEVICE_BLUETOOTH_VOICE; + break; + case MM_SOUND_DEVICE_TYPE_HDMI: + *sound_device_type = SOUND_DEVICE_HDMI; + break; + case MM_SOUND_DEVICE_TYPE_USB_AUDIO: + *sound_device_type = SOUND_DEVICE_USB_AUDIO; + break; + case MM_SOUND_DEVICE_TYPE_MIRRORING: + *sound_device_type = SOUND_DEVICE_FORWARDING; + break; + } + + return MM_ERROR_NONE; +} + int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *sound_io_direction) { SM_NULL_ARG_CHECK(sound_io_direction); @@ -428,21 +466,6 @@ int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, so return MM_ERROR_NONE; } -int _convert_avail_mode(int avail_mode) -{ - int _avail_mode = 0; - - if ((avail_mode < 0) || (avail_mode > (MM_SOUND_DEVICE_BT_MODE_MEDIA | MM_SOUND_DEVICE_BT_MODE_VOICE))) - return -1; - - if (avail_mode & MM_SOUND_DEVICE_BT_MODE_MEDIA) - _avail_mode |= SOUND_DEVICE_BLUETOOTH_MODE_MEDIA; - if (avail_mode & MM_SOUND_DEVICE_BT_MODE_VOICE) - _avail_mode |= SOUND_DEVICE_BLUETOOTH_MODE_VOICE; - - return _avail_mode; -} - const char* _convert_api_name(native_api_e api_name) { const char* name = NULL; @@ -1136,7 +1159,8 @@ void _device_connected_cb(sound_device_h device, bool is_connected, void *user_d switch (type) { case MM_SOUND_DEVICE_TYPE_AUDIOJACK: - case MM_SOUND_DEVICE_TYPE_BLUETOOTH: + case MM_SOUND_DEVICE_TYPE_BLUETOOTH_A2DP: + case MM_SOUND_DEVICE_TYPE_BLUETOOTH_SCO: case MM_SOUND_DEVICE_TYPE_HDMI: case MM_SOUND_DEVICE_TYPE_MIRRORING: case MM_SOUND_DEVICE_TYPE_USB_AUDIO: @@ -1252,7 +1276,7 @@ int _set_session_mode(_session_mode_e mode) 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: /* Bluetooth spk & mic */ + case _SESSION_MODE_VOICE_WITH_BLUETOOTH_SCO: /* Bluetooth spk & mic */ /* check if the device is available now */ ret = mm_sound_get_device_list(MM_SOUND_DEVICE_ALL_FLAG, &device_list); if (ret != MM_ERROR_NONE) { @@ -1290,8 +1314,8 @@ int _set_session_mode(_session_mode_e mode) break; } break; - case _SESSION_MODE_VOICE_WITH_BLUETOOTH: - if (type == MM_SOUND_DEVICE_TYPE_BLUETOOTH) { + case _SESSION_MODE_VOICE_WITH_BLUETOOTH_SCO: + if (type == MM_SOUND_DEVICE_TYPE_BLUETOOTH_SCO) { is_found = true; proper_device = tmp_device; break; @@ -1584,8 +1608,9 @@ int _add_device_for_stream_routing(sound_stream_info_s *stream_info, sound_devic #endif char *device_type_str = NULL; int device_id = 0; - mm_sound_device_type_e device_type; + mm_sound_device_type_e mm_sound_device_type; mm_sound_device_io_direction_e device_direction; + sound_device_type_e device_type; SM_INSTANCE_CHECK_FOR_PRIV(stream_info); SM_NULL_ARG_CHECK_FOR_PRIV(device); @@ -1603,9 +1628,11 @@ int _add_device_for_stream_routing(sound_stream_info_s *stream_info, sound_devic #endif if ((ret = mm_sound_get_device_id(device, &device_id))) return ret; - if ((ret = mm_sound_get_device_type(device, &device_type))) + if ((ret = mm_sound_get_device_type(device, &mm_sound_device_type))) return ret; - if ((ret = _convert_device_type(device_type, &device_type_str))) + if (ret == MM_ERROR_NONE) + _convert_device_type(mm_sound_device_type, &device_type); + if ((ret = _convert_device_type_to_str(device_type, &device_type_str))) return ret; if ((ret = mm_sound_get_device_io_direction(device, &device_direction))) return ret; @@ -1666,8 +1693,9 @@ int _remove_device_for_stream_routing(sound_stream_info_s *stream_info, sound_de bool removed_successfully = false; char *device_type_str = NULL; int device_id = 0; - mm_sound_device_type_e device_type; + mm_sound_device_type_e mm_sound_device_type; mm_sound_device_io_direction_e device_direction; + sound_device_type_e device_type; SM_INSTANCE_CHECK_FOR_PRIV(stream_info); SM_NULL_ARG_CHECK_FOR_PRIV(device); @@ -1676,9 +1704,11 @@ int _remove_device_for_stream_routing(sound_stream_info_s *stream_info, sound_de stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL_EXT) { if ((ret = mm_sound_get_device_id(device, &device_id))) return ret; - if ((ret = mm_sound_get_device_type(device, &device_type))) + if ((ret = mm_sound_get_device_type(device, &mm_sound_device_type))) return ret; - if ((ret = _convert_device_type(device_type, &device_type_str))) + if (ret == MM_ERROR_NONE) + _convert_device_type(mm_sound_device_type, &device_type); + if ((ret = _convert_device_type_to_str(device_type, &device_type_str))) return ret; if ((ret = mm_sound_get_device_io_direction(device, &device_direction))) return ret; diff --git a/test/sound_manager_test.c b/test/sound_manager_test.c index 9e1224d..8529e50 100644 --- a/test/sound_manager_test.c +++ b/test/sound_manager_test.c @@ -100,11 +100,6 @@ virtual_sound_stream_h g_vstream_h = NULL; static const char *g_device_direction_str[] = {"IN", "OUT", "BOTH"}; static const char *g_device_state_str[] = {"De-Activated", "Activated"}; -static const char *g_device_avail_modes_str[] = { - [SOUND_DEVICE_BLUETOOTH_MODE_MEDIA] = "Media", - [SOUND_DEVICE_BLUETOOTH_MODE_VOICE] = "Voice", - [SOUND_DEVICE_BLUETOOTH_MODE_MEDIA | SOUND_DEVICE_BLUETOOTH_MODE_VOICE] = "Media & Voice" -}; void focus_callback(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, @@ -419,9 +414,9 @@ static void displaymenu() else if (g_menu_state == CURRENT_STATUS_CREATE_STREAM_INFO) g_print("*** input stream type to create stream information\n(0:media, 1:system, 2:alarm, 3:notification, 4:emergency, 5:ringtone-call, 6:voice-call, 7:voip, 8:media-ext-only, 9:loopback, 10:solo, 11:radio)\n"); else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING) - g_print("*** input device type to add (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt, 5:usb)\n"); + g_print("*** input device type to add (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n"); else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING) - g_print("*** input device type to remove (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt, 5:usb)\n"); + g_print("*** input device type to remove (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n"); else if (g_menu_state == CURRENT_STATUS_APPLY_STREAM_ROUTING) g_print("*** press enter to apply devices for stream routing\n"); else if (g_menu_state == CURRENT_STATUS_SET_STREAM_ROUTING_OPTION) @@ -554,25 +549,24 @@ void _set_session_interrupted_cb(sound_session_interrupted_code_e code, void *us /* If failed to get some property, just give some default value */ void _get_device_props_simple(sound_device_h device, int *id, char **type, char **name, - const char **direc, const char **state, const char **avail_modes) + const char **direc, const char **state) { int ret; sound_device_type_e _type; sound_device_io_direction_e _direc; sound_device_state_e _state; - int _avail_modes; if ((ret = sound_manager_get_device_type(device, &_type))) g_print("failed to get device type, ret[0x%x]\n", ret); else - _convert_device_type(_type, type); + _convert_device_type_to_str(_type, type); if ((ret = sound_manager_get_device_id(device, id))) { g_print("failed to get device id, ret[0x%x]\n", ret); *id = -1; } - if (_type == SOUND_DEVICE_BLUETOOTH || _type == SOUND_DEVICE_USB_AUDIO) { + if (_type == SOUND_DEVICE_BLUETOOTH_MEDIA || _type == SOUND_DEVICE_BLUETOOTH_VOICE || _type == SOUND_DEVICE_USB_AUDIO) { if ((ret = sound_manager_get_device_name(device, name))) { g_print("failed to get device name, ret[0x%x]\n", ret); *name = NOT_AVAIL; @@ -594,29 +588,18 @@ void _get_device_props_simple(sound_device_h device, int *id, char **type, char } else { *state = g_device_state_str[_state]; } - - if (_type == SOUND_DEVICE_BLUETOOTH) { - if ((ret = sound_manager_get_bt_device_avail_modes(device, &_avail_modes))) { - g_print("failed to get device avail_mode, ret[0x%x]\n", ret); - *avail_modes = NOT_AVAIL; - } else { - *avail_modes = g_device_avail_modes_str[_avail_modes]; - } - } else { - *avail_modes = NOT_AVAIL; - } } void _set_device_connected_cb(sound_device_h device, bool is_connected, void *user_data) { int id = -1; char *type, *name; - const char *direc, *state, *avail_modes; + const char *direc, *state; - _get_device_props_simple(device, &id, &type, &name, &direc, &state, &avail_modes); + _get_device_props_simple(device, &id, &type, &name, &direc, &state); g_print("[ Device #%d %s %s ] %s\n", id, type, name, is_connected ? "Connected" : "Disconnected"); - g_print(" Direc[ %-4s ] State[ %-12s ] Avail-Modes[ %s ]\n", direc, state, avail_modes); + g_print(" Direc[ %-4s ] State[ %-12s ]\n", direc, state); } void _set_device_info_changed_cb(sound_device_h device, sound_device_changed_info_e changed_info, void *user_data) @@ -624,13 +607,13 @@ void _set_device_info_changed_cb(sound_device_h device, sound_device_changed_inf int id = -1; char *type, *name; - const char *direc, *state, *avail_modes; + const char *direc, *state; const char *changed_info_str[] = {"State", "Direction", "Avail-Mode"}; - _get_device_props_simple(device, &id, &type, &name, &direc, &state, &avail_modes); + _get_device_props_simple(device, &id, &type, &name, &direc, &state); g_print("[Device #%d %s %s] %s changed\n", id, type, name, changed_info_str[changed_info]); - g_print(" Direc[ %-4s ] State[ %-12s ] Avail-Modes[ %s ]\n", direc, state, avail_modes); + g_print(" Direc[ %-4s ] State[ %-12s ]\n", direc, state); } void reset_menu_state(void) @@ -966,13 +949,12 @@ static void interpret(char *cmd) char *name; const char *direc; const char *state; - const char *avail_modes; if (!(ret = sound_manager_get_current_device_list(g_device_mask, &device_list))) { g_print("success to get current device list\n"); while (!sound_manager_get_next_device(device_list, &device)) { - _get_device_props_simple(device, &id, &type, &name, &direc, &state, &avail_modes); + _get_device_props_simple(device, &id, &type, &name, &direc, &state); g_print("[ Device #%d %s %s ]\n", id, type, name); - g_print(" Direc[ %-4s ] State[ %-12s ] Avail-Modes[ %s ]\n", direc, state, avail_modes); + g_print(" Direc[ %-4s ] State[ %-12s ]\n", direc, state); } } else { g_print("fail to get current device list, ret[0x%x]\n", ret); @@ -1169,10 +1151,13 @@ static void interpret(char *cmd) case 3: /* audio-jack */ selected_type = SOUND_DEVICE_AUDIO_JACK; break; - case 4: /* bt */ - selected_type = SOUND_DEVICE_BLUETOOTH; + case 4: /* bt a2dp */ + selected_type = SOUND_DEVICE_BLUETOOTH_MEDIA; break; - case 5: /* usb */ + case 5: /* bt sco */ + selected_type = SOUND_DEVICE_BLUETOOTH_VOICE; + break; + case 6: /* usb */ selected_type = SOUND_DEVICE_USB_AUDIO; break; default: @@ -1229,10 +1214,13 @@ static void interpret(char *cmd) case 3: /* audio-jack */ selected_type = SOUND_DEVICE_AUDIO_JACK; break; - case 4: /* bt */ - selected_type = SOUND_DEVICE_BLUETOOTH; + case 4: /* bt a2dp */ + selected_type = SOUND_DEVICE_BLUETOOTH_MEDIA; + break; + case 5: /* bt sco */ + selected_type = SOUND_DEVICE_BLUETOOTH_VOICE; break; - case 5: /* usb */ + case 6: /* usb */ selected_type = SOUND_DEVICE_USB_AUDIO; break; default: