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;
/**
_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 {
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);
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
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);
}
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);
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);
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";
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);
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;
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:
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) {
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;
#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);
#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;
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);
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;
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,
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)
/* 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;
} 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)
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)
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);
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:
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: