* @brief Enumeration for sound manager's error codes.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
-typedef enum
-{
+typedef enum {
SOUND_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
SOUND_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
SOUND_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
* @brief Enumeration for sound type.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
-typedef enum
-{
+typedef enum {
SOUND_TYPE_SYSTEM, /**< Sound type for system */
SOUND_TYPE_NOTIFICATION, /**< Sound type for notifications */
SOUND_TYPE_ALARM, /**< Sound type for alarm */
* @see sound_manager_create_stream_information()
* @see sound_manager_destroy_stream_information()
*/
-typedef void (* sound_stream_focus_state_changed_cb) (sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data);
+typedef void (*sound_stream_focus_state_changed_cb) (sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data);
/**
* @brief Called when the focus state for each sound stream type is changed regardless of the process.
* @see sound_manager_set_focus_state_watch_cb()
* @see sound_manager_unset_focus_state_watch_cb()
*/
-typedef void (* sound_stream_focus_state_watch_cb) (sound_stream_focus_mask_e changed_focus_mask, sound_stream_focus_state_e changed_focus_state, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data);
+typedef void (*sound_stream_focus_state_watch_cb) (sound_stream_focus_mask_e changed_focus_mask, sound_stream_focus_state_e changed_focus_state, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data);
/**
* @}
* @see sound_manager_set_session_interrupted_cb()
* @see sound_manager_unset_session_interrupted_cb()
*/
-typedef void (* sound_session_interrupted_cb) (sound_session_interrupted_code_e code, void *user_data);
+typedef void (*sound_session_interrupted_cb) (sound_session_interrupted_code_e code, void *user_data);
/**
* @}
* @see sound_manager_set_device_connected_cb()
* @see sound_manager_unset_device_connected_cb()
*/
-typedef void (* sound_device_connected_cb) (sound_device_h device, bool is_connected, void *user_data);
+typedef void (*sound_device_connected_cb) (sound_device_h device, bool is_connected, void *user_data);
/**
* @brief Called when the information of a sound device was changed.
* @see sound_manager_set_device_information_changed_cb()
* @see sound_manager_unset_device_information_changed_cb()
*/
-typedef void (* sound_device_information_changed_cb) (sound_device_h device, sound_device_changed_info_e changed_info, void *user_data);
+typedef void (*sound_device_information_changed_cb) (sound_device_h device, sound_device_changed_info_e changed_info, void *user_data);
/**
* @}
* @see sound_manager_set_volume()
* @see sound_manager_get_volume()
*/
-int sound_manager_get_max_volume (sound_type_e type, int *max);
+int sound_manager_get_max_volume(sound_type_e type, int *max);
/**
* @brief Sets the volume level specified for a particular sound type.
* @see sound_manager_get_max_volume()
* @see sound_manager_get_volume()
*/
-int sound_manager_set_volume (sound_type_e type, int volume);
+int sound_manager_set_volume(sound_type_e type, int volume);
/**
* @brief Gets the volume level specified for a particular sound type.
* @see sound_manager_get_max_volume()
* @see sound_manager_set_volume()
*/
-int sound_manager_get_volume (sound_type_e type, int *volume);
+int sound_manager_get_volume(sound_type_e type, int *volume);
/**
* @brief Sets the type of the sound being currently played.
* @see sound_manager_get_current_sound_type()
* @see sound_manager_unset_current_sound_type()
*/
-int sound_manager_set_current_sound_type (sound_type_e type);
+int sound_manager_set_current_sound_type(sound_type_e type);
/**
* @brief Gets the type of the sound being currently played.
* @see sound_manager_set_current_sound_type()
* @see sound_manager_unset_current_sound_type()
*/
-int sound_manager_get_current_sound_type (sound_type_e *type);
+int sound_manager_get_current_sound_type(sound_type_e *type);
/**
* @brief Unsets the type of the sound being currently played.
* @see sound_manager_set_current_sound_type()
* @see sound_manager_get_current_sound_type()
*/
-int sound_manager_unset_current_sound_type (void);
+int sound_manager_unset_current_sound_type(void);
/**
* @brief Registers a callback function to be invoked when the volume level is changed.
* @see sound_manager_unset_volume_changed_cb()
* @see sound_manager_volume_changed_cb()
*/
-int sound_manager_set_volume_changed_cb (sound_manager_volume_changed_cb callback, void *user_data);
+int sound_manager_set_volume_changed_cb(sound_manager_volume_changed_cb callback, void *user_data);
/**
* @brief Unregisters the volume change callback.
* @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
* @see sound_manager_set_volume_changed_cb()
*/
-int sound_manager_unset_volume_changed_cb (void);
+int sound_manager_unset_volume_changed_cb(void);
/**
* @}
* @brief Creates a handle for stream information.
* @since_tizen 3.0
* @details To apply the stream policy according to this stream information, this handle should be passed to other APIs\n
- * related to playback or recording. (e.g., player, wav-player, audio-io, etc.)
+ * related to playback or recording. (e.g., player, wav-player, audio-io, etc.)
* @param[in] stream_type The type of stream
* @param[in] callback The focus state change callback function (mandatory)
* @param[in] user_data The user data to be passed to the callback function
* @see sound_manager_destroy_focus()
* @see sound_manager_get_focus_state()
*/
-int sound_manager_create_stream_information (sound_stream_type_e stream_type, sound_stream_focus_state_changed_cb callback, void *user_data, sound_stream_info_h *stream_info);
+int sound_manager_create_stream_information(sound_stream_type_e stream_type, sound_stream_focus_state_changed_cb callback, void *user_data, sound_stream_info_h *stream_info);
/**
* @brief Destroys the handle for stream information.
* @see sound_manager_destroy_focus()
* @see sound_manager_get_focus_state()
*/
-int sound_manager_destroy_stream_information (sound_stream_info_h stream_info);
+int sound_manager_destroy_stream_information(sound_stream_info_h stream_info);
/**
* @brief Adds the device to the stream information for the stream routing.
* @param[in] device The device item from sound_device_list_h
*
* @remarks @a Use sound_manager_get_current_device_list() and sound_manager_get_next_device() to get the device.\n
- * SOUND_MANAGER_ERROR_POLICY could be returned according to the stream type of the stream_info.\n
- * The available type of the stream_info for this API is SOUND_STREAM_TYPE_VOIP.
+ * SOUND_MANAGER_ERROR_POLICY could be returned according to the stream type of the stream_info.\n
+ * The available type of the stream_info for this API is SOUND_STREAM_TYPE_VOIP.
*
* @return @c 0 on success,
* otherwise a negative error value
* @see sound_manager_remove_device_for_stream_routing()
* @see sound_manager_apply_stream_routing()
*/
-int sound_manager_add_device_for_stream_routing (sound_stream_info_h stream_info, sound_device_h device);
+int sound_manager_add_device_for_stream_routing(sound_stream_info_h stream_info, sound_device_h device);
/**
* @brief Removes the device to the stream information for the stream routing.
* @see sound_manager_add_device_for_stream_routing()
* @see sound_manager_apply_stream_routing()
*/
-int sound_manager_remove_device_for_stream_routing (sound_stream_info_h stream_info, sound_device_h device);
+int sound_manager_remove_device_for_stream_routing(sound_stream_info_h stream_info, sound_device_h device);
/**
* @brief Applies the stream routing.
* @see sound_manager_add_device_for_stream_routing()
* @see sound_manager_remove_device_for_stream_routing()
*/
-int sound_manager_apply_stream_routing (sound_stream_info_h stream_info);
+int sound_manager_apply_stream_routing(sound_stream_info_h stream_info);
/**
* @brief Acquires the stream focus.
* @see sound_manager_release_focus()
* @see sound_manager_get_focus_state()
*/
-int sound_manager_acquire_focus (sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *additional_info);
+int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *additional_info);
/**
* @brief Releases the acquired focus.
* @see sound_manager_acquire_focus()
* @see sound_manager_get_focus_state()
*/
-int sound_manager_release_focus (sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *additional_info);
+int sound_manager_release_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *additional_info);
/**
* @brief Gets the state of focus.
* @see sound_manager_acquire_focus()
* @see sound_manager_release_focus()
*/
-int sound_manager_get_focus_state (sound_stream_info_h stream_info, sound_stream_focus_state_e *state_for_playback, sound_stream_focus_state_e *state_for_recording);
+int sound_manager_get_focus_state(sound_stream_info_h stream_info, sound_stream_focus_state_e *state_for_playback, sound_stream_focus_state_e *state_for_recording);
/**
* @brief Registers the watch callback function to be invoked when the focus state for each sound stream type is changed regardless of the process.
* @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
* @see sound_manager_unset_focus_state_watch_cb()
*/
-int sound_manager_set_focus_state_watch_cb (sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_watch_cb callback, void *user_data);
+int sound_manager_set_focus_state_watch_cb(sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_watch_cb callback, void *user_data);
/**
* @brief Unregisters the focus state watch callback.
* @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
* @see sound_manager_set_focus_state_watch_cb()
*/
-int sound_manager_unset_focus_state_watch_cb (void);
+int sound_manager_unset_focus_state_watch_cb(void);
/**
* @}
* @see sound_manager_set_voip_session_mode()
* @see sound_manager_get_voip_session_mode()
*/
-int sound_manager_set_session_type (sound_session_type_e type);
+int sound_manager_set_session_type(sound_session_type_e type);
/**
* @deprecated Deprecated since 3.0.
* @see sound_manager_set_voip_session_mode()
* @see sound_manager_get_voip_session_mode()
*/
-int sound_manager_get_session_type (sound_session_type_e *type);
+int sound_manager_get_session_type(sound_session_type_e *type);
/**
* @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
* @see sound_manager_set_media_session_resumption_option()
* @see sound_manager_get_media_session_resumption_option()
*/
-int sound_manager_set_media_session_option (sound_session_option_for_starting_e s_option, sound_session_option_for_during_play_e d_option);
+int sound_manager_set_media_session_option(sound_session_option_for_starting_e s_option, sound_session_option_for_during_play_e d_option);
/**
* @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
* @see sound_manager_set_media_session_resumption_option()
* @see sound_manager_get_media_session_resumption_option()
*/
-int sound_manager_get_media_session_option (sound_session_option_for_starting_e *s_option, sound_session_option_for_during_play_e *d_option);
+int sound_manager_get_media_session_option(sound_session_option_for_starting_e *s_option, sound_session_option_for_during_play_e *d_option);
/**
* @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
* @see sound_manager_get_media_session_option()
* @see sound_manager_get_media_session_resumption_option()
*/
-int sound_manager_set_media_session_resumption_option (sound_session_option_for_resumption_e option);
+int sound_manager_set_media_session_resumption_option(sound_session_option_for_resumption_e option);
/**
* @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
* @see sound_manager_get_media_session_option()
* @see sound_manager_set_media_session_resumption_option()
*/
-int sound_manager_get_media_session_resumption_option (sound_session_option_for_resumption_e *option);
+int sound_manager_get_media_session_resumption_option(sound_session_option_for_resumption_e *option);
/**
* @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
* @see sound_manager_get_session_type()
* @see sound_manager_get_voip_session_mode()
*/
-int sound_manager_set_voip_session_mode (sound_session_voip_mode_e mode);
+int sound_manager_set_voip_session_mode(sound_session_voip_mode_e mode);
/**
* @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
* @see sound_manager_get_session_type()
* @see sound_manager_set_voip_session_mode()
*/
-int sound_manager_get_voip_session_mode (sound_session_voip_mode_e *mode);
+int sound_manager_get_voip_session_mode(sound_session_voip_mode_e *mode);
/**
* @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
* @see sound_manager_unset_session_interrupted_cb()
* @see sound_session_interrupted_cb()
*/
-int sound_manager_set_session_interrupted_cb (sound_session_interrupted_cb callback, void *user_data);
+int sound_manager_set_session_interrupted_cb(sound_session_interrupted_cb callback, void *user_data);
/**
* @deprecated Deprecated since 3.0.
* @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
* @see sound_manager_set_session_interrupted_cb()
*/
-int sound_manager_unset_session_interrupted_cb (void);
+int sound_manager_unset_session_interrupted_cb(void);
/**
* @}
* @see sound_manager_get_device_name()
* @see sound_manager_get_device_state()
*/
-int sound_manager_get_current_device_list (sound_device_mask_e device_mask, sound_device_list_h *device_list);
+int sound_manager_get_current_device_list(sound_device_mask_e device_mask, sound_device_list_h *device_list);
/**
* @brief Gets the next item of the device list.
* @see sound_manager_get_device_name()
* @see sound_manager_get_device_state()
*/
-int sound_manager_get_next_device (sound_device_list_h device_list, sound_device_h *device);
+int sound_manager_get_next_device(sound_device_list_h device_list, sound_device_h *device);
/**
* @brief Gets the previous item of the device list.
* @see sound_manager_get_device_name()
* @see sound_manager_get_device_state()
*/
-int sound_manager_get_prev_device (sound_device_list_h device_list, sound_device_h *device);
+int sound_manager_get_prev_device(sound_device_list_h device_list, sound_device_h *device);
/**
* @brief Gets the type of the device.
* @see sound_manager_get_device_name()
* @see sound_manager_get_device_state()
*/
-int sound_manager_get_device_type (sound_device_h device, sound_device_type_e *type);
+int sound_manager_get_device_type(sound_device_h device, sound_device_type_e *type);
/**
* @brief Gets the io direction of the device.
* @see sound_manager_get_device_name()
* @see sound_manager_get_device_state()
*/
-int sound_manager_get_device_io_direction (sound_device_h device, sound_device_io_direction_e *io_direction);
+int sound_manager_get_device_io_direction(sound_device_h device, sound_device_io_direction_e *io_direction);
/**
* @brief Gets the id of the device.
* @see sound_manager_get_device_name()
* @see sound_manager_get_device_state()
*/
-int sound_manager_get_device_id (sound_device_h device, int *id);
+int sound_manager_get_device_id(sound_device_h device, int *id);
/**
* @brief Gets the name of the device.
* @see sound_manager_get_device_id()
* @see sound_manager_get_device_state()
*/
-int sound_manager_get_device_name (sound_device_h device, char **name);
+int sound_manager_get_device_name(sound_device_h device, char **name);
/**
* @brief Gets the state of the device.
* @see sound_manager_get_device_id()
* @see sound_manager_get_device_name()
*/
-int sound_manager_get_device_state (sound_device_h device, sound_device_state_e *state);
+int sound_manager_get_device_state(sound_device_h device, sound_device_state_e *state);
/**
* @brief Registers a callback function to be invoked when the state of connection of a sound device was changed.
* @see sound_manager_unset_device_connected_cb()
* @see sound_device_connected_cb()
*/
-int sound_manager_set_device_connected_cb (sound_device_mask_e device_mask, sound_device_connected_cb callback, void *user_data);
+int sound_manager_set_device_connected_cb(sound_device_mask_e device_mask, sound_device_connected_cb callback, void *user_data);
/**
* @brief Unregisters the callback function which is called when the state of connection of a sound device was changed.
* @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
* @see sound_manager_set_device_connected_cb()
*/
-int sound_manager_unset_device_connected_cb (void);
+int sound_manager_unset_device_connected_cb(void);
/**
* @brief Registers a callback function to be invoked when the information of a sound device was changed.
* @see sound_manager_unset_device_information_changed_cb()
* @see sound_device_information_changed_cb()
*/
-int sound_manager_set_device_information_changed_cb (sound_device_mask_e device_mask, sound_device_information_changed_cb callback, void *user_data);
+int sound_manager_set_device_information_changed_cb(sound_device_mask_e device_mask, sound_device_information_changed_cb callback, void *user_data);
/**
* @brief Unregisters the callback function which is called when the information of a sound device was changed.
* @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
* @see sound_manager_set_device_information_changed_cb()
*/
-int sound_manager_unset_device_information_changed_cb (void);
+int sound_manager_unset_device_information_changed_cb(void);
/**
* @}
* @brief Creates a handle for stream information.
* @since_tizen 3.0
* @details To apply the stream policy according to this stream information, this handle should be passed to other APIs\n
- * related to playback or recording. (e.g., player, wav-player, audio-io, etc.)
+ * related to playback or recording. (e.g., player, wav-player, audio-io, etc.)
* @param[in] stream_type The type of stream for internal usage
* @param[in] callback The focus state change callback function (mandatory)
* @param[in] user_data The user data to be passed to the callback function
* @see sound_manager_destroy_focus()
* @see sound_manager_get_focus_state()
*/
-int sound_manager_create_stream_information_internal (sound_stream_type_internal_e stream_type, sound_stream_focus_state_changed_cb callback, void *user_data, sound_stream_info_h *stream_info);
+int sound_manager_create_stream_information_internal(sound_stream_type_internal_e stream_type, sound_stream_focus_state_changed_cb callback, void *user_data, sound_stream_info_h *stream_info);
/**
* @internal
* @see sound_manager_create_stream_information_internal()
* @see sound_manager_destroy_stream_information()
*/
-int sound_manager_set_stream_routing_option (sound_stream_info_h stream_info, const char *name, int value);
+int sound_manager_set_stream_routing_option(sound_stream_info_h stream_info, const char *name, int value);
/**
* @internal
* @see sound_manager_create_stream_information()
* @see sound_manager_destroy_stream_information()
*/
-int sound_manager_is_available_stream_information (sound_stream_info_h stream_info, native_api_e api_name, bool *is_available);
+int sound_manager_is_available_stream_information(sound_stream_info_h stream_info, native_api_e api_name, bool *is_available);
/**
* @internal
* @see sound_manager_create_stream_information()
* @see sound_manager_destroy_stream_information()
*/
-int sound_manager_get_type_from_stream_information (sound_stream_info_h stream_info, char **type);
+int sound_manager_get_type_from_stream_information(sound_stream_info_h stream_info, char **type);
/**
* @internal
* @see sound_manager_create_stream_information()
* @see sound_manager_destroy_stream_information()
*/
-int sound_manager_get_index_from_stream_information (sound_stream_info_h stream_info, int *index);
+int sound_manager_get_index_from_stream_information(sound_stream_info_h stream_info, int *index);
/**
* @internal
* @see sound_manager_start_virtual_stream()
* @see sound_manager_stop_virtual_stream()
*/
-int sound_manager_create_virtual_stream (sound_stream_info_h stream_info, virtual_sound_stream_h *virtual_stream);
+int sound_manager_create_virtual_stream(sound_stream_info_h stream_info, virtual_sound_stream_h *virtual_stream);
/**
* @internal
* @see sound_manager_start_virtual_stream()
* @see sound_manager_stop_virtual_stream()
*/
-int sound_manager_destroy_virtual_stream (virtual_sound_stream_h virtual_stream);
+int sound_manager_destroy_virtual_stream(virtual_sound_stream_h virtual_stream);
/**
* @internal
* @see sound_manager_destroy_virtual_stream()
* @see sound_manager_stop_virtual_stream()
*/
-int sound_manager_start_virtual_stream (virtual_sound_stream_h virtual_stream);
+int sound_manager_start_virtual_stream(virtual_sound_stream_h virtual_stream);
/**
* @internal
* @see sound_manager_destroy_virtual_stream()
* @see sound_manager_start_virtual_stream()
*/
-int sound_manager_stop_virtual_stream (virtual_sound_stream_h virtual_stream);
+int sound_manager_stop_virtual_stream(virtual_sound_stream_h virtual_stream);
/**
* @}
#include <mm_sound_private.h>
#include "sound_manager_internal.h"
-#define _CHECK_CONDITION(condition,error,msg) \
- if(condition) {} else \
- { LOGE("[%s] %s(0x%08x)",__FUNCTION__, msg,error); return error;}; \
+#define _CHECK_CONDITION(condition, error, msg) \
+if (condition) { \
+} else { \
+ LOGE("[%s] %s(0x%08x)", __FUNCTION__, msg, error); \
+ return error; \
+}; \
-#define SM_INSTANCE_CHECK(handle) \
- _CHECK_CONDITION(handle != NULL,SOUND_MANAGER_ERROR_INVALID_PARAMETER,"SOUND_MANAGER_ERROR_INVALID_PARAMETER")
+#define SM_INSTANCE_CHECK(handle) \
+_CHECK_CONDITION(handle != NULL, SOUND_MANAGER_ERROR_INVALID_PARAMETER, "SOUND_MANAGER_ERROR_INVALID_PARAMETER")
-#define SM_NULL_ARG_CHECK(arg) \
- _CHECK_CONDITION(arg != NULL,SOUND_MANAGER_ERROR_INVALID_PARAMETER,"SOUND_MANAGER_ERROR_INVALID_PARAMETER")
+#define SM_NULL_ARG_CHECK(arg) \
+_CHECK_CONDITION(arg != NULL, SOUND_MANAGER_ERROR_INVALID_PARAMETER, "SOUND_MANAGER_ERROR_INVALID_PARAMETER")
-#define SM_STATE_CHECK(handle,expected_state) \
- _CHECK_CONDITION(handle->state == expected_state,SOUND_MANAGER_ERROR_INVALID_STATE,"SOUND_MANAGER_ERROR_INVALID_STATE")
+#define SM_STATE_CHECK(handle, expected_state) \
+_CHECK_CONDITION(handle->state == expected_state, SOUND_MANAGER_ERROR_INVALID_STATE, "SOUND_MANAGER_ERROR_INVALID_STATE")
-#define SM_RANGE_ARG_CHECK(arg, min, max) \
- _CHECK_CONDITION(arg <= max,SOUND_MANAGER_ERROR_INVALID_PARAMETER,"SOUND_MANAGER_ERROR_INVALID_PARAMETER") \
- _CHECK_CONDITION(arg >= min,SOUND_MANAGER_ERROR_INVALID_PARAMETER,"SOUND_MANAGER_ERROR_INVALID_PARAMETER")
+#define SM_RANGE_ARG_CHECK(arg, min, max) \
+_CHECK_CONDITION(arg <= max, SOUND_MANAGER_ERROR_INVALID_PARAMETER, "SOUND_MANAGER_ERROR_INVALID_PARAMETER") \
+_CHECK_CONDITION(arg >= min, SOUND_MANAGER_ERROR_INVALID_PARAMETER, "SOUND_MANAGER_ERROR_INVALID_PARAMETER")
-#define SM_INSTANCE_CHECK_FOR_PRIV(handle) \
- _CHECK_CONDITION(handle != NULL,MM_ERROR_INVALID_ARGUMENT,"MM_ERROR_INVALID_ARGUMENT")
+#define SM_INSTANCE_CHECK_FOR_PRIV(handle) \
+_CHECK_CONDITION(handle != NULL, MM_ERROR_INVALID_ARGUMENT, "MM_ERROR_INVALID_ARGUMENT")
-#define SM_NULL_ARG_CHECK_FOR_PRIV(arg) \
- _CHECK_CONDITION(arg != NULL,MM_ERROR_INVALID_ARGUMENT,"MM_ERROR_INVALID_ARGUMENT")
+#define SM_NULL_ARG_CHECK_FOR_PRIV(arg) \
+_CHECK_CONDITION(arg != NULL, MM_ERROR_INVALID_ARGUMENT, "MM_ERROR_INVALID_ARGUMENT")
-#define SM_STATE_CHECK_FOR_PRIV(handle,expected_state) \
- _CHECK_CONDITION(handle->state == expected_state,MM_ERROR_SOUND_INVALID_STATE,"MM_ERROR_SOUND_INVALID_STATE")
+#define SM_STATE_CHECK_FOR_PRIV(handle, expected_state) \
+_CHECK_CONDITION(handle->state == expected_state, MM_ERROR_SOUND_INVALID_STATE, "MM_ERROR_SOUND_INVALID_STATE")
-#define SM_ENTER_CRITICAL_SECTION_WITH_RETURN(x_mutex,x_return) \
-switch ( pthread_mutex_lock( x_mutex ) ) \
-{ \
+#define SM_ENTER_CRITICAL_SECTION_WITH_RETURN(x_mutex, x_return) \
+switch (pthread_mutex_lock(x_mutex)) { \
case EINVAL: \
LOGW("try mutex init..\n"); \
- if( 0 > pthread_mutex_init( x_mutex, NULL) ) { \
+ if (0 > pthread_mutex_init(x_mutex, NULL)) { \
return x_return; \
} else { \
break; \
}
#define SM_LEAVE_CRITICAL_SECTION(x_mutex) \
-if( pthread_mutex_unlock( x_mutex ) ) { \
+if (pthread_mutex_unlock(x_mutex)) { \
LOGE("mutex unlock failed\n"); \
}
unsigned int subs_id; /* for internal device connected subscription */
void *user_data;
sound_session_interrupted_cb user_cb;
-}_session_interrupt_info_s;
+} _session_interrupt_info_s;
typedef struct {
unsigned int subs_id;
void *user_data;
sound_manager_volume_changed_cb user_cb;
-}_volume_changed_info_s;
+} _volume_changed_info_s;
typedef struct {
int index;
void *user_data;
sound_stream_focus_state_watch_cb user_cb;
-}_focus_watch_info_s;
+} _focus_watch_info_s;
typedef struct {
unsigned int subs_id;
void *user_data;
sound_device_connected_cb user_cb;
-}_device_connected_info_s;
+} _device_connected_info_s;
typedef struct {
unsigned int subs_id;
void *user_data;
sound_device_information_changed_cb user_cb;
-}_device_changed_info_s;
+} _device_changed_info_s;
-void _focus_session_interrupt_cb (mm_sound_focus_state_e state, const char *reason_for_change, bool is_wcb, void *user_data);
+void _focus_session_interrupt_cb(mm_sound_focus_state_e state, const char *reason_for_change, bool is_wcb, void *user_data);
-void _voip_focus_state_change_callback (sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data);
+void _voip_focus_state_change_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data);
void _device_connected_cb(sound_device_h device, bool is_connected, void *user_data);
-void _focus_state_change_callback (int index, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data);
+void _focus_state_change_callback(int index, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data);
-void _focus_watch_callback (int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data);
+void _focus_watch_callback(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data);
-int _convert_sound_manager_error_code (const char *func, int code);
+int _convert_sound_manager_error_code(const char *func, int code);
-int _convert_stream_type (sound_stream_type_e enum_type, char **stream_type);
+int _convert_stream_type(sound_stream_type_e enum_type, char **stream_type);
-int _convert_stream_type_for_internal (sound_stream_type_internal_e stream_type_enum, char **stream_type);
+int _convert_stream_type_for_internal(sound_stream_type_internal_e stream_type_enum, char **stream_type);
-int _convert_stream_type_to_change_reason (const char *stream_type, sound_stream_focus_change_reason_e *change_reason);
+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(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_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);
+const char* _convert_api_name(native_api_e api_name);
-int _get_stream_conf_info (const char *stream_type, stream_conf_info_s *info);
+int _get_stream_conf_info(const char *stream_type, stream_conf_info_s *info);
-int _set_manual_route_info (unsigned int index, manual_route_info_s *info);
+int _set_manual_route_info(unsigned int index, manual_route_info_s *info);
-int _set_route_option (unsigned int index, const char *key, int value);
+int _set_route_option(unsigned int index, const char *key, int value);
-int _convert_sound_type (sound_type_e sound_type, const char **volume_type);
+int _convert_sound_type(sound_type_e sound_type, const char **volume_type);
-int _convert_sound_type_to_enum (char *sound_type, sound_type_e *sound_type_enum);
+int _convert_sound_type_to_enum(char *sound_type, sound_type_e *sound_type_enum);
-int _get_volume_max_level (const char *direction, const char *volume_type, unsigned int *max_level);
+int _get_volume_max_level(const char *direction, const char *volume_type, unsigned int *max_level);
-int _get_current_volume_type (const char *direction, char **volume_type);
+int _get_current_volume_type(const char *direction, char **volume_type);
-void _update_focus_status (unsigned int index, unsigned int acquired_focus_status);
+void _update_focus_status(unsigned int index, unsigned int acquired_focus_status);
-void _pa_context_state_cb (pa_context *c, void *userdata);
+void _pa_context_state_cb(pa_context *c, void *userdata);
-void _pa_stream_state_cb (pa_stream *s, void * userdata);
+void _pa_stream_state_cb(pa_stream *s, void * userdata);
-int _set_session_mode (_session_mode_e mode);
+int _set_session_mode(_session_mode_e mode);
int _make_pa_connection_and_register_focus(sound_stream_info_s *stream_h, sound_stream_focus_state_changed_cb callback, void *user_data);
int _destroy_pa_connection_and_unregister_focus(sound_stream_info_s *stream_h);
-int _add_device_for_stream_routing (sound_stream_info_s *stream_info, sound_device_h device);
+int _add_device_for_stream_routing(sound_stream_info_s *stream_info, sound_device_h device);
-int _remove_device_for_stream_routing (sound_stream_info_s *stream_info, sound_device_h device);
+int _remove_device_for_stream_routing(sound_stream_info_s *stream_info, sound_device_h device);
-int _apply_stream_routing (sound_stream_info_s *stream_info);
+int _apply_stream_routing(sound_stream_info_s *stream_info);
-int _create_virtual_stream (sound_stream_info_s *stream_info, virtual_sound_stream_info_s **virtual_stream);
+int _create_virtual_stream(sound_stream_info_s *stream_info, virtual_sound_stream_info_s **virtual_stream);
-int _destroy_virtual_stream (virtual_sound_stream_info_s *virtual_stream);
+int _destroy_virtual_stream(virtual_sound_stream_info_s *virtual_stream);
-int _start_virtual_stream (virtual_sound_stream_info_s *virtual_stream);
+int _start_virtual_stream(virtual_sound_stream_info_s *virtual_stream);
-int _stop_virtual_stream (virtual_sound_stream_info_s *virtual_stream);
+int _stop_virtual_stream(virtual_sound_stream_info_s *virtual_stream);
#ifdef __cplusplus
}
Name: capi-media-sound-manager
Summary: Sound Manager library
-Version: 0.3.21
+Version: 0.3.22
Release: 0
Group: Multimedia/API
License: Apache-2.0
extern pthread_mutex_t g_stream_info_count_mutex;
pthread_mutex_t g_interrupt_cb_mutex, g_device_info_cb_mutex, g_device_conn_cb_mutex, g_volume_cb_mutex;
-int sound_manager_get_max_volume (sound_type_e type, int *max)
+int sound_manager_get_max_volume(sound_type_e type, int *max)
{
const char *volume_type = NULL;
unsigned int max_level = 0;
if (type >= SOUND_TYPE_NUM || type < 0)
return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
- ret = _convert_sound_type (type, &volume_type);
+ ret = _convert_sound_type(type, &volume_type);
if (ret == MM_ERROR_NONE) {
ret = _get_volume_max_level("out", volume_type, &max_level);
if (ret == MM_ERROR_NONE)
- *max = (int)max_level -1; // actual volume step can be max step - 1
+ *max = (int)max_level -1; /* actual volume step can be max step - 1 */
}
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_set_volume (sound_type_e type, int volume)
+int sound_manager_set_volume(sound_type_e type, int volume)
{
int ret = MM_ERROR_NONE;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_volume (sound_type_e type, int *volume)
+int sound_manager_get_volume(sound_type_e type, int *volume)
{
int ret = MM_ERROR_NONE;
unsigned int uvolume;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_set_current_sound_type (sound_type_e type)
+int sound_manager_set_current_sound_type(sound_type_e type)
{
int ret = MM_ERROR_NONE;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_current_sound_type (sound_type_e *type)
+int sound_manager_get_current_sound_type(sound_type_e *type)
{
int ret = MM_ERROR_NONE;
volume_type_t mm_sound_vol_type = VOLUME_TYPE_UNKNOWN;
if (ret == MM_ERROR_NONE) {
if (mm_sound_vol_type == VOLUME_TYPE_UNKNOWN) {
/* get the volume type of the current playing stream */
- ret = _get_current_volume_type ("out", &volume_type);
+ ret = _get_current_volume_type("out", &volume_type);
if (ret == MM_ERROR_NONE) {
- ret = _convert_sound_type_to_enum (volume_type, type);
+ ret = _convert_sound_type_to_enum(volume_type, type);
free(volume_type);
}
} else {
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_unset_current_sound_type (void)
+int sound_manager_unset_current_sound_type(void)
{
int ret = MM_ERROR_NONE;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_set_volume_changed_cb (sound_manager_volume_changed_cb callback, void* user_data)
+int sound_manager_set_volume_changed_cb(sound_manager_volume_changed_cb callback, void* user_data)
{
int ret = MM_ERROR_NONE;
unsigned int subs_id = 0;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_unset_volume_changed_cb (void)
+int sound_manager_unset_volume_changed_cb(void)
{
int ret = MM_ERROR_NONE;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_create_stream_information (sound_stream_type_e stream_type, sound_stream_focus_state_changed_cb callback, void *user_data, sound_stream_info_h *stream_info)
+int sound_manager_create_stream_information(sound_stream_type_e stream_type, sound_stream_focus_state_changed_cb callback, void *user_data, sound_stream_info_h *stream_info)
{
int ret = MM_ERROR_NONE;
memset(stream_h, 0, sizeof(sound_stream_info_s));
ret = _convert_stream_type(stream_type, &stream_h->stream_type);
if (ret == MM_ERROR_NONE) {
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN( &g_stream_info_count_mutex, MM_ERROR_SOUND_INTERNAL);
+ SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, MM_ERROR_SOUND_INTERNAL);
ret = _make_pa_connection_and_register_focus(stream_h, callback, user_data);
if (ret == MM_ERROR_NONE) {
*stream_info = (sound_stream_info_h)stream_h;
}
SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
}
- if (ret) {
+ if (ret)
free(stream_h);
- }
}
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_destroy_stream_information (sound_stream_info_h stream_info)
+int sound_manager_destroy_stream_information(sound_stream_info_h stream_info)
{
int ret = MM_ERROR_NONE;
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
SM_INSTANCE_CHECK(stream_h);
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN( &g_stream_info_count_mutex, MM_ERROR_SOUND_INTERNAL);
+ SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, MM_ERROR_SOUND_INTERNAL);
ret = _destroy_pa_connection_and_unregister_focus(stream_h);
free(stream_h);
stream_h = NULL;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_add_device_for_stream_routing (sound_stream_info_h stream_info, sound_device_h device)
+int sound_manager_add_device_for_stream_routing(sound_stream_info_h stream_info, sound_device_h device)
{
int ret = MM_ERROR_NONE;
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_remove_device_for_stream_routing (sound_stream_info_h stream_info, sound_device_h device)
+int sound_manager_remove_device_for_stream_routing(sound_stream_info_h stream_info, sound_device_h device)
{
int ret = MM_ERROR_NONE;
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_apply_stream_routing (sound_stream_info_h stream_info)
+int sound_manager_apply_stream_routing(sound_stream_info_h stream_info)
{
int ret = MM_ERROR_NONE;
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_acquire_focus (sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *additional_info)
+int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *additional_info)
{
int ret = MM_ERROR_NONE;
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_release_focus (sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *additional_info)
+int sound_manager_release_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *additional_info)
{
int ret = MM_ERROR_NONE;
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_focus_state (sound_stream_info_h stream_info, sound_stream_focus_state_e *state_for_playback, sound_stream_focus_state_e *state_for_recording)
+int sound_manager_get_focus_state(sound_stream_info_h stream_info, sound_stream_focus_state_e *state_for_playback, sound_stream_focus_state_e *state_for_recording)
{
int ret = MM_ERROR_NONE;
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
ret = MM_ERROR_INVALID_ARGUMENT;
if (state_for_playback)
- *state_for_playback = (stream_h->acquired_focus & SOUND_STREAM_FOCUS_FOR_PLAYBACK)?SOUND_STREAM_FOCUS_STATE_ACQUIRED:SOUND_STREAM_FOCUS_STATE_RELEASED;
+ *state_for_playback = ((stream_h->acquired_focus & SOUND_STREAM_FOCUS_FOR_PLAYBACK) ? (SOUND_STREAM_FOCUS_STATE_ACQUIRED) : (SOUND_STREAM_FOCUS_STATE_RELEASED));
if (state_for_recording)
- *state_for_recording = (stream_h->acquired_focus & SOUND_STREAM_FOCUS_FOR_RECORDING)?SOUND_STREAM_FOCUS_STATE_ACQUIRED:SOUND_STREAM_FOCUS_STATE_RELEASED;
+ *state_for_recording = ((stream_h->acquired_focus & SOUND_STREAM_FOCUS_FOR_RECORDING) ? (SOUND_STREAM_FOCUS_STATE_ACQUIRED) : (SOUND_STREAM_FOCUS_STATE_RELEASED));
LOGI("<< leave : acquired_focus(%p)", stream_h->acquired_focus);
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_set_focus_state_watch_cb (sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_watch_cb callback, void *user_data)
+int sound_manager_set_focus_state_watch_cb(sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_watch_cb callback, void *user_data)
{
int ret = MM_ERROR_NONE;
int id = -1;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_unset_focus_state_watch_cb (void)
+int sound_manager_unset_focus_state_watch_cb(void)
{
int ret = MM_ERROR_NONE;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_set_session_type (sound_session_type_e type)
+int sound_manager_set_session_type(sound_session_type_e type)
{
int ret = MM_ERROR_NONE;
int cur_session = -1;
return SOUND_MANAGER_ERROR_NONE;
} else {
ret = mm_session_finish();
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return _convert_sound_manager_error_code(__func__, ret);
- }
+
g_session_interrupt_cb_table.is_registered = 0;
if (cur_session == MM_SESSION_TYPE_VOIP) {
g_cached_session_mode = -1;
g_cached_voip_device_id = -1;
if (g_voip_vstream_h) {
- _stop_virtual_stream (g_voip_vstream_h);
- _destroy_virtual_stream (g_voip_vstream_h);
+ _stop_virtual_stream(g_voip_vstream_h);
+ _destroy_virtual_stream(g_voip_vstream_h);
g_voip_vstream_h = NULL;
}
/*voip stream destruction*/
ret = _destroy_pa_connection_and_unregister_focus(g_voip_stream_info);
free(g_voip_stream_info);
g_voip_stream_info = NULL;
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return _convert_sound_manager_error_code(__func__, ret);
- }
}
}
}
}
ret = mm_session_init(new_session);
- if (ret == MM_ERROR_NONE) {
+ if (ret == MM_ERROR_NONE)
g_session_interrupt_cb_table.is_registered = 1;
- }
LOGI("<< leave : type=%d, ret=%p", type, ret);
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_session_type (sound_session_type_e *type)
+int sound_manager_get_session_type(sound_session_type_e *type)
{
int ret = MM_ERROR_NONE;
int cur_session;
LOGW("session hasn't been set, setting default session");
cur_session = SOUND_SESSION_TYPE_DEFAULT;
ret = mm_session_init(cur_session);
- if (ret == 0) {
+ if (ret == 0)
g_session_interrupt_cb_table.is_registered = 1;
- }
}
if ((cur_session > MM_SESSION_TYPE_EMERGENCY) &&
(cur_session != MM_SESSION_TYPE_VOIP)) {
if (g_cached_session != -1)
cur_session = g_cached_session;
- else //will be never reach here. just prevent code
+ else /* will be never reach here. just prevent code */
cur_session = SOUND_SESSION_TYPE_DEFAULT;
}
return 0;
}
-int sound_manager_set_media_session_option (sound_session_option_for_starting_e s_option, sound_session_option_for_during_play_e d_option)
+int sound_manager_set_media_session_option(sound_session_option_for_starting_e s_option, sound_session_option_for_during_play_e d_option)
{
int ret = MM_ERROR_NONE;
int session = 0;
if (ret != 0 || !g_session_interrupt_cb_table.is_registered) {
LOGW("session hasn't been set, setting default session");
ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
- if (ret == 0) {
+ if (ret == 0)
g_session_interrupt_cb_table.is_registered = 1;
- }
+
} else if (ret == 0 && session > MM_SESSION_TYPE_MEDIA) {
if (session == MM_SESSION_TYPE_MEDIA_RECORD) {
if (!g_session_interrupt_cb_table.is_registered) {
case SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START:
if (session_option & MM_SESSION_OPTION_PAUSE_OTHERS) {
ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_REMOVE, MM_SESSION_OPTION_PAUSE_OTHERS);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
+
updated = 1;
}
break;
case SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START:
if (!(session_option & MM_SESSION_OPTION_PAUSE_OTHERS)) {
ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_ADD, MM_SESSION_OPTION_PAUSE_OTHERS);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
+
updated = 1;
}
break;
case SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY:
if (session_option & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_REMOVE, MM_SESSION_OPTION_UNINTERRUPTIBLE);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
+
updated = 1;
}
break;
case SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY:
if (!(session_option & MM_SESSION_OPTION_UNINTERRUPTIBLE)) {
ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_ADD, MM_SESSION_OPTION_UNINTERRUPTIBLE);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
+
updated = 1;
}
break;
}
- if (updated) {
+ if (updated)
LOGI("<< leave : updated");
- } else {
+ else
LOGI("<< leave : already set same option(%x), skip it", session_option);
- }
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_media_session_option (sound_session_option_for_starting_e *s_option, sound_session_option_for_during_play_e *d_option)
+int sound_manager_get_media_session_option(sound_session_option_for_starting_e *s_option, sound_session_option_for_during_play_e *d_option)
{
int ret = MM_ERROR_NONE;
int session = 0;
ret = mm_session_get_current_information(&session, &session_options);
if (ret != 0) {
ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
- if (ret == 0) {
+ if (ret == 0)
g_session_interrupt_cb_table.is_registered = 1;
- }
+
} else if (session > SOUND_SESSION_TYPE_MEDIA) {
if (session == MM_SESSION_TYPE_MEDIA_RECORD) {
if (!g_session_interrupt_cb_table.is_registered) {
LOGE("Already set by camera/recorder/audio-io(in)/radio API, but need to set session to Media first");
return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
}
- } else {
+ } else
return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
- }
}
/* get option */
- if (session_options & MM_SESSION_OPTION_PAUSE_OTHERS) {
+ if (session_options & MM_SESSION_OPTION_PAUSE_OTHERS)
*s_option = SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START;
- } else {
+ else
*s_option = SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START;
- }
- if (session_options & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
+
+ if (session_options & MM_SESSION_OPTION_UNINTERRUPTIBLE)
*d_option = SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY;
- } else {
+ else
*d_option = SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY;
- }
LOGI("<< leave : option for starting=%d, for during play=%d", *s_option, *d_option);
return SOUND_MANAGER_ERROR_NONE;
}
-int sound_manager_set_media_session_resumption_option (sound_session_option_for_resumption_e option)
+int sound_manager_set_media_session_resumption_option(sound_session_option_for_resumption_e option)
{
int ret = MM_ERROR_NONE;
int session = 0;
if (ret != 0 || !g_session_interrupt_cb_table.is_registered) {
LOGW("session hasn't been set, setting default session");
ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
- if (ret == 0) {
+ if (ret == 0)
g_session_interrupt_cb_table.is_registered = 1;
- }
+
} else if (ret == 0 && session > MM_SESSION_TYPE_MEDIA) {
if (session == MM_SESSION_TYPE_MEDIA_RECORD) {
if (!g_session_interrupt_cb_table.is_registered) {
LOGE("Already set by camera/recorder/audio-io(in)/radio API, but need to set session to Media first");
return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
}
- } else {
+ } else
return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
- }
+
}
switch (option) {
case SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM:
if (session_option & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED) {
ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_REMOVE, MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
+
updated = 1;
}
break;
case SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED:
if (!(session_option & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED)) {
ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_ADD, MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
+
updated = 1;
}
break;
}
- if (updated) {
+ if (updated)
LOGI("<< leave : updated");
- } else {
+ else
LOGI("<< leave : already set same option(%x), skip it", session_option);
- }
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_media_session_resumption_option (sound_session_option_for_resumption_e *option)
+int sound_manager_get_media_session_resumption_option(sound_session_option_for_resumption_e *option)
{
int ret = MM_ERROR_NONE;
int session = 0;
if (ret != 0) {
LOGW("session hasn't been set, setting default session");
ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
- if (ret == 0) {
+ if (ret == 0)
g_session_interrupt_cb_table.is_registered = 1;
- }
+
} else if (session > SOUND_SESSION_TYPE_MEDIA) {
if (session == MM_SESSION_TYPE_MEDIA_RECORD) {
if (!g_session_interrupt_cb_table.is_registered) {
LOGE("Already set by camera/recorder/audio-io(in)/radio API, but need to set session to Media first");
return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
}
- } else {
+ } else
return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
- }
}
/* get option */
- if (session_options & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED) {
+ if (session_options & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED)
*option = SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED;
- } else {
+ else
*option = SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM;
- }
LOGI("<< leave : option for resumption=%d (0:by system, 1:by system or media paused)", *option);
return SOUND_MANAGER_ERROR_NONE;
}
-int sound_manager_set_voip_session_mode (sound_session_voip_mode_e mode)
+int sound_manager_set_voip_session_mode(sound_session_voip_mode_e mode)
{
int ret = MM_ERROR_NONE;
int session = 0;
LOGI(">> enter : mode=%d", mode);
ret = mm_session_get_current_information(&session, &session_options);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return _convert_sound_manager_error_code(__func__, ret);
- } else if (session != MM_SESSION_TYPE_VOIP) {
+ else if (session != MM_SESSION_TYPE_VOIP)
return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
- }
+
if (mode < SOUND_SESSION_VOIP_MODE_RINGTONE || mode > SOUND_SESSION_VOIP_MODE_VOICE_WITH_BLUETOOTH) {
ret = MM_ERROR_INVALID_ARGUMENT;
return _convert_sound_manager_error_code(__func__, ret);
}
- ret = _set_session_mode ((_session_mode_e)mode);
+ ret = _set_session_mode((_session_mode_e)mode);
LOGI("<< leave : session=%p, mode=%d, ret=%p", session, mode, ret);
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_voip_session_mode (sound_session_voip_mode_e *mode)
+int sound_manager_get_voip_session_mode(sound_session_voip_mode_e *mode)
{
int ret = MM_ERROR_NONE;
int session = 0;
if (ret != MM_ERROR_NONE) {
LOGI("session = %d, option = %d", session, session_options);
return _convert_sound_manager_error_code(__func__, ret);
- } else if (session != MM_SESSION_TYPE_VOIP || g_cached_session_mode == -1) {
+ } else if (session != MM_SESSION_TYPE_VOIP || g_cached_session_mode == -1)
return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
- }
*mode = (sound_session_voip_mode_e)g_cached_session_mode;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_set_session_interrupted_cb (sound_session_interrupted_cb callback, void *user_data)
+int sound_manager_set_session_interrupted_cb(sound_session_interrupted_cb callback, void *user_data)
{
int ret = MM_ERROR_NONE;
unsigned int subs_id = 0;
goto finish;
ret = mm_sound_focus_set_session_interrupt_callback((mm_sound_focus_session_interrupt_cb)_focus_session_interrupt_cb, NULL);
if (ret) {
- if(mm_sound_remove_device_connected_callback(subs_id) != MM_ERROR_NONE)
+ if (mm_sound_remove_device_connected_callback(subs_id) != MM_ERROR_NONE)
LOGW("mm_sound_remove_device_connected_callback failed");
goto finish;
}
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_unset_session_interrupted_cb (void)
+int sound_manager_unset_session_interrupted_cb(void)
{
int ret = MM_ERROR_NONE;
if (g_session_interrupt_cb_table.user_cb) {
ret = mm_sound_focus_unset_session_interrupt_callback();
if (ret) {
- if(mm_sound_remove_device_connected_callback(g_session_interrupt_cb_table.subs_id) != MM_ERROR_NONE)
+ if (mm_sound_remove_device_connected_callback(g_session_interrupt_cb_table.subs_id) != MM_ERROR_NONE)
LOGW("mm_sound_remove_device_connected_callback failed");
goto finish;
}
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_current_device_list (sound_device_mask_e device_mask, sound_device_list_h *device_list)
+int sound_manager_get_current_device_list(sound_device_mask_e device_mask, sound_device_list_h *device_list)
{
int ret = MM_ERROR_NONE;
ret = mm_sound_get_current_device_list((mm_sound_device_flags_e)device_mask, device_list);
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_next_device (sound_device_list_h device_list, sound_device_h *device)
+int sound_manager_get_next_device(sound_device_list_h device_list, sound_device_h *device)
{
int ret = MM_ERROR_NONE;
ret = mm_sound_get_next_device(device_list, device);
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_prev_device (sound_device_list_h device_list, sound_device_h *device)
+int sound_manager_get_prev_device(sound_device_list_h device_list, sound_device_h *device)
{
int ret = MM_ERROR_NONE;
ret = mm_sound_get_prev_device(device_list, device);
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_device_type (sound_device_h device, sound_device_type_e *type)
+int sound_manager_get_device_type(sound_device_h device, sound_device_type_e *type)
{
int ret = MM_ERROR_NONE;
ret = mm_sound_get_device_type(device, (mm_sound_device_type_e*)type);
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_device_io_direction (sound_device_h device, sound_device_io_direction_e *io_direction)
+int sound_manager_get_device_io_direction(sound_device_h device, sound_device_io_direction_e *io_direction)
{
int ret = MM_ERROR_NONE;
mm_sound_device_io_direction_e mm_sound_io_direction;
ret = mm_sound_get_device_io_direction(device, &mm_sound_io_direction);
- if (ret == MM_ERROR_NONE) {
+ if (ret == MM_ERROR_NONE)
ret = _convert_device_io_direction(mm_sound_io_direction, io_direction);
- }
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_device_id (sound_device_h device, int *id)
+int sound_manager_get_device_id(sound_device_h device, int *id)
{
int ret = MM_ERROR_NONE;
ret = mm_sound_get_device_id(device, id);
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_device_name (sound_device_h device, char **name)
+int sound_manager_get_device_name(sound_device_h device, char **name)
{
int ret = MM_ERROR_NONE;
ret = mm_sound_get_device_name(device, name);
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_device_state (sound_device_h device, sound_device_state_e *state)
+int sound_manager_get_device_state(sound_device_h device, sound_device_state_e *state)
{
int ret = MM_ERROR_NONE;
ret = mm_sound_get_device_state(device, (mm_sound_device_state_e*)state);
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_set_device_connected_cb (sound_device_mask_e device_mask, sound_device_connected_cb callback, void *user_data)
+int sound_manager_set_device_connected_cb(sound_device_mask_e device_mask, sound_device_connected_cb callback, void *user_data)
{
int ret = MM_ERROR_NONE;
unsigned int subs_id = 0;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_unset_device_connected_cb (void)
+int sound_manager_unset_device_connected_cb(void)
{
int ret = MM_ERROR_NONE;
g_device_connected_cb_table.user_cb = NULL;
g_device_connected_cb_table.user_data = NULL;
}
- } else {
+ } else
ret = MM_ERROR_SOUND_INTERNAL;
- }
SM_LEAVE_CRITICAL_SECTION(&g_device_conn_cb_mutex);
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_set_device_information_changed_cb (sound_device_mask_e device_mask, sound_device_information_changed_cb callback, void *user_data)
+int sound_manager_set_device_information_changed_cb(sound_device_mask_e device_mask, sound_device_information_changed_cb callback, void *user_data)
{
int ret = MM_ERROR_NONE;
unsigned int subs_id = 0;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_unset_device_information_changed_cb (void)
+int sound_manager_unset_device_information_changed_cb(void)
{
int ret = MM_ERROR_NONE;
}
__attribute__ ((destructor))
-void __sound_manager_finalize (void)
+void __sound_manager_finalize(void)
{
int ret = MM_ERROR_NONE;
if (g_session_interrupt_cb_table.is_registered) {
LOGI("<ENTER>");
ret = mm_session_finish();
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
LOGE("[%s] failed to mm_session_finish(), ret(%p)", __func__, ret);
- }
+
g_session_interrupt_cb_table.is_registered = 0;
LOGI("<LEAVE>");
}
}
__attribute__ ((constructor))
-void __sound_manager_initialize (void)
+void __sound_manager_initialize(void)
{
}
#include <sound_manager_internal.h>
#include <mm_sound.h>
-int sound_manager_create_stream_information_internal (sound_stream_type_internal_e stream_type, sound_stream_focus_state_changed_cb callback, void *user_data, sound_stream_info_h *stream_info)
+int sound_manager_create_stream_information_internal(sound_stream_type_internal_e stream_type, sound_stream_focus_state_changed_cb callback, void *user_data, sound_stream_info_h *stream_info)
{
int ret = MM_ERROR_NONE;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_set_stream_routing_option (sound_stream_info_h stream_info, const char *name, int value)
+int sound_manager_set_stream_routing_option(sound_stream_info_h stream_info, const char *name, int value)
{
int ret = MM_ERROR_NONE;
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_is_available_stream_information (sound_stream_info_h stream_info, native_api_e api_name, bool *is_available)
+int sound_manager_is_available_stream_information(sound_stream_info_h stream_info, native_api_e api_name, bool *is_available)
{
int ret = MM_ERROR_NONE;
int i = 0;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_type_from_stream_information (sound_stream_info_h stream_info, char **type)
+int sound_manager_get_type_from_stream_information(sound_stream_info_h stream_info, char **type)
{
int ret = MM_ERROR_NONE;
sound_stream_info_s* stream_h = (sound_stream_info_s*)stream_info;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_get_index_from_stream_information (sound_stream_info_h stream_info, int *index)
+int sound_manager_get_index_from_stream_information(sound_stream_info_h stream_info, int *index)
{
int ret = MM_ERROR_NONE;
sound_stream_info_s* stream_h = (sound_stream_info_s*)stream_info;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_create_virtual_stream (sound_stream_info_h stream_info, virtual_sound_stream_h *virtual_stream)
+int sound_manager_create_virtual_stream(sound_stream_info_h stream_info, virtual_sound_stream_h *virtual_stream)
{
int ret = MM_ERROR_NONE;
virtual_sound_stream_info_s *vstream_h = NULL;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_destroy_virtual_stream (virtual_sound_stream_h virtual_stream)
+int sound_manager_destroy_virtual_stream(virtual_sound_stream_h virtual_stream)
{
int ret = MM_ERROR_NONE;
virtual_sound_stream_info_s *vstream_h = (virtual_sound_stream_info_s*)virtual_stream;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_start_virtual_stream (virtual_sound_stream_h virtual_stream)
+int sound_manager_start_virtual_stream(virtual_sound_stream_h virtual_stream)
{
int ret = MM_ERROR_NONE;
virtual_sound_stream_info_s *vstream_h = (virtual_sound_stream_info_s*)virtual_stream;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_stop_virtual_stream (virtual_sound_stream_h virtual_stream)
+int sound_manager_stop_virtual_stream(virtual_sound_stream_h virtual_stream)
{
int ret = MM_ERROR_NONE;
virtual_sound_stream_info_s *vstream_h = (virtual_sound_stream_info_s*)virtual_stream;
int g_stream_info_count = 0;
pthread_mutex_t g_stream_info_count_mutex = PTHREAD_MUTEX_INITIALIZER;
-int _convert_sound_manager_error_code (const char *func, int code) {
+int _convert_sound_manager_error_code(const char *func, int code)
+{
int ret = SOUND_MANAGER_ERROR_NONE;
char *errorstr = NULL;
- switch(code) {
+ switch (code) {
case MM_ERROR_FILE_WRITE:
case MM_ERROR_INVALID_HANDLE:
ret = SOUND_MANAGER_ERROR_INVALID_OPERATION;
errorstr = "INVALID_STATE";
break;
}
- if (ret) {
- LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)",func, errorstr, ret, code);
- } else {
- LOGD("[%s] %s(0x%08x) : core frameworks error code(0x%08x)",func, errorstr, ret, code);
- }
+ if (ret)
+ LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)", func, errorstr, ret, code);
+ else
+ LOGD("[%s] %s(0x%08x) : core frameworks error code(0x%08x)", func, errorstr, ret, code);
+
return ret;
}
-int _convert_stream_type (sound_stream_type_e stream_type_enum, char **stream_type)
+int _convert_stream_type(sound_stream_type_e stream_type_enum, char **stream_type)
{
int ret = MM_ERROR_NONE;
- if (stream_type == NULL) {
+ if (stream_type == NULL)
return MM_ERROR_INVALID_ARGUMENT;
- }
switch (stream_type_enum) {
case SOUND_STREAM_TYPE_MEDIA:
return ret;
}
-int _convert_stream_type_for_internal (sound_stream_type_internal_e stream_type_enum, char **stream_type)
+int _convert_stream_type_for_internal(sound_stream_type_internal_e stream_type_enum, char **stream_type)
{
int ret = MM_ERROR_NONE;
- if (stream_type == NULL) {
+ if (stream_type == NULL)
return MM_ERROR_INVALID_ARGUMENT;
- }
switch (stream_type_enum) {
case SOUND_STREAM_TYPE_RINGTONE_CALL:
return ret;
}
-int _convert_stream_type_to_change_reason (const char *stream_type, sound_stream_focus_change_reason_e *change_reason)
+int _convert_stream_type_to_change_reason(const char *stream_type, sound_stream_focus_change_reason_e *change_reason)
{
int ret = MM_ERROR_NONE;
return ret;
}
-static int _convert_stream_type_to_interrupt_reason (const char *stream_type, sound_session_interrupted_code_e *change_reason)
+static int _convert_stream_type_to_interrupt_reason(const char *stream_type, sound_session_interrupted_code_e *change_reason)
{
int ret = MM_ERROR_NONE;
return ret;
}
-int _convert_sound_type (sound_type_e sound_type, const char **volume_type)
+int _convert_sound_type(sound_type_e sound_type, const char **volume_type)
{
int ret = MM_ERROR_NONE;
return ret;
}
-int _convert_sound_type_to_enum (char *sound_type, sound_type_e *sound_type_enum)
+int _convert_sound_type_to_enum(char *sound_type, sound_type_e *sound_type_enum)
{
int ret = MM_ERROR_NONE;
return ret;
}
-int _convert_device_type (sound_device_type_e device_type_enum, char **device_type)
+int _convert_device_type(sound_device_type_e device_type_enum, char **device_type)
{
int ret = MM_ERROR_NONE;
*device_type = "forwarding";
break;
}
- if (!strncmp(*device_type,"",SOUND_DEVICE_TYPE_LEN)) {
+ if (!strncmp(*device_type, "", SOUND_DEVICE_TYPE_LEN)) {
LOGE("could not find the device_type[%d] in this switch case statement", device_type_enum);
ret = MM_ERROR_SOUND_INTERNAL;
- } else {
+ } else
LOGI("device_type[%s]", *device_type);
- }
+
return ret;
}
-int _convert_device_io_direction (mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *sound_io_direction)
+int _convert_device_io_direction(mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *sound_io_direction)
{
int ret = MM_ERROR_NONE;
return ret;
}
-const char* _convert_api_name (native_api_e api_name)
+const char* _convert_api_name(native_api_e api_name)
{
const char* name = NULL;
switch (api_name) {
return name;
}
-void _focus_state_change_callback (int index, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data)
+void _focus_state_change_callback(int index, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data)
{
int ret = MM_ERROR_NONE;
int i = 0;
} else {
for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++) {
if (sound_stream_info_arr[i] && sound_stream_info_arr[i]->index == index) {
- if (state == FOCUS_IS_RELEASED) {
+ if (state == FOCUS_IS_RELEASED)
sound_stream_info_arr[i]->acquired_focus &= ~focus_type;
- } else if (state == FOCUS_IS_ACQUIRED) {
+ else if (state == FOCUS_IS_ACQUIRED)
sound_stream_info_arr[i]->acquired_focus |= focus_type;
- }
+
LOGI("[FOCUS USER CALLBACK(%p) START]", sound_stream_info_arr[i]->user_cb);
sound_stream_info_arr[i]->user_cb((sound_stream_info_h)sound_stream_info_arr[i], change_reason, additional_info, sound_stream_info_arr[i]->user_data);
LOGI("[FOCUS USER CALLBACK(%p) END]", sound_stream_info_arr[i]->user_cb);
break;
}
}
- if (i == SOUND_STREAM_INFO_ARR_MAX) {
+ if (i == SOUND_STREAM_INFO_ARR_MAX)
LOGE("could not find index(%d), failed to call user callback", index);
- }
}
LOGI("<< leave");
return;
}
-void _focus_watch_callback (int index, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data)
+void _focus_watch_callback(int index, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data)
{
int ret = MM_ERROR_NONE;
sound_stream_focus_change_reason_e change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA;
return;
}
-void _pa_context_state_cb (pa_context *c, void *userdata)
+void _pa_context_state_cb(pa_context *c, void *userdata)
{
pa_context_state_t state;
sound_stream_info_s *stream_info_h = (sound_stream_info_s*)userdata;
assert(c);
state = pa_context_get_state(c);
- LOGI ("[%p] context state = [%d]", stream_info_h, state);
+ LOGI("[%p] context state = [%d]", stream_info_h, state);
switch (state) {
case PA_CONTEXT_READY:
case PA_CONTEXT_TERMINATED:
}
}
-void _pa_stream_state_cb (pa_stream *s, void * userdata)
+void _pa_stream_state_cb(pa_stream *s, void * userdata)
{
pa_stream_state_t state;
virtual_sound_stream_info_s *vstream_h = (virtual_sound_stream_info_s*)userdata;
assert(s);
state = pa_stream_get_state(s);
- LOGI ("[%p] stream [%d] state = [%d]", vstream_h, pa_stream_get_index(s), state);
+ LOGI("[%p] stream [%d] state = [%d]", vstream_h, pa_stream_get_index(s), state);
switch (state) {
case PA_STREAM_READY:
}
}
-int _get_stream_conf_info (const char *stream_type, stream_conf_info_s *info)
+int _get_stream_conf_info(const char *stream_type, stream_conf_info_s *info)
{
int ret = MM_ERROR_NONE;
GVariant *result = NULL;
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn && err) {
LOGE("g_bus_get_sync() error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
return MM_ERROR_SOUND_INTERNAL;
}
- result = g_dbus_connection_call_sync (conn,
+ result = g_dbus_connection_call_sync(conn,
PA_BUS_NAME,
PA_STREAM_MANAGER_OBJECT_PATH,
PA_STREAM_MANAGER_INTERFACE,
PA_STREAM_MANAGER_METHOD_NAME_GET_STREAM_INFO,
- g_variant_new ("(s)", stream_type),
+ g_variant_new("(s)", stream_type),
G_VARIANT_TYPE("(vvvvv)"),
G_DBUS_CALL_FLAGS_NONE,
2000,
&err);
if (!result && err) {
LOGE("g_dbus_connection_call_sync() for GET_STREAM_INFO error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
ret = MM_ERROR_SOUND_INTERNAL;
} else {
GVariantIter iter;
child = g_variant_get_child_value(result, 0);
item = g_variant_get_variant(child);
info->priority = g_variant_get_int32(item);
- g_variant_unref (item);
- g_variant_unref (child);
- LOGI ("priority(%d)", info->priority);
+ g_variant_unref(item);
+ g_variant_unref(child);
+ LOGI("priority(%d)", info->priority);
/* get route type */
child = g_variant_get_child_value(result, 1);
item = g_variant_get_variant(child);
info->route_type = g_variant_get_int32(item);
- g_variant_unref (item);
- g_variant_unref (child);
- LOGI ("route_type(%d)", info->route_type);
+ g_variant_unref(item);
+ g_variant_unref(child);
+ LOGI("route_type(%d)", info->route_type);
/* get availabe in-devices */
child = g_variant_get_child_value(result, 2);
item = g_variant_get_variant(child);
size = g_variant_n_children(item);
- LOGI ("num of avail-in-devices are %d", size);
+ LOGI("num of avail-in-devices are %d", size);
g_variant_iter_init(&iter, item);
i = 0;
while (g_variant_iter_loop(&iter, "&s", &name)) {
- if (size == 1 && !strncmp (name, "none", strlen("none"))) {
- LOGI (" in-device is [%s], skip it", name);
+ if (size == 1 && !strncmp(name, "none", strlen("none"))) {
+ LOGI(" in-device is [%s], skip it", name);
break;
} else {
- LOGI (" in-device name : %s", name);
+ LOGI(" in-device name : %s", name);
info->avail_in_devices[i++] = strdup(name);
}
}
- g_variant_iter_free (&iter);
- g_variant_unref (item);
- g_variant_unref (child);
+ g_variant_iter_free(&iter);
+ g_variant_unref(item);
+ g_variant_unref(child);
/* get available out-devices */
child = g_variant_get_child_value(result, 3);
item = g_variant_get_variant(child);
size = g_variant_n_children(item);
- LOGI ("num of avail-out-devices are %d", size);
+ LOGI("num of avail-out-devices are %d", size);
g_variant_iter_init(&iter, item);
i = 0;
while (g_variant_iter_loop(&iter, "&s", &name)) {
- if (size == 1 && !strncmp (name, "none", strlen("none"))) {
- LOGI (" out-device is [%s], skip it", name);
+ if (size == 1 && !strncmp(name, "none", strlen("none"))) {
+ LOGI(" out-device is [%s], skip it", name);
break;
} else {
- LOGI (" out-device name : %s", name);
+ LOGI(" out-device name : %s", name);
info->avail_out_devices[i++] = strdup(name);
}
}
- g_variant_iter_free (&iter);
- g_variant_unref (item);
- g_variant_unref (child);
+ g_variant_iter_free(&iter);
+ g_variant_unref(item);
+ g_variant_unref(child);
/* get available frameworks */
child = g_variant_get_child_value(result, 4);
item = g_variant_get_variant(child);
size = g_variant_n_children(item);
- LOGI ("num of avail-frameworks are %d", size);
+ LOGI("num of avail-frameworks are %d", size);
g_variant_iter_init(&iter, item);
i = 0;
while (g_variant_iter_loop(&iter, "&s", &name)) {
- if (size == 1 && !strncmp (name, "none", strlen("none"))) {
- LOGI (" framework is [%s], skip it", name);
+ if (size == 1 && !strncmp(name, "none", strlen("none"))) {
+ LOGI(" framework is [%s], skip it", name);
break;
} else {
- LOGI (" framework name : %s", name);
+ LOGI(" framework name : %s", name);
info->avail_frameworks[i++] = strdup(name);
}
}
- g_variant_iter_free (&iter);
- g_variant_unref (item);
- g_variant_unref (child);
+ g_variant_iter_free(&iter);
+ g_variant_unref(item);
+ g_variant_unref(child);
g_variant_unref(result);
}
g_object_unref(conn);
return ret;
}
-int _set_manual_route_info (unsigned int index, manual_route_info_s *info)
+int _set_manual_route_info(unsigned int index, manual_route_info_s *info)
{
int ret = MM_ERROR_NONE;
int i = 0;
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn && err) {
LOGE("g_bus_get_sync() error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
return MM_ERROR_SOUND_INTERNAL;
}
}
}
- result = g_dbus_connection_call_sync (conn,
+ result = g_dbus_connection_call_sync(conn,
PA_BUS_NAME,
PA_STREAM_MANAGER_OBJECT_PATH,
PA_STREAM_MANAGER_INTERFACE,
PA_STREAM_MANAGER_METHOD_NAME_SET_STREAM_ROUTE_DEVICES,
- g_variant_new ("(uauau)", index, builder_for_in_devices, builder_for_out_devices),
+ g_variant_new("(uauau)", index, builder_for_in_devices, builder_for_out_devices),
G_VARIANT_TYPE("(s)"),
G_DBUS_CALL_FLAGS_NONE,
2000,
&err);
if (!result && err) {
LOGE("g_dbus_connection_call_sync() for SET_STREAM_ROUTE_DEVICES error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
ret = MM_ERROR_SOUND_INTERNAL;
} else {
const gchar *dbus_ret = NULL;
g_variant_get(result, "(&s)", &dbus_ret);
LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
- if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
+ if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
ret = MM_ERROR_SOUND_INVALID_STATE;
- } else {
+ else
info->is_set = true;
- }
+
g_variant_unref(result);
}
g_variant_builder_unref(builder_for_in_devices);
return ret;
}
-int _set_route_option (unsigned int index, const char *name, int value)
+int _set_route_option(unsigned int index, const char *name, int value)
{
int ret = MM_ERROR_NONE;
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn && err) {
LOGE("g_bus_get_sync() error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
return MM_ERROR_SOUND_INTERNAL;
}
LOGI("[OPTION] %s(%d)", name, value);
- result = g_dbus_connection_call_sync (conn,
+ result = g_dbus_connection_call_sync(conn,
PA_BUS_NAME,
PA_STREAM_MANAGER_OBJECT_PATH,
PA_STREAM_MANAGER_INTERFACE,
PA_STREAM_MANAGER_METHOD_NAME_SET_STREAM_ROUTE_OPTION,
- g_variant_new ("(usi)", index, name, value),
+ g_variant_new("(usi)", index, name, value),
G_VARIANT_TYPE("(s)"),
G_DBUS_CALL_FLAGS_NONE,
2000,
&err);
if (!result && err) {
LOGE("g_dbus_connection_call_sync() for SET_STREAM_ROUTE_OPTION error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
ret = MM_ERROR_SOUND_INTERNAL;
} else {
const gchar *dbus_ret = NULL;
g_variant_get(result, "(&s)", &dbus_ret);
LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
- if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret))) {
+ if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret)))
ret = MM_ERROR_SOUND_INVALID_STATE;
- } else if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
+ else if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
ret = MM_ERROR_SOUND_INTERNAL;
- }
+
g_variant_unref(result);
}
g_object_unref(conn);
return ret;
}
-int _get_volume_max_level (const char *direction, const char *volume_type, unsigned int *max_level)
+int _get_volume_max_level(const char *direction, const char *volume_type, unsigned int *max_level)
{
int ret = MM_ERROR_NONE;
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn && err) {
LOGE("g_bus_get_sync() error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
return MM_ERROR_SOUND_INTERNAL;
}
- result = g_dbus_connection_call_sync (conn,
+ result = g_dbus_connection_call_sync(conn,
PA_BUS_NAME,
PA_STREAM_MANAGER_OBJECT_PATH,
PA_STREAM_MANAGER_INTERFACE,
PA_STREAM_MANAGER_METHOD_NAME_GET_VOLUME_MAX_LEVEL,
- g_variant_new ("(ss)", direction, volume_type),
+ g_variant_new("(ss)", direction, volume_type),
G_VARIANT_TYPE("(us)"),
G_DBUS_CALL_FLAGS_NONE,
2000,
&err);
if (!result && err) {
LOGE("g_dbus_connection_call_sync() for GET_VOLUME_MAX_LEVEL error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
ret = MM_ERROR_SOUND_INTERNAL;
} else {
const gchar *dbus_ret = NULL;
g_variant_get(result, "(u&s)", max_level, &dbus_ret);
LOGI("g_dbus_connection_call_sync() success, method return value is (%u, %s)", *max_level, dbus_ret);
- if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
+ if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
ret = MM_ERROR_SOUND_INTERNAL;
- }
+
g_variant_unref(result);
}
g_object_unref(conn);
return ret;
}
-int _get_current_volume_type (const char *direction, char **volume_type)
+int _get_current_volume_type(const char *direction, char **volume_type)
{
int ret = MM_ERROR_NONE;
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn && err) {
LOGE("g_bus_get_sync() error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
return MM_ERROR_SOUND_INTERNAL;
}
- result = g_dbus_connection_call_sync (conn,
+ result = g_dbus_connection_call_sync(conn,
PA_BUS_NAME,
PA_STREAM_MANAGER_OBJECT_PATH,
PA_STREAM_MANAGER_INTERFACE,
PA_STREAM_MANAGER_METHOD_NAME_GET_CURRENT_VOLUME_TYPE,
- g_variant_new ("(s)", direction),
+ g_variant_new("(s)", direction),
G_VARIANT_TYPE("(ss)"),
G_DBUS_CALL_FLAGS_NONE,
2000,
&err);
if (!result && err) {
LOGE("g_dbus_connection_call_sync() for GET_CURRENT_VOLUME_TYPE error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
ret = MM_ERROR_SOUND_INTERNAL;
} else {
const gchar *dbus_volume_type = NULL;
if (!strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
ret = MM_ERROR_NONE;
*volume_type = strdup(dbus_volume_type);
- } else if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret))) {
+ } else if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret)))
ret = MM_ERROR_SOUND_VOLUME_NO_INSTANCE;
- } else {
+ else
ret = MM_ERROR_SOUND_INTERNAL;
- }
+
g_variant_unref(result);
}
g_object_unref(conn);
return ret;
}
-void _update_focus_status (unsigned int index, unsigned int acquired_focus_status)
+void _update_focus_status(unsigned int index, unsigned int acquired_focus_status)
{
GVariant *result = NULL;
GDBusConnection *conn = NULL;
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn && err) {
LOGE("g_bus_get_sync() error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
return;
}
- result = g_dbus_connection_call_sync (conn,
+ result = g_dbus_connection_call_sync(conn,
PA_BUS_NAME,
PA_STREAM_MANAGER_OBJECT_PATH,
PA_STREAM_MANAGER_INTERFACE,
PA_STREAM_MANAGER_METHOD_NAME_UPDATE_FOCUS_STATUS,
- g_variant_new ("(uu)", index, acquired_focus_status),
+ g_variant_new("(uu)", index, acquired_focus_status),
G_VARIANT_TYPE("(s)"),
G_DBUS_CALL_FLAGS_NONE,
2000,
&err);
if (!result && err) {
LOGE("g_dbus_connection_call_sync() for UPDATE_FOCUS_STATUS error (%s)", err->message);
- g_error_free (err);
+ g_error_free(err);
} else {
const gchar *dbus_ret = NULL;
g_variant_get(result, "(&s)", &dbus_ret);
LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
- if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
- }
+ if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret)))
+ LOGE("failed to UPDATE_FOCUS_STATUS error (%s)", dbus_ret);
+
g_variant_unref(result);
}
g_object_unref(conn);
return;
}
-void _focus_session_interrupt_cb (mm_sound_focus_state_e state, const char *reason_for_change, bool is_wcb, void *user_data)
+void _focus_session_interrupt_cb(mm_sound_focus_state_e state, const char *reason_for_change, bool is_wcb, void *user_data)
{
sound_session_interrupted_code_e e;
LOGE("session interrupted by [%s]", reason_for_change);
if (g_session_interrupt_cb_table.user_cb) {
if (is_wcb) {
- if (state == FOCUS_IS_RELEASED) {
+ if (state == FOCUS_IS_RELEASED)
e = SOUND_SESSION_INTERRUPTED_COMPLETED;
- } else {
+ else
_convert_stream_type_to_interrupt_reason(reason_for_change, &e);
- }
} else {
- if (state == FOCUS_IS_ACQUIRED) {
+ if (state == FOCUS_IS_ACQUIRED)
e = SOUND_SESSION_INTERRUPTED_COMPLETED;
- } else {
+ else
_convert_stream_type_to_interrupt_reason(reason_for_change, &e);
- }
}
g_session_interrupt_cb_table.user_cb(e, g_session_interrupt_cb_table.user_data);
}
void _device_connected_cb(sound_device_h device, bool is_connected, void *user_data)
{
mm_sound_device_type_e type;
- if (mm_sound_get_device_type (device, &type) != MM_ERROR_NONE) {
+ if (mm_sound_get_device_type(device, &type) != MM_ERROR_NONE)
LOGE("getting device type failed");
- } else {
+ else {
switch (type) {
- case MM_SOUND_DEVICE_TYPE_AUDIOJACK:
- case MM_SOUND_DEVICE_TYPE_BLUETOOTH:
- case MM_SOUND_DEVICE_TYPE_HDMI:
- case MM_SOUND_DEVICE_TYPE_MIRRORING:
- case MM_SOUND_DEVICE_TYPE_USB_AUDIO:
- if (!is_connected) {
- LOGI("sound device unplugged");
- g_session_interrupt_cb_table.user_cb(SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG, g_session_interrupt_cb_table.user_data);
- }
- break;
- default:
- break;
+ case MM_SOUND_DEVICE_TYPE_AUDIOJACK:
+ case MM_SOUND_DEVICE_TYPE_BLUETOOTH:
+ case MM_SOUND_DEVICE_TYPE_HDMI:
+ case MM_SOUND_DEVICE_TYPE_MIRRORING:
+ case MM_SOUND_DEVICE_TYPE_USB_AUDIO:
+ if (!is_connected) {
+ LOGI("sound device unplugged");
+ g_session_interrupt_cb_table.user_cb(SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG, g_session_interrupt_cb_table.user_data);
+ }
+ break;
+ default:
+ break;
}
}
}
/* This is an internal callback for the VOIP SESSION */
-void _voip_focus_state_change_callback (sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data)
+void _voip_focus_state_change_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data)
{
sound_stream_info_s *info = (sound_stream_info_s *)stream_info;
LOGI(">> enter, stream_info(%p), change_reason(%d), additional_info(%s)", stream_info, reason_for_change, additional_info);
}
if (!(info->acquired_focus & SOUND_STREAM_FOCUS_FOR_PLAYBACK) ||
- !(info->acquired_focus & SOUND_STREAM_FOCUS_FOR_RECORDING) ) {
+ !(info->acquired_focus & SOUND_STREAM_FOCUS_FOR_RECORDING)) {
/* stop virtual stream for rintone-voip or voip */
if (g_voip_vstream_h) {
/* stop virtual stream handle */
return;
}
-int _set_session_mode (_session_mode_e mode)
+int _set_session_mode(_session_mode_e mode)
{
int ret = MM_ERROR_NONE;
int w_ret = MM_ERROR_NONE;
}
switch (mode) {
- case _SESSION_MODE_RINGTONE:
- if (g_voip_vstream_h) {
- /* stop vstream and destroy vstream */
- _stop_virtual_stream(g_voip_vstream_h);
- _destroy_virtual_stream(g_voip_vstream_h);
- g_voip_vstream_h = NULL;
- /* destroy stream info */
- _destroy_pa_connection_and_unregister_focus(g_voip_stream_info);
- free(g_voip_stream_info);
- g_voip_stream_info = NULL;
+ case _SESSION_MODE_RINGTONE:
+ if (g_voip_vstream_h) {
+ /* stop vstream and destroy vstream */
+ _stop_virtual_stream(g_voip_vstream_h);
+ _destroy_virtual_stream(g_voip_vstream_h);
+ g_voip_vstream_h = NULL;
+ /* destroy stream info */
+ _destroy_pa_connection_and_unregister_focus(g_voip_stream_info);
+ free(g_voip_stream_info);
+ g_voip_stream_info = NULL;
+ }
+ if (!g_voip_stream_info) {
+ g_voip_stream_info = malloc(sizeof(sound_stream_info_s));
+ if (!g_voip_stream_info) {
+ ret = MM_ERROR_OUT_OF_MEMORY;
+ goto ERROR_CASE;
+ }
+ memset(g_voip_stream_info, 0, sizeof(sound_stream_info_s));
+ }
+ /* create stream info and acquire focus for rintone-voip stream */
+ g_voip_stream_info->stream_type = "ringtone-voip";
+ ret = _make_pa_connection_and_register_focus(g_voip_stream_info, _voip_focus_state_change_callback, NULL);
+ if (ret != MM_ERROR_NONE) {
+ free(g_voip_stream_info);
+ g_voip_stream_info = NULL;
+ goto ERROR_CASE;
+ } else {
+ /* acquire focus */
+ ret = mm_sound_acquire_focus(g_voip_stream_info->index, FOCUS_FOR_BOTH, "for voip session");
+ if (ret == MM_ERROR_NONE) {
+ g_voip_stream_info->acquired_focus |= FOCUS_FOR_BOTH;
+ _update_focus_status(g_voip_stream_info->index, (unsigned int)g_voip_stream_info->acquired_focus);
+ } else
+ goto ERROR_CASE;
+
+ }
+ /* create virtual stream for ringtone-voip */
+ i_ret = _create_virtual_stream(g_voip_stream_info, &g_voip_vstream_h);
+ if (i_ret == SOUND_MANAGER_ERROR_NONE) {
+ i_ret = _start_virtual_stream(g_voip_vstream_h);
+ if (i_ret != SOUND_MANAGER_ERROR_NONE)
+ goto ERROR_CASE;
+ } else {
+ ret = MM_ERROR_SOUND_INTERNAL;
+ 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: /* Bluetooth spk & mic */
+ /* check if the device is available now */
+ ret = mm_sound_get_current_device_list(MM_SOUND_DEVICE_ALL_FLAG, &device_list);
+ if (ret != MM_ERROR_NONE) {
+ LOGE("failed to get current device list");
+ goto ERROR_CASE;
+ } else {
+ while (!is_found && ((w_ret = mm_sound_get_next_device(device_list, &tmp_device)) == MM_ERROR_NONE)) {
+ ret = mm_sound_get_device_type(tmp_device, &type);
+ if (ret != MM_ERROR_NONE)
+ goto ERROR_CASE;
+ ret = mm_sound_get_device_id(tmp_device, &id);
+ if (ret != MM_ERROR_NONE)
+ goto ERROR_CASE;
+ else {
+ if (g_cached_voip_device_id != -1 && g_cached_voip_device_id == id)
+ prev_device = tmp_device;
+ }
+ switch (mode) {
+ case _SESSION_MODE_VOICE_WITH_BUILTIN_RECEIVER:
+ if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER) {
+ is_found = true;
+ proper_device = tmp_device;
+ break;
+ }
+ case _SESSION_MODE_VOICE_WITH_BUILTIN_SPEAKER:
+ if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER) {
+ is_found = true;
+ proper_device = tmp_device;
+ break;
+ }
+ case _SESSION_MODE_VOICE_WITH_AUDIO_JACK:
+ if (type == MM_SOUND_DEVICE_TYPE_AUDIOJACK) {
+ is_found = true;
+ proper_device = tmp_device;
+ break;
+ }
+ break;
+ case _SESSION_MODE_VOICE_WITH_BLUETOOTH:
+ if (type == MM_SOUND_DEVICE_TYPE_BLUETOOTH) {
+ is_found = true;
+ proper_device = tmp_device;
+ break;
+ }
+ default:
+ break;
+ }
}
+ if (!is_found) {
+ LOGE("could not found a proper connected device for this mode(%d)", mode);
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto ERROR_CASE_NO_DESTROY;
+ }
+ }
+ /* if ok for the device, go below */
+ if (g_cached_session_mode == _SESSION_MODE_RINGTONE) {
+ /* stop vstream and destroy vstream */
+ _stop_virtual_stream(g_voip_vstream_h);
+ _destroy_virtual_stream(g_voip_vstream_h);
+ g_voip_vstream_h = NULL;
+ /* destroy stream info */
+ _destroy_pa_connection_and_unregister_focus(g_voip_stream_info);
+ free(g_voip_stream_info);
+ g_voip_stream_info = NULL;
+ }
+ /* create stream info and acquire focus for voip stream */
+ if (g_cached_session_mode == -1 || g_cached_session_mode == _SESSION_MODE_RINGTONE) {
if (!g_voip_stream_info) {
g_voip_stream_info = malloc(sizeof(sound_stream_info_s));
if (!g_voip_stream_info) {
}
memset(g_voip_stream_info, 0, sizeof(sound_stream_info_s));
}
- /* create stream info and acquire focus for rintone-voip stream */
- g_voip_stream_info->stream_type = "ringtone-voip";
+ g_voip_stream_info->stream_type = "voip";
ret = _make_pa_connection_and_register_focus(g_voip_stream_info, _voip_focus_state_change_callback, NULL);
if (ret != MM_ERROR_NONE) {
free(g_voip_stream_info);
g_voip_stream_info = NULL;
goto ERROR_CASE;
- } else {
- /* acquire focus */
- ret = mm_sound_acquire_focus(g_voip_stream_info->index, FOCUS_FOR_BOTH, "for voip session");
- if (ret == MM_ERROR_NONE) {
- g_voip_stream_info->acquired_focus |= FOCUS_FOR_BOTH;
- _update_focus_status(g_voip_stream_info->index, (unsigned int)g_voip_stream_info->acquired_focus);
- } else {
- goto ERROR_CASE;
- }
}
- /* create virtual stream for ringtone-voip */
- i_ret = _create_virtual_stream (g_voip_stream_info, &g_voip_vstream_h);
+ /* set device for routing to the device */
+ i_ret = _add_device_for_stream_routing(g_voip_stream_info, proper_device);
if (i_ret == SOUND_MANAGER_ERROR_NONE) {
- i_ret = _start_virtual_stream (g_voip_vstream_h);
- if (i_ret != SOUND_MANAGER_ERROR_NONE) {
+ i_ret = _apply_stream_routing(g_voip_stream_info);
+ if (i_ret != SOUND_MANAGER_ERROR_NONE)
goto ERROR_CASE;
- }
- } else {
- ret = MM_ERROR_SOUND_INTERNAL;
+ } else
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: /* Bluetooth spk & mic */
- /* check if the device is available now */
- ret = mm_sound_get_current_device_list(MM_SOUND_DEVICE_ALL_FLAG, &device_list);
- if (ret != MM_ERROR_NONE) {
- LOGE("failed to get current device list");
+
+ /* acquire focus */
+ ret = mm_sound_acquire_focus(g_voip_stream_info->index, FOCUS_FOR_BOTH, "for voip session");
+ if (ret == MM_ERROR_NONE) {
+ g_voip_stream_info->acquired_focus |= FOCUS_FOR_BOTH;
+ _update_focus_status(g_voip_stream_info->index, (unsigned int)g_voip_stream_info->acquired_focus);
+ } else
goto ERROR_CASE;
- } else {
- while (!is_found && ((w_ret = mm_sound_get_next_device(device_list, &tmp_device)) == MM_ERROR_NONE)) {
- ret = mm_sound_get_device_type(tmp_device, &type);
- if (ret != MM_ERROR_NONE) {
- goto ERROR_CASE;
- }
- ret = mm_sound_get_device_id(tmp_device, &id);
- if (ret != MM_ERROR_NONE) {
- goto ERROR_CASE;
- } else {
- if (g_cached_voip_device_id != -1 && g_cached_voip_device_id == id) {
- prev_device = tmp_device;
- }
- }
- switch (mode) {
- case _SESSION_MODE_VOICE_WITH_BUILTIN_RECEIVER:
- if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER) {
- is_found = true;
- proper_device = tmp_device;
- break;
- }
- case _SESSION_MODE_VOICE_WITH_BUILTIN_SPEAKER:
- if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER) {
- is_found = true;
- proper_device = tmp_device;
- break;
- }
- case _SESSION_MODE_VOICE_WITH_AUDIO_JACK:
- if (type == MM_SOUND_DEVICE_TYPE_AUDIOJACK) {
- is_found = true;
- proper_device = tmp_device;
- break;
- }
- break;
- case _SESSION_MODE_VOICE_WITH_BLUETOOTH:
- if (type == MM_SOUND_DEVICE_TYPE_BLUETOOTH) {
- is_found = true;
- proper_device = tmp_device;
- break;
- }
- default:
- break;
- }
- }
- if (!is_found) {
- LOGE("could not found a proper connected device for this mode(%d)", mode);
- ret = MM_ERROR_SOUND_INTERNAL;
- goto ERROR_CASE_NO_DESTROY;
- }
- }
- /* if ok for the device, go below */
- if (g_cached_session_mode == _SESSION_MODE_RINGTONE) {
- /* stop vstream and destroy vstream */
- _stop_virtual_stream(g_voip_vstream_h);
- _destroy_virtual_stream(g_voip_vstream_h);
- g_voip_vstream_h = NULL;
- /* destroy stream info */
- _destroy_pa_connection_and_unregister_focus(g_voip_stream_info);
- free(g_voip_stream_info);
- g_voip_stream_info = NULL;
- }
- /* create stream info and acquire focus for voip stream */
- if (g_cached_session_mode == -1 || g_cached_session_mode == _SESSION_MODE_RINGTONE) {
- if (!g_voip_stream_info) {
- g_voip_stream_info = malloc(sizeof(sound_stream_info_s));
- if (!g_voip_stream_info) {
- ret = MM_ERROR_OUT_OF_MEMORY;
- goto ERROR_CASE;
- }
- memset(g_voip_stream_info, 0, sizeof(sound_stream_info_s));
- }
- g_voip_stream_info->stream_type = "voip";
- ret = _make_pa_connection_and_register_focus(g_voip_stream_info, _voip_focus_state_change_callback, NULL);
- if (ret != MM_ERROR_NONE) {
- free(g_voip_stream_info);
- g_voip_stream_info = NULL;
+
+ /* create virtual stream for voip */
+ i_ret = _create_virtual_stream(g_voip_stream_info, &g_voip_vstream_h);
+ if (i_ret == SOUND_MANAGER_ERROR_NONE) {
+ i_ret = _start_virtual_stream(g_voip_vstream_h);
+ if (i_ret != SOUND_MANAGER_ERROR_NONE)
+ goto ERROR_CASE;
+ } else
+ goto ERROR_CASE;
+
+ } else {
+ if (g_cached_voip_device_id != -1 && prev_device) {
+ /* remove cached device */
+ i_ret = _remove_device_for_stream_routing(g_voip_stream_info, prev_device);
+ if (i_ret != SOUND_MANAGER_ERROR_NONE)
goto ERROR_CASE;
- }
/* set device for routing to the device */
i_ret = _add_device_for_stream_routing(g_voip_stream_info, proper_device);
if (i_ret == SOUND_MANAGER_ERROR_NONE) {
i_ret = _apply_stream_routing(g_voip_stream_info);
- if (i_ret != SOUND_MANAGER_ERROR_NONE) {
- goto ERROR_CASE;
- }
- } else {
- goto ERROR_CASE;
- }
- /* acquire focus */
- ret = mm_sound_acquire_focus(g_voip_stream_info->index, FOCUS_FOR_BOTH, "for voip session");
- if (ret == MM_ERROR_NONE) {
- g_voip_stream_info->acquired_focus |= FOCUS_FOR_BOTH;
- _update_focus_status(g_voip_stream_info->index, (unsigned int)g_voip_stream_info->acquired_focus);
- } else {
- goto ERROR_CASE;
- }
- /* create virtual stream for voip */
- i_ret = _create_virtual_stream(g_voip_stream_info, &g_voip_vstream_h);
- if (i_ret == SOUND_MANAGER_ERROR_NONE) {
- i_ret = _start_virtual_stream(g_voip_vstream_h);
- if (i_ret != SOUND_MANAGER_ERROR_NONE) {
- goto ERROR_CASE;
- }
- } else {
- goto ERROR_CASE;
- }
- } else {
- if (g_cached_voip_device_id != -1 && prev_device) {
- /* remove cached device */
- i_ret = _remove_device_for_stream_routing(g_voip_stream_info, prev_device);
- if (i_ret != SOUND_MANAGER_ERROR_NONE) {
- goto ERROR_CASE;
- }
- /* set device for routing to the device */
- i_ret = _add_device_for_stream_routing(g_voip_stream_info, proper_device);
- if (i_ret == SOUND_MANAGER_ERROR_NONE) {
- i_ret = _apply_stream_routing(g_voip_stream_info);
- if (i_ret != SOUND_MANAGER_ERROR_NONE) {
- goto ERROR_CASE;
- }
- } else {
+ if (i_ret != SOUND_MANAGER_ERROR_NONE)
goto ERROR_CASE;
- }
- } else {
+ } else
goto ERROR_CASE;
- }
- }
- break;
+ } else
+ goto ERROR_CASE;
+ }
+ break;
}
g_cached_session_mode = mode;
g_cached_voip_device_id = id;
/* get configuration information of this stream type */
ret = _get_stream_conf_info(stream_h->stream_type, &stream_h->stream_conf_info);
- if (ret) {
+ if (ret)
goto PA_ERROR_WITH_UNLOCK;
- } else {
+ else
LOGI("stream_conf_info : priority[%d], route type[%d]", stream_h->stream_conf_info.priority, stream_h->stream_conf_info.route_type);
- }
pa_threaded_mainloop_unlock(stream_h->pa_mainloop);
pa_threaded_mainloop_unlock(stream_h->pa_mainloop);
PA_ERROR:
for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
- if (stream_h->stream_conf_info.avail_in_devices[i]) {
+ if (stream_h->stream_conf_info.avail_in_devices[i])
free(stream_h->stream_conf_info.avail_in_devices[i]);
- } else {
+ else
break;
- }
}
for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
- if (stream_h->stream_conf_info.avail_out_devices[i]) {
+ if (stream_h->stream_conf_info.avail_out_devices[i])
free(stream_h->stream_conf_info.avail_out_devices[i]);
- } else {
+ else
break;
- }
}
for (i = 0; i < AVAIL_FRAMEWORKS_MAX; i++) {
- if (stream_h->stream_conf_info.avail_frameworks[i]) {
+ if (stream_h->stream_conf_info.avail_frameworks[i])
free(stream_h->stream_conf_info.avail_frameworks[i]);
- } else {
+ else
break;
- }
}
if (stream_h->pa_context) {
pa_context_disconnect(stream_h->pa_context);
LOGE("failed to unregister focus, ret(0x%x)", ret);
for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
- if (stream_h->stream_conf_info.avail_in_devices[i]) {
+ if (stream_h->stream_conf_info.avail_in_devices[i])
free(stream_h->stream_conf_info.avail_in_devices[i]);
- }
- if (stream_h->stream_conf_info.avail_out_devices[i]) {
+ if (stream_h->stream_conf_info.avail_out_devices[i])
free(stream_h->stream_conf_info.avail_out_devices[i]);
- }
}
for (i = 0; i < AVAIL_FRAMEWORKS_MAX; i++) {
- if (stream_h->stream_conf_info.avail_frameworks[i]) {
+ if (stream_h->stream_conf_info.avail_frameworks[i])
free(stream_h->stream_conf_info.avail_frameworks[i]);
- }
}
for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++) {
return ret;
}
-int _add_device_for_stream_routing (sound_stream_info_s *stream_info, sound_device_h device)
+int _add_device_for_stream_routing(sound_stream_info_s *stream_info, sound_device_h device)
{
int ret = MM_ERROR_NONE;
int i = 0;
/* not ready yet. after preparing in libmm-sound, it'll be enabled */
if (stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL_EXT) {
ret = mm_sound_get_device_use_internal_codec(device, &use_internal_codec);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
if (use_internal_codec)
return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
}
#endif
ret = mm_sound_get_device_id(device, &device_id);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
ret = mm_sound_get_device_type(device, &device_type);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
ret = _convert_device_type(device_type, &device_type_str);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
ret = mm_sound_get_device_io_direction(device, &device_direction);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
+
if (device_direction == MM_SOUND_DEVICE_IO_DIRECTION_IN || device_direction == MM_SOUND_DEVICE_IO_DIRECTION_BOTH) {
for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
if (stream_info->stream_conf_info.avail_in_devices[i]) {
}
}
- if (!added_successfully) {
+ if (!added_successfully)
ret = MM_ERROR_POLICY_INTERNAL;
- }
return ret;
}
-int _remove_device_for_stream_routing (sound_stream_info_s *stream_info, sound_device_h device)
+int _remove_device_for_stream_routing(sound_stream_info_s *stream_info, sound_device_h device)
{
int ret = MM_ERROR_NONE;
int i = 0;
if (stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL ||
stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL_EXT) {
ret = mm_sound_get_device_id(device, &device_id);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
ret = mm_sound_get_device_type(device, &device_type);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
ret = _convert_device_type(device_type, &device_type_str);
ret = mm_sound_get_device_io_direction(device, &device_direction);
- if (ret) {
+ if (ret)
return _convert_sound_manager_error_code(__func__, ret);
- }
+
if (device_direction == MM_SOUND_DEVICE_IO_DIRECTION_IN || device_direction == MM_SOUND_DEVICE_IO_DIRECTION_BOTH) {
for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
if (stream_info->stream_conf_info.avail_in_devices[i]) {
}
}
- if (!removed_successfully) {
+ if (!removed_successfully)
ret = MM_ERROR_INVALID_ARGUMENT;
- }
return ret;
}
-int _apply_stream_routing (sound_stream_info_s *stream_info)
+int _apply_stream_routing(sound_stream_info_s *stream_info)
{
int ret = MM_ERROR_NONE;
int i = 0;
break;
}
}
- if (need_to_apply) {
+ if (need_to_apply)
ret = _set_manual_route_info(stream_info->index, &stream_info->manual_route_info);
- } else {
+ else
_convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INVALID_STATE);
- }
- } else {
+
+ } else
ret = MM_ERROR_SOUND_INVALID_STATE;
- }
return ret;
}
-int _create_virtual_stream (sound_stream_info_s *stream_info, virtual_sound_stream_info_s **virtual_stream)
+int _create_virtual_stream(sound_stream_info_s *stream_info, virtual_sound_stream_info_s **virtual_stream)
{
int ret = MM_ERROR_NONE;
bool result = false;
LOGI("stream_type[%s], native api[%s], is_available[%d]", stream_info->stream_type, name, result);
if (result == true) {
(*virtual_stream) = malloc(sizeof(virtual_sound_stream_info_s));
- if(!(*virtual_stream)) {
+ if (!(*virtual_stream))
ret = MM_ERROR_OUT_OF_MEMORY;
- } else {
+ else {
memset((*virtual_stream), 0, sizeof(virtual_sound_stream_info_s));
(*virtual_stream)->stream_type = stream_info->stream_type;
(*virtual_stream)->pa_mainloop = stream_info->pa_mainloop;
(*virtual_stream)->state = _VSTREAM_STATE_READY;
(*virtual_stream)->stream_info = stream_info;
}
- } else {
+ } else
ret = MM_ERROR_SOUND_NOT_SUPPORTED_OPERATION;
- }
+
return ret;
}
-int _destroy_virtual_stream (virtual_sound_stream_info_s *virtual_stream)
+int _destroy_virtual_stream(virtual_sound_stream_info_s *virtual_stream)
{
int ret = MM_ERROR_NONE;
return ret;
}
-int _start_virtual_stream (virtual_sound_stream_info_s *virtual_stream)
+int _start_virtual_stream(virtual_sound_stream_info_s *virtual_stream)
{
int ret = MM_ERROR_NONE;
int pa_ret = PA_OK;
for (i = 0; i < SOUND_STREAM_DIRECTION_MAX; i++) {
if (io_direction & (i + 1)) {
virtual_stream->pa_stream[i] = pa_stream_new_with_proplist(virtual_stream->pa_context, "VIRTUAL_STREAM", &ss, &maps, virtual_stream->pa_proplist);
- if(virtual_stream->pa_stream[i] == NULL) {
+ if (virtual_stream->pa_stream[i] == NULL) {
LOGE("failed to pa_stream_new_with_proplist()");
pa_ret = pa_context_errno(virtual_stream->pa_context);
ret = MM_ERROR_SOUND_INTERNAL;
for (;;) {
pa_stream_state_t state;
state = pa_stream_get_state(virtual_stream->pa_stream[i]);
- if (state == PA_STREAM_READY) {
+ if (state == PA_STREAM_READY)
break;
- }
- if (!PA_STREAM_IS_GOOD(state)) {
+ if (!PA_STREAM_IS_GOOD(state))
pa_ret = pa_context_errno(virtual_stream->pa_context);
- }
+
pa_threaded_mainloop_wait(virtual_stream->pa_mainloop);
}
}
return ret;
}
-int _stop_virtual_stream (virtual_sound_stream_info_s *virtual_stream)
+int _stop_virtual_stream(virtual_sound_stream_info_s *virtual_stream)
{
int ret = MM_ERROR_NONE;
int i = 0;
for (;;) {
pa_stream_state_t state;
state = pa_stream_get_state(virtual_stream->pa_stream[i]);
- if (state == PA_STREAM_TERMINATED) {
+ if (state == PA_STREAM_TERMINATED)
break;
- }
pa_threaded_mainloop_wait(virtual_stream->pa_mainloop);
}
#include <sound_manager_internal.h>
#include <pthread.h>
#include <glib.h>
-//#include <dlfcn.h>
#define MAX_STRING_LEN 2048
-
-enum
-{
+enum {
CURRENT_STATUS_MAINMENU,
CURRENT_STATUS_GET_MAX_VOLUME,
CURRENT_STATUS_SET_VOLUME,
sound_stream_info_h g_stream_info_h = NULL;
virtual_sound_stream_h g_vstream_h = NULL;
-void focus_callback (sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data) {
+void focus_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data)
+{
int ret = 0;
sound_stream_focus_state_e playback_focus_state;
sound_stream_focus_state_e recording_focus_state;
g_print("*** FOCUS callback is called, stream_info(%p) ***\n", stream_info);
g_print(" - reason_for_change(%d), additional_info(%s), user_data(%p)\n", reason_for_change, additional_info, user_data);
- ret = sound_manager_get_focus_state (stream_info, &playback_focus_state, &recording_focus_state);
+
+ ret = sound_manager_get_focus_state(stream_info, &playback_focus_state, &recording_focus_state);
if (!ret)
g_print(" - focus_state(playback_focus:%d, recording_focus:%d)\n", playback_focus_state, recording_focus_state);
- if (playback_focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
+
+ if (playback_focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED)
g_print(" -- PLAYBACK_FOCUS acquired\n");
- }
- if (recording_focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
+
+ if (recording_focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED)
g_print(" -- FOCUS_RECORDING acquired\n");
- }
+
g_print("*** FOCUS callback is ended, stream_info(%p) ****\n", stream_info);
+
return;
}
-void focus_watch_callback (sound_stream_focus_mask_e changed_focus_type, sound_stream_focus_state_e changed_focus_state, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data) {
+void focus_watch_callback(sound_stream_focus_mask_e changed_focus_type, sound_stream_focus_state_e changed_focus_state, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data)
+{
g_print("*** FOCUS WATCH callback is called ***\n");
g_print(" - changed_focus_type(%d), changed_focus_state(%d), reason_for_change(%d), additional_info(%s), user_data(%p)\n",
changed_focus_type, changed_focus_state, reason_for_change, additional_info, user_data);
void _interpret_main_menu(char *cmd)
{
- if (strncmp(cmd, "gx", 3) == 0)
- {
- g_menu_state = CURRENT_STATUS_GET_MAX_VOLUME;
- }
- else if (strncmp(cmd, "sv", 3) == 0)
- {
- g_menu_state = CURRENT_STATUS_SET_VOLUME;
- }
- else if (strncmp(cmd, "gv", 3) == 0)
- {
- g_menu_state = CURRENT_STATUS_GET_VOLUME;
- }
- else if (strncmp(cmd, "st", 3) == 0)
- {
- g_menu_state = CURRENT_STATUS_SET_CURRENT_SOUND_TYPE;
- }
- else if (strncmp(cmd, "gt", 3) == 0)
- {
- g_menu_state = CURRENT_STATUS_GET_CURRENT_SOUND_TYPE;
- }
- else if (strncmp(cmd, "ut", 3) == 0)
- {
- g_menu_state = CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE;
- }
- else if (strncmp(cmd, "vc", 3) == 0)
- {
- g_menu_state = CURRENT_STATUS_SET_VOLUME_CHANGED_CB;
- }
- else if (strncmp(cmd, "uv", 3) == 0)
- {
- g_menu_state = CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB;
- }
- else if (strncmp(cmd, "ss", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_SET_SESSION_TYPE;
- }
- else if (strncmp(cmd, "gs", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_GET_SESSION_TYPE;
- }
- else if (strncmp(cmd, "sm", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_SET_MEDIA_SESSION_OPTION;
- }
- else if (strncmp(cmd, "gm", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_GET_MEDIA_SESSION_OPTION;
- }
- else if (strncmp(cmd, "sr", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION;
- }
- else if (strncmp(cmd, "gr", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION;
- }
- else if (strncmp(cmd, "so", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_SET_VOIP_SESSION_MODE;
- }
- else if (strncmp(cmd, "go", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_GET_VOIP_SESSION_MODE;
- }
- else if (strncmp(cmd, "sl", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_SET_CALL_SESSION_MODE;
- }
- else if (strncmp(cmd, "gc", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_GET_CALL_SESSION_MODE;
- }
- else if (strncmp(cmd, "sc", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB;
- }
- else if (strncmp(cmd, "us", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB;
- }
- else if (strncmp(cmd, "sk", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_SET_DEVICE_MASK;
- }
- else if (strncmp(cmd, "gk", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_GET_DEVICE_MASK;
- }
- else if (strncmp(cmd, "gl", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_GET_DEVICE_LIST;
- }
- else if (strncmp(cmd, "gn", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_GET_DEVICE_NEXT;
- }
- else if (strncmp(cmd, "gp", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_GET_DEVICE_PREV;
- }
- else if (strncmp(cmd, "sd", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_SET_DEVICE_CONNECTED_CB;
- }
- else if (strncmp(cmd, "ud", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB;
- }
- else if (strncmp(cmd, "si", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB;
- }
- else if (strncmp(cmd, "ui", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB;
- }
- else if (strncmp(cmd, "csi", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_CREATE_STREAM_INFO;
- }
- else if (strncmp(cmd, "ads", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING;
- }
- else if (strncmp(cmd, "rds", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING;
- }
- else if (strncmp(cmd, "aps", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_APPLY_STREAM_ROUTING;
- }
- else if (strncmp(cmd, "sso", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_SET_STREAM_ROUTING_OPTION;
- }
- else if (strncmp(cmd, "afc", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_ACQUIRE_FOCUS;
- }
- else if (strncmp(cmd, "rfc", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_RELEASE_FOCUS;
- }
- else if (strncmp(cmd, "gfs", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_GET_ACQUIRED_FOCUS;
- }
- else if (strncmp(cmd, "sfw", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_SET_FOCUS_WATCH_CB;
- }
- else if (strncmp(cmd, "ufw", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_UNSET_FOCUS_WATCH_CB;
- }
- else if (strncmp(cmd, "dsi", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_DESTROY_STREAM_INFO;
- }
- else if (strncmp(cmd, "vcr", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_CREATE_VIRTUAL_STREAM;
- }
- else if (strncmp(cmd, "vsr", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_START_VIRTUAL_STREAM;
- }
- else if (strncmp(cmd, "vst", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_STOP_VIRTUAL_STREAM;
- }
- else if (strncmp(cmd, "vdt", 3) == 0 )
- {
- g_menu_state = CURRENT_STATUS_DESTROY_VIRTUAL_STREAM;
- }
- else if (strncmp(cmd, "q", 3) == 0 )
- {
- g_print("closing the test suite\n");
- quit_program();
- }
- else
- {
- g_print("unknown menu \n");
- }
-
+ if (strncmp(cmd, "gx", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_MAX_VOLUME;
+ else if (strncmp(cmd, "sv", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_VOLUME;
+ else if (strncmp(cmd, "gv", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_VOLUME;
+ else if (strncmp(cmd, "st", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_CURRENT_SOUND_TYPE;
+ else if (strncmp(cmd, "gt", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_CURRENT_SOUND_TYPE;
+ else if (strncmp(cmd, "ut", 3) == 0)
+ g_menu_state = CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE;
+ else if (strncmp(cmd, "vc", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_VOLUME_CHANGED_CB;
+ else if (strncmp(cmd, "uv", 3) == 0)
+ g_menu_state = CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB;
+ else if (strncmp(cmd, "ss", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_SESSION_TYPE;
+ else if (strncmp(cmd, "gs", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_SESSION_TYPE;
+ else if (strncmp(cmd, "sm", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_MEDIA_SESSION_OPTION;
+ else if (strncmp(cmd, "gm", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_MEDIA_SESSION_OPTION;
+ else if (strncmp(cmd, "sr", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION;
+ else if (strncmp(cmd, "gr", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION;
+ else if (strncmp(cmd, "so", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_VOIP_SESSION_MODE;
+ else if (strncmp(cmd, "go", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_VOIP_SESSION_MODE;
+ else if (strncmp(cmd, "sl", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_CALL_SESSION_MODE;
+ else if (strncmp(cmd, "gc", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_CALL_SESSION_MODE;
+ else if (strncmp(cmd, "sc", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB;
+ else if (strncmp(cmd, "us", 3) == 0)
+ g_menu_state = CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB;
+ else if (strncmp(cmd, "sk", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_DEVICE_MASK;
+ else if (strncmp(cmd, "gk", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_DEVICE_MASK;
+ else if (strncmp(cmd, "gl", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_DEVICE_LIST;
+ else if (strncmp(cmd, "gn", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_DEVICE_NEXT;
+ else if (strncmp(cmd, "gp", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_DEVICE_PREV;
+ else if (strncmp(cmd, "sd", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_DEVICE_CONNECTED_CB;
+ else if (strncmp(cmd, "ud", 3) == 0)
+ g_menu_state = CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB;
+ else if (strncmp(cmd, "si", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB;
+ else if (strncmp(cmd, "ui", 3) == 0)
+ g_menu_state = CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB;
+ else if (strncmp(cmd, "csi", 3) == 0)
+ g_menu_state = CURRENT_STATUS_CREATE_STREAM_INFO;
+ else if (strncmp(cmd, "ads", 3) == 0)
+ g_menu_state = CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING;
+ else if (strncmp(cmd, "rds", 3) == 0)
+ g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING;
+ else if (strncmp(cmd, "aps", 3) == 0)
+ g_menu_state = CURRENT_STATUS_APPLY_STREAM_ROUTING;
+ else if (strncmp(cmd, "sso", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_STREAM_ROUTING_OPTION;
+ else if (strncmp(cmd, "afc", 3) == 0)
+ g_menu_state = CURRENT_STATUS_ACQUIRE_FOCUS;
+ else if (strncmp(cmd, "rfc", 3) == 0)
+ g_menu_state = CURRENT_STATUS_RELEASE_FOCUS;
+ else if (strncmp(cmd, "gfs", 3) == 0)
+ g_menu_state = CURRENT_STATUS_GET_ACQUIRED_FOCUS;
+ else if (strncmp(cmd, "sfw", 3) == 0)
+ g_menu_state = CURRENT_STATUS_SET_FOCUS_WATCH_CB;
+ else if (strncmp(cmd, "ufw", 3) == 0)
+ g_menu_state = CURRENT_STATUS_UNSET_FOCUS_WATCH_CB;
+ else if (strncmp(cmd, "dsi", 3) == 0)
+ g_menu_state = CURRENT_STATUS_DESTROY_STREAM_INFO;
+ else if (strncmp(cmd, "vcr", 3) == 0)
+ g_menu_state = CURRENT_STATUS_CREATE_VIRTUAL_STREAM;
+ else if (strncmp(cmd, "vsr", 3) == 0)
+ g_menu_state = CURRENT_STATUS_START_VIRTUAL_STREAM;
+ else if (strncmp(cmd, "vst", 3) == 0)
+ g_menu_state = CURRENT_STATUS_STOP_VIRTUAL_STREAM;
+ else if (strncmp(cmd, "vdt", 3) == 0)
+ g_menu_state = CURRENT_STATUS_DESTROY_VIRTUAL_STREAM;
+ else if (strncmp(cmd, "q", 3) == 0) {
+ g_print("closing the test suite\n");
+ quit_program();
+ } else
+ g_print("unknown menu \n");
}
void display_sub_basic()
g_print("uv. Unset Volume Changed CB \n");
g_print("-----------------------------------------------------------------------------------------\n");
g_print(" SESSION MODULE \n");
- g_print("-----------------------------------------------------------------------------------------\n");
+ g_print("-----------------------------------------------------------------------------------------\n");
g_print("ss. Set Session Type\t\t");
g_print("gs. Get Session Type\n");
g_print("sm. Set Media Session Option \t");
static void displaymenu()
{
static int flag = 0;
- if (g_menu_state == CURRENT_STATUS_MAINMENU)
- {
+ if (g_menu_state == CURRENT_STATUS_MAINMENU) {
display_sub_basic();
flag = 0;
- }
- else if (g_menu_state == CURRENT_STATUS_GET_MAX_VOLUME)
- {
+ } else if (g_menu_state == CURRENT_STATUS_GET_MAX_VOLUME)
g_print("*** input sound type(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n");
- }
- else if (g_menu_state == CURRENT_STATUS_SET_VOLUME)
- {
- if(flag == 0)
- g_print("*** input sound type and desired volume level(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE, (0~max volum).\n");
- flag =1;
- }
- else if (g_menu_state == CURRENT_STATUS_GET_VOLUME)
- {
+ else if (g_menu_state == CURRENT_STATUS_SET_VOLUME) {
+ if (flag == 0)
+ g_print("*** input sound type and desired volume level(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE, (0~max volum).\n");
+ flag = 1;
+ } else if (g_menu_state == CURRENT_STATUS_GET_VOLUME)
g_print("*** input sound type(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n");
- }
else if (g_menu_state == CURRENT_STATUS_SET_CURRENT_SOUND_TYPE)
- {
g_print("*** input sound type.(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n");
- }
else if (g_menu_state == CURRENT_STATUS_GET_CURRENT_SOUND_TYPE)
- {
g_print("*** press enter to get current sound type\n");
- }
else if (g_menu_state == CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE)
- {
g_print("*** press enter to unset current sound type\n");
- }
else if (g_menu_state == CURRENT_STATUS_SET_VOLUME_CHANGED_CB)
- {
g_print("*** press enter to set volume changed cb\n");
- }
else if (g_menu_state == CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB)
- {
g_print("*** press enter to unset volume changed cb\n");
- }
else if (g_menu_state == CURRENT_STATUS_SET_SESSION_TYPE)
- {
g_print("*** input session type(0:MEDIA, 1:ALARM, 2:NOTIFICATION, 3:EMERGENCY, 4:VOIP)\n");
- }
else if (g_menu_state == CURRENT_STATUS_GET_SESSION_TYPE)
- {
g_print("*** press enter to get session type\n");
- }
- else if (g_menu_state == CURRENT_STATUS_SET_MEDIA_SESSION_OPTION)
- {
- if(flag == 0)
- g_print("*** input starting option, and ongoing(for starting(0:MIX WITH OTHERS, 1:PAUSE OTHERS), for ongoing(0:INTERRUPTABLE, 1:UNINTERRUPABLE)\n");
+ else if (g_menu_state == CURRENT_STATUS_SET_MEDIA_SESSION_OPTION) {
+ if (flag == 0)
+ g_print("*** input starting option, and ongoing(for starting(0:MIX WITH OTHERS, 1:PAUSE OTHERS), for ongoing(0:INTERRUPTABLE, 1:UNINTERRUPABLE)\n");
flag = 1;
- }
- else if (g_menu_state == CURRENT_STATUS_GET_MEDIA_SESSION_OPTION)
- {
+ } else if (g_menu_state == CURRENT_STATUS_GET_MEDIA_SESSION_OPTION)
g_print("*** press enter to get media session option\n");
- }
else if (g_menu_state == CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION)
- {
g_print("*** input media session resumption option(0:BY SYSTEM, 1:OR MEDIA PAUSE)\n");
- }
else if (g_menu_state == CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION)
- {
g_print("*** press enter to get media session resumption option\n");
- }
else if (g_menu_state == CURRENT_STATUS_SET_VOIP_SESSION_MODE)
- {
g_print("*** input voip session mode (0:RINGTONE, 1:VOICE with RCV, 2:VOICE with SPK, 3:VOICE with AudioJack, 4:VOICE with BT)\n");
- }
else if (g_menu_state == CURRENT_STATUS_GET_VOIP_SESSION_MODE)
- {
g_print("*** press enter to get voip session mode\n");
- }
else if (g_menu_state == CURRENT_STATUS_SET_CALL_SESSION_MODE)
- {
g_print("*** input call session mode (0:RINGTONE, 1:VOICE with RCV, 2:VOICE with SPK, 3:VOICE with AudioJack, 4:VOICE with BT)\n");
- }
else if (g_menu_state == CURRENT_STATUS_GET_CALL_SESSION_MODE)
- {
g_print("*** press enter to get call session mode\n");
- }
else if (g_menu_state == CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB)
- {
g_print("*** press enter to set session interrupted cb\n");
- }
else if (g_menu_state == CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB)
- {
g_print("*** press enter to unset session interrupted cb\n");
- }
else if (g_menu_state == CURRENT_STATUS_SET_DEVICE_MASK)
- {
g_print("*** input device mask (0:ALL, 1:INTERNAL, 2:EXTERNAL, 3:INPUT, 4:OUTPUT, 5:BOTH, 6:ACTIVATED, 7:DEACTIVATED, b:back to the menu\n");
- }
else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_MASK)
- {
g_print("*** press enter to get device mask\n");
- }
else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_LIST)
- {
g_print("*** press enter to get device list\n");
- }
else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_NEXT)
- {
g_print("*** press enter to get next device from the list\n");
- }
else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_PREV)
- {
g_print("*** press enter to get previous device from the list\n");
- }
else if (g_menu_state == CURRENT_STATUS_SET_DEVICE_CONNECTED_CB)
- {
g_print("*** press enter to set device connected cb\n");
- }
else if (g_menu_state == CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB)
- {
g_print("*** press enter to unset device connected cb\n");
- }
else if (g_menu_state == CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB)
- {
g_print("*** press enter to set device information changed cb\n");
- }
else if (g_menu_state == CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB)
- {
g_print("*** press enter to unset device information changed cb\n");
- }
else if (g_menu_state == CURRENT_STATUS_CREATE_STREAM_INFO)
- {
g_print("*** input stream type to create stream information (0:media, 1:alarm, 2:notification, 3:ringtone-call, 4:voice-call, 5:voip, 6:media-ext-only)\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)\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)\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)
- {
g_print("*** input option(name/value) for routing (0:option_1/0, 1:option_1/1, 2:option_2/0, 3:option_2:1)\n");
- }
else if (g_menu_state == CURRENT_STATUS_ACQUIRE_FOCUS)
- {
g_print("*** input focus type to acquire (0:playback, 1:recording, 2:both)\n");
- }
else if (g_menu_state == CURRENT_STATUS_RELEASE_FOCUS)
- {
g_print("*** input focus type to release (0:playback, 1:recording, 2:both)\n");
- }
else if (g_menu_state == CURRENT_STATUS_GET_ACQUIRED_FOCUS)
- {
g_print("*** press enter to get focus state\n");
- }
else if (g_menu_state == CURRENT_STATUS_DESTROY_STREAM_INFO)
- {
g_print("*** press enter to destroy stream information\n");
- }
else if (g_menu_state == CURRENT_STATUS_SET_FOCUS_WATCH_CB)
- {
g_print("*** input focus type to watch for (0:playback, 1:recording, 2:both)\n");
- }
else if (g_menu_state == CURRENT_STATUS_UNSET_FOCUS_WATCH_CB)
- {
g_print("*** press enter to unset focus state watch cb\n");
- }
else if (g_menu_state == CURRENT_STATUS_CREATE_VIRTUAL_STREAM)
- {
g_print("*** press enter to create virtual stream\n");
- }
else if (g_menu_state == CURRENT_STATUS_START_VIRTUAL_STREAM)
- {
g_print("*** press enter to start virtual stream\n");
- }
else if (g_menu_state == CURRENT_STATUS_STOP_VIRTUAL_STREAM)
- {
g_print("*** press enter to stop virtual stream\n");
- }
else if (g_menu_state == CURRENT_STATUS_DESTROY_VIRTUAL_STREAM)
- {
g_print("*** press enter to destroy virtual stream\n");
- }
- else
- {
+ else {
g_print("*** unknown status.\n");
quit_program();
}
return FALSE;
}
-gboolean timeout_quit_program(void* data)
-{
- //elm_exit();
- quit_program();
- return FALSE;
-}
-
int convert_sound_type(sound_type_e *type, char *cmd)
{
int sound_type_n = atoi(cmd);
- if (SOUND_TYPE_SYSTEM > sound_type_n || sound_type_n > SOUND_TYPE_VOICE)
- {
- g_print("not supported sound type(%d)\n", sound_type_n);
- return 0;
- }
- else
- {
- switch (sound_type_n)
- {
- case 0:
- *type = SOUND_TYPE_SYSTEM;
- break;
- case 1:
- *type = SOUND_TYPE_NOTIFICATION;
- break;
- case 2:
- *type = SOUND_TYPE_ALARM;
- break;
- case 3:
- *type = SOUND_TYPE_RINGTONE;
- break;
- case 4:
- *type = SOUND_TYPE_MEDIA;
- break;
- case 5:
- *type = SOUND_TYPE_CALL;
- break;
- case 6:
- *type = SOUND_TYPE_VOIP;
- break;
- case 7:
- *type = SOUND_TYPE_VOICE;
- break;
- }
+ if (SOUND_TYPE_SYSTEM > sound_type_n || sound_type_n > SOUND_TYPE_VOICE) {
+ g_print("not supported sound type(%d)\n", sound_type_n);
+ return 0;
+ } else {
+ switch (sound_type_n) {
+ case 0:
+ *type = SOUND_TYPE_SYSTEM;
+ break;
+ case 1:
+ *type = SOUND_TYPE_NOTIFICATION;
+ break;
+ case 2:
+ *type = SOUND_TYPE_ALARM;
+ break;
+ case 3:
+ *type = SOUND_TYPE_RINGTONE;
+ break;
+ case 4:
+ *type = SOUND_TYPE_MEDIA;
+ break;
+ case 5:
+ *type = SOUND_TYPE_CALL;
+ break;
+ case 6:
+ *type = SOUND_TYPE_VOIP;
+ break;
+ case 7:
+ *type = SOUND_TYPE_VOICE;
+ break;
}
+ }
return 1;
}
int convert_session_type(sound_session_type_e *type, char *cmd)
{
int session_type_n = atoi(cmd);
- if (SOUND_SESSION_TYPE_MEDIA > session_type_n || session_type_n > SOUND_SESSION_TYPE_VOIP)
- {
- g_print("not supported session type(%d)\n", session_type_n);
- return 0;
- }
- else
- {
- switch (session_type_n)
- {
- case 0:
- *type = SOUND_SESSION_TYPE_MEDIA;
- break;
- case 1:
- *type = SOUND_SESSION_TYPE_ALARM;
- break;
- case 2:
- *type = SOUND_SESSION_TYPE_NOTIFICATION;
- break;
- case 3:
- *type = SOUND_SESSION_TYPE_EMERGENCY;
- break;
- case 4:
- *type = SOUND_SESSION_TYPE_VOIP;
- break;
- }
+ if (SOUND_SESSION_TYPE_MEDIA > session_type_n || session_type_n > SOUND_SESSION_TYPE_VOIP) {
+ g_print("not supported session type(%d)\n", session_type_n);
+ return 0;
+ } else {
+ switch (session_type_n) {
+ case 0:
+ *type = SOUND_SESSION_TYPE_MEDIA;
+ break;
+ case 1:
+ *type = SOUND_SESSION_TYPE_ALARM;
+ break;
+ case 2:
+ *type = SOUND_SESSION_TYPE_NOTIFICATION;
+ break;
+ case 3:
+ *type = SOUND_SESSION_TYPE_EMERGENCY;
+ break;
+ case 4:
+ *type = SOUND_SESSION_TYPE_VOIP;
+ break;
}
+ }
return 1;
}
g_print("***device connected callback is called, is_connected[%d]\n", is_connected);
- if ((ret = sound_manager_get_device_type (device, &type)))
+ if ((ret = sound_manager_get_device_type(device, &type)))
g_print("failed to get device type, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_io_direction (device, &io_direction)))
+ if ((ret = sound_manager_get_device_io_direction(device, &io_direction)))
g_print("failed to get device io direction, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_id (device, &id)))
+ if ((ret = sound_manager_get_device_id(device, &id)))
g_print("failed to get device id, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_name (device, &name)))
+ if ((ret = sound_manager_get_device_name(device, &name)))
g_print("failed to get device name, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_state (device, &state)))
+ if ((ret = sound_manager_get_device_state(device, &state)))
g_print("failed to get device state, ret[0x%x]\n", ret);
if (!ret)
g_print(" -- device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state);
g_print("***device information changed callback is called, changed_info[%d](0:STATE 1:IO_DIRECTION)\n", changed_info);
- if ((ret = sound_manager_get_device_type (device, &type)))
+ if ((ret = sound_manager_get_device_type(device, &type)))
g_print("failed to get device type, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_io_direction (device, &io_direction)))
+ if ((ret = sound_manager_get_device_io_direction(device, &io_direction)))
g_print("failed to get device io direction, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_id (device, &id)))
+ if ((ret = sound_manager_get_device_id(device, &id)))
g_print("failed to get device id, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_name (device, &name)))
+ if ((ret = sound_manager_get_device_name(device, &name)))
g_print("failed to get device name, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_state (device, &state)))
+ if ((ret = sound_manager_get_device_state(device, &state)))
g_print("failed to get device state, ret[0x%x]\n", ret);
if (!ret)
g_print(" -- device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state);
g_menu_state = CURRENT_STATUS_MAINMENU;
}
-static void interpret (char *cmd)
+static void interpret(char *cmd)
{
- switch (g_menu_state)
- {
- case CURRENT_STATUS_MAINMENU:
- {
- _interpret_main_menu(cmd);
- }
+ switch (g_menu_state) {
+ case CURRENT_STATUS_MAINMENU:
+ _interpret_main_menu(cmd);
break;
- case CURRENT_STATUS_GET_MAX_VOLUME:
- {
- static sound_type_e type;
- static int max;
- if(convert_sound_type(&type,cmd) == 1)
- {
- if(sound_manager_get_max_volume(type, &max) != 0)
- g_print("failt to get max volume\n");
- else
- g_print("the max volume of this type(%d) is %d\n", type, max);
- }
- reset_menu_state();
+ case CURRENT_STATUS_GET_MAX_VOLUME: {
+ static sound_type_e type;
+ static int max;
+ if (convert_sound_type(&type, cmd) == 1) {
+ if (sound_manager_get_max_volume(type, &max) != 0)
+ g_print("failt to get max volume\n");
+ else
+ g_print("the max volume of this type(%d) is %d\n", type, max);
}
+ reset_menu_state();
break;
- case CURRENT_STATUS_SET_VOLUME:
- {
- static int cnt =0;
- static sound_type_e type;
- static int volume;
- switch(cnt)
- {
- case 0:
- if(convert_sound_type(&type,cmd) == 1)
- cnt ++;
- else
- reset_menu_state();
- break;
- case 1:
- volume = atoi(cmd);
- if(sound_manager_set_volume(type, volume) != 0)
- g_print("fail to set volume(%d) check sound type(%d)'s available volume level\n", volume, type);
- else
- g_print("set volume success : sound type(%d), volume(%d)\n",type, volume);
- cnt = 0;
+ }
+ case CURRENT_STATUS_SET_VOLUME: {
+ static int cnt = 0;
+ static sound_type_e type;
+ static int volume;
+ switch (cnt) {
+ case 0:
+ if (convert_sound_type(&type, cmd) == 1)
+ cnt++;
+ else
reset_menu_state();
- break;
- default:
- break;
- }
- }
- break;
- case CURRENT_STATUS_GET_VOLUME:
- {
- static sound_type_e type;
- static int volume;
- if(convert_sound_type(&type,cmd) == 1)
- {
- if(sound_manager_get_volume(type, &volume) != 0)
- g_print("fail to get volume\n");
- else
- g_print("current volume of this type(%d) is : %d\n", type, volume);
- }
- reset_menu_state();
- }
- break;
- case CURRENT_STATUS_SET_CURRENT_SOUND_TYPE:
- {
- static sound_type_e type;
- if(convert_sound_type(&type,cmd) == 1)
- {
- if(sound_manager_set_current_sound_type(type) != 0)
- g_print("fail to set sound type(%d)\n", type);
- else
- g_print("success to set sound type(%d)\n", type);
- }
- reset_menu_state();
- }
- break;
- case CURRENT_STATUS_GET_CURRENT_SOUND_TYPE:
- {
- static sound_type_e type;
- if(sound_manager_get_current_sound_type(&type) !=0)
- g_print("fail to get current sound type\n");
+ break;
+ case 1:
+ volume = atoi(cmd);
+ if (sound_manager_set_volume(type, volume) != 0)
+ g_print("fail to set volume(%d) check sound type(%d)'s available volume level\n", volume, type);
else
- g_print("current sound type is (%d)\n", type);
+ g_print("set volume success : sound type(%d), volume(%d)\n", type, volume);
+ cnt = 0;
reset_menu_state();
+ break;
+ default:
+ break;
}
break;
- case CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE:
- {
- if(sound_manager_unset_current_sound_type() !=0)
- g_print("fail to unset current sound type\n");
+ }
+ case CURRENT_STATUS_GET_VOLUME: {
+ static sound_type_e type;
+ static int volume;
+ if (convert_sound_type(&type, cmd) == 1) {
+ if (sound_manager_get_volume(type, &volume) != 0)
+ g_print("fail to get volume\n");
else
- g_print("success to unset current sound type\n");
- reset_menu_state();
+ g_print("current volume of this type(%d) is : %d\n", type, volume);
}
+ reset_menu_state();
break;
- case CURRENT_STATUS_SET_VOLUME_CHANGED_CB:
- {
- if(sound_manager_set_volume_changed_cb(_set_volume_changed_cb, NULL) !=0)
- g_print("fail to set volume changed cb\n");
+ }
+ case CURRENT_STATUS_SET_CURRENT_SOUND_TYPE: {
+ static sound_type_e type;
+ if (convert_sound_type(&type, cmd) == 1) {
+ if (sound_manager_set_current_sound_type(type) != 0)
+ g_print("fail to set sound type(%d)\n", type);
else
- g_print("success to set volume changed cb\n");
- reset_menu_state();
+ g_print("success to set sound type(%d)\n", type);
}
+ reset_menu_state();
break;
- case CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB:
- {
- if(sound_manager_unset_volume_changed_cb() !=0)
- g_print("fail to unset volume changed cb\n");
- else
- g_print("success to unset volume changed cb\n");
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_GET_CURRENT_SOUND_TYPE: {
+ static sound_type_e type;
+ if (sound_manager_get_current_sound_type(&type) != 0)
+ g_print("fail to get current sound type\n");
+ else
+ g_print("current sound type is (%d)\n", type);
+ reset_menu_state();
break;
- case CURRENT_STATUS_SET_SESSION_TYPE:
- {
- static sound_session_type_e type;
- if(convert_session_type(&type, cmd) == 1)
- {
- if(sound_manager_set_session_type(type) !=0)
- g_print("fail to set session type\n");
- else
- g_print("success to set session type(%d)\n",type);
- }
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE: {
+ if (sound_manager_unset_current_sound_type() != 0)
+ g_print("fail to unset current sound type\n");
+ else
+ g_print("success to unset current sound type\n");
+ reset_menu_state();
break;
- case CURRENT_STATUS_GET_SESSION_TYPE:
- {
- static sound_session_type_e type;
- if(sound_manager_get_session_type(&type) !=0)
- g_print("fail to get session type\n");
- else
- g_print("current session type is : %d (0:MEDIA, 1:ALARM, 2:NOTIFICATION, 3:EMERGENCY, 4:VOIP, 5:CALL)\n", type);
-
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_SET_VOLUME_CHANGED_CB: {
+ if (sound_manager_set_volume_changed_cb(_set_volume_changed_cb, NULL) != 0)
+ g_print("fail to set volume changed cb\n");
+ else
+ g_print("success to set volume changed cb\n");
+ reset_menu_state();
break;
- case CURRENT_STATUS_SET_MEDIA_SESSION_OPTION:
- {
- static sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
- static sound_session_option_for_starting_e option_s;
- static sound_session_option_for_during_play_e option_d;
- static int cnt = 0;
- if(sound_manager_set_session_type(type) !=0)
- {
- g_print("fail to set media session type\n");
- reset_menu_state();
- }
- else
- {
- switch(cnt)
- {
- case 0:
- option_s = (sound_session_option_for_starting_e)atoi(cmd);
- if(SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START > option_s || SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START < option_s)
- g_print("not supported option type\n");
- else
- cnt ++;
- break;
- case 1:
- option_d = (sound_session_option_for_during_play_e)atoi(cmd);
- if(SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY > option_d || SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY < option_d)
- g_print("not supported option type\n");
- else
- {
- if(sound_manager_set_media_session_option(option_s, option_d) != 0)
- g_print("fail to set media session option\n");
- else
- g_print("success to set media session option\n");
- cnt = 0;
- }
- reset_menu_state();
- break;
- default:
- break;
- }
- }
- }
+ }
+ case CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB: {
+ if (sound_manager_unset_volume_changed_cb() != 0)
+ g_print("fail to unset volume changed cb\n");
+ else
+ g_print("success to unset volume changed cb\n");
+ reset_menu_state();
break;
- case CURRENT_STATUS_GET_MEDIA_SESSION_OPTION:
- {
- static sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
- static sound_session_option_for_starting_e option_s;
- static sound_session_option_for_during_play_e option_d;
- if(sound_manager_set_session_type(type) != 0)
- g_print("fail to set media session type\n");
+ }
+ case CURRENT_STATUS_SET_SESSION_TYPE: {
+ static sound_session_type_e type;
+ if (convert_session_type(&type, cmd) == 1) {
+ if (sound_manager_set_session_type(type) != 0)
+ g_print("fail to set session type\n");
else
- {
- if(sound_manager_get_media_session_option(&option_s,&option_d) !=0)
- g_print("fail to get media session option\n");
- else
- g_print("current media session options are (%d) for starting, (%d) for ongoing\n", option_s, option_d);
- }
- reset_menu_state();
+ g_print("success to set session type(%d)\n", type);
}
+ reset_menu_state();
break;
- case CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION:
- {
- static sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
- static sound_session_option_for_resumption_e option_r;
- if(sound_manager_set_session_type(type) != 0)
- g_print("fail to set media session type\n");
- else
- {
- option_r = (sound_session_option_for_resumption_e)atoi(cmd);
- if(SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM > option_r || SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED < option_r)
+ }
+ case CURRENT_STATUS_GET_SESSION_TYPE: {
+ static sound_session_type_e type;
+ if (sound_manager_get_session_type(&type) != 0)
+ g_print("fail to get session type\n");
+ else
+ g_print("current session type is : %d (0:MEDIA, 1:ALARM, 2:NOTIFICATION, 3:EMERGENCY, 4:VOIP, 5:CALL)\n", type);
+ reset_menu_state();
+ break;
+ }
+ case CURRENT_STATUS_SET_MEDIA_SESSION_OPTION: {
+ static sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
+ static sound_session_option_for_starting_e option_s;
+ static sound_session_option_for_during_play_e option_d;
+ static int cnt = 0;
+ if (sound_manager_set_session_type(type) != 0) {
+ g_print("fail to set media session type\n");
+ reset_menu_state();
+ } else {
+ switch (cnt) {
+ case 0:
+ option_s = (sound_session_option_for_starting_e)atoi(cmd);
+ if (SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START > option_s || SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START < option_s)
g_print("not supported option type\n");
else
- {
- if(sound_manager_set_media_session_resumption_option(option_r) !=0)
- g_print("fail to set media session resumption option\n");
+ cnt++;
+ break;
+ case 1:
+ option_d = (sound_session_option_for_during_play_e)atoi(cmd);
+ if (SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY > option_d || SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY < option_d)
+ g_print("not supported option type\n");
+ else {
+ if (sound_manager_set_media_session_option(option_s, option_d) != 0)
+ g_print("fail to set media session option\n");
else
- g_print("succese to set media session resumption option\n");
+ g_print("success to set media session option\n");
+ cnt = 0;
}
- }
- reset_menu_state();
+ reset_menu_state();
+ break;
+ default:
+ break;
+ }
}
break;
- case CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION:
- {
- static sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
- static sound_session_option_for_resumption_e option_r;
- if(sound_manager_set_session_type(type) != 0)
- g_print("fail to set media session type\n");
+ }
+ case CURRENT_STATUS_GET_MEDIA_SESSION_OPTION: {
+ static sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
+ static sound_session_option_for_starting_e option_s;
+ static sound_session_option_for_during_play_e option_d;
+ if (sound_manager_set_session_type(type) != 0)
+ g_print("fail to set media session type\n");
+ else {
+ if (sound_manager_get_media_session_option(&option_s, &option_d) != 0)
+ g_print("fail to get media session option\n");
else
- {
- if(sound_manager_get_media_session_resumption_option(&option_r) != 0)
- g_print("fail to get media session resumption option\n");
- else
- g_print("current media session resumption option is : %d\n", option_r);
- }
- reset_menu_state();
+ g_print("current media session options are (%d) for starting, (%d) for ongoing\n", option_s, option_d);
}
+ reset_menu_state();
break;
- case CURRENT_STATUS_SET_VOIP_SESSION_MODE:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- sound_session_voip_mode_e mode;
- mode = (sound_session_voip_mode_e)atoi(cmd);
- ret = sound_manager_set_voip_session_mode(mode);
- if (ret) {
- g_print("failed to set voip session mode(%d), ret[0x%x]\n", mode, ret);
- } else {
- g_print("success to set voip session mode\n");
+ }
+ case CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION: {
+ static sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
+ static sound_session_option_for_resumption_e option_r;
+ if (sound_manager_set_session_type(type) != 0)
+ g_print("fail to set media session type\n");
+ else {
+ option_r = (sound_session_option_for_resumption_e)atoi(cmd);
+ if (SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM > option_r || SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED < option_r)
+ g_print("not supported option type\n");
+ else {
+ if (sound_manager_set_media_session_resumption_option(option_r) != 0)
+ g_print("fail to set media session resumption option\n");
+ else
+ g_print("succese to set media session resumption option\n");
}
- reset_menu_state();
}
+ reset_menu_state();
break;
- case CURRENT_STATUS_GET_VOIP_SESSION_MODE:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- sound_session_voip_mode_e mode;
- ret = sound_manager_get_voip_session_mode(&mode);
- if(ret)
- g_print("fail to get voip session mode, ret[0x%x]\n", ret);
+ }
+ case CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION: {
+ static sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
+ static sound_session_option_for_resumption_e option_r;
+ if (sound_manager_set_session_type(type) != 0)
+ g_print("fail to set media session type\n");
+ else {
+ if (sound_manager_get_media_session_resumption_option(&option_r) != 0)
+ g_print("fail to get media session resumption option\n");
else
- g_print("success to get voip session mode, mode[%d]\n", mode);
- reset_menu_state();
+ g_print("current media session resumption option is : %d\n", option_r);
}
+ reset_menu_state();
break;
- case CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB:
- {
- if(sound_manager_set_session_interrupted_cb(_set_session_interrupted_cb, NULL) != 0)
- g_print("fail to set interrupted changed cb\n");
- else
- g_print("success to set interrupted changed cb\n");
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_SET_VOIP_SESSION_MODE: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ sound_session_voip_mode_e mode;
+ mode = (sound_session_voip_mode_e)atoi(cmd);
+ ret = sound_manager_set_voip_session_mode(mode);
+ if (ret)
+ g_print("failed to set voip session mode(%d), ret[0x%x]\n", mode, ret);
+ else
+ g_print("success to set voip session mode\n");
+ reset_menu_state();
break;
- case CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB:
- {
- if(sound_manager_unset_session_interrupted_cb() != 0)
- g_print("fail to unset interrupted changed cb\n");
- else
- g_print("success to unset interrupted changed cb\n");
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_GET_VOIP_SESSION_MODE: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ sound_session_voip_mode_e mode;
+ ret = sound_manager_get_voip_session_mode(&mode);
+ if (ret)
+ g_print("fail to get voip session mode, ret[0x%x]\n", ret);
+ else
+ g_print("success to get voip session mode, mode[%d]\n", mode);
+ reset_menu_state();
break;
- case CURRENT_STATUS_SET_DEVICE_MASK:
- {
- if (strncmp(cmd, "0", 1) == 0) {
- g_device_mask = SOUND_DEVICE_ALL_MASK;
- reset_menu_state();
- } else if (strncmp(cmd, "1", 1) == 0) {
- if (g_device_mask == SOUND_DEVICE_ALL_MASK)
- g_device_mask = SOUND_DEVICE_TYPE_INTERNAL_MASK;
- else
- g_device_mask |= SOUND_DEVICE_TYPE_INTERNAL_MASK;
- g_print("add TYPE_INTERNAL MASK\n");
- } else if (strncmp(cmd, "2", 1) == 0) {
- if (g_device_mask == SOUND_DEVICE_ALL_MASK)
- g_device_mask = SOUND_DEVICE_TYPE_EXTERNAL_MASK;
- else
- g_device_mask |= SOUND_DEVICE_TYPE_EXTERNAL_MASK;
- g_print("add TYPE_EXTERNAL MASK\n");
- } else if (strncmp(cmd, "3", 1) == 0) {
- if (g_device_mask == SOUND_DEVICE_ALL_MASK)
- g_device_mask = SOUND_DEVICE_IO_DIRECTION_IN_MASK;
- else
- g_device_mask |= SOUND_DEVICE_IO_DIRECTION_IN_MASK;
- g_print("add IO_DIRECTION_IN MASK\n");
- } else if (strncmp(cmd, "4", 1) == 0) {
- if (g_device_mask == SOUND_DEVICE_ALL_MASK)
- g_device_mask = SOUND_DEVICE_IO_DIRECTION_OUT_MASK;
- else
- g_device_mask |= SOUND_DEVICE_IO_DIRECTION_OUT_MASK;
- g_print("add IO_DIRECTION_OUT MASK\n");
- } else if (strncmp(cmd, "5", 1) == 0) {
- if (g_device_mask == SOUND_DEVICE_ALL_MASK)
- g_device_mask = SOUND_DEVICE_IO_DIRECTION_BOTH_MASK;
- else
- g_device_mask |= SOUND_DEVICE_IO_DIRECTION_BOTH_MASK;
- g_print("add IO_DIRECTION_BOTH MASK\n");
- } else if (strncmp(cmd, "6", 1) == 0) {
- if (g_device_mask == SOUND_DEVICE_ALL_MASK)
- g_device_mask = SOUND_DEVICE_STATE_ACTIVATED_MASK;
- else
- g_device_mask |= SOUND_DEVICE_STATE_ACTIVATED_MASK;
- g_print("add STATE_ACTIVATED MASK\n");
- } else if (strncmp(cmd, "7", 1) == 0) {
- if (g_device_mask == SOUND_DEVICE_ALL_MASK)
- g_device_mask = SOUND_DEVICE_STATE_DEACTIVATED_MASK;
- else
- g_device_mask |= SOUND_DEVICE_STATE_DEACTIVATED_MASK;
- g_print("add STATE_DEACTIVATED MASK\n");
- } else if (strncmp(cmd, "b", 1) == 0) {
- g_print("device mask[0x%x]\n", g_device_mask);
- reset_menu_state();
- } else {
- g_print("invalid selection, please select again..\n");
- }
- }
+ }
+ case CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB: {
+ if (sound_manager_set_session_interrupted_cb(_set_session_interrupted_cb, NULL) != 0)
+ g_print("fail to set interrupted changed cb\n");
+ else
+ g_print("success to set interrupted changed cb\n");
+ reset_menu_state();
break;
- case CURRENT_STATUS_GET_DEVICE_MASK:
- {
- g_print("current device mask[0x%x]\n", g_device_mask);
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB: {
+ if (sound_manager_unset_session_interrupted_cb() != 0)
+ g_print("fail to unset interrupted changed cb\n");
+ else
+ g_print("success to unset interrupted changed cb\n");
+ reset_menu_state();
break;
- case CURRENT_STATUS_GET_DEVICE_LIST:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- if (!(ret = sound_manager_get_current_device_list(g_device_mask, &g_device_list)))
- g_print("success to get current device list\n");
+ }
+ case CURRENT_STATUS_SET_DEVICE_MASK: {
+ if (strncmp(cmd, "0", 1) == 0) {
+ g_device_mask = SOUND_DEVICE_ALL_MASK;
+ reset_menu_state();
+ } else if (strncmp(cmd, "1", 1) == 0) {
+ if (g_device_mask == SOUND_DEVICE_ALL_MASK)
+ g_device_mask = SOUND_DEVICE_TYPE_INTERNAL_MASK;
+ else
+ g_device_mask |= SOUND_DEVICE_TYPE_INTERNAL_MASK;
+ g_print("add TYPE_INTERNAL MASK\n");
+ } else if (strncmp(cmd, "2", 1) == 0) {
+ if (g_device_mask == SOUND_DEVICE_ALL_MASK)
+ g_device_mask = SOUND_DEVICE_TYPE_EXTERNAL_MASK;
else
- g_print("fail to get current device list, ret[0x%x]\n", ret);
+ g_device_mask |= SOUND_DEVICE_TYPE_EXTERNAL_MASK;
+ g_print("add TYPE_EXTERNAL MASK\n");
+ } else if (strncmp(cmd, "3", 1) == 0) {
+ if (g_device_mask == SOUND_DEVICE_ALL_MASK)
+ g_device_mask = SOUND_DEVICE_IO_DIRECTION_IN_MASK;
+ else
+ g_device_mask |= SOUND_DEVICE_IO_DIRECTION_IN_MASK;
+ g_print("add IO_DIRECTION_IN MASK\n");
+ } else if (strncmp(cmd, "4", 1) == 0) {
+ if (g_device_mask == SOUND_DEVICE_ALL_MASK)
+ g_device_mask = SOUND_DEVICE_IO_DIRECTION_OUT_MASK;
+ else
+ g_device_mask |= SOUND_DEVICE_IO_DIRECTION_OUT_MASK;
+ g_print("add IO_DIRECTION_OUT MASK\n");
+ } else if (strncmp(cmd, "5", 1) == 0) {
+ if (g_device_mask == SOUND_DEVICE_ALL_MASK)
+ g_device_mask = SOUND_DEVICE_IO_DIRECTION_BOTH_MASK;
+ else
+ g_device_mask |= SOUND_DEVICE_IO_DIRECTION_BOTH_MASK;
+ g_print("add IO_DIRECTION_BOTH MASK\n");
+ } else if (strncmp(cmd, "6", 1) == 0) {
+ if (g_device_mask == SOUND_DEVICE_ALL_MASK)
+ g_device_mask = SOUND_DEVICE_STATE_ACTIVATED_MASK;
+ else
+ g_device_mask |= SOUND_DEVICE_STATE_ACTIVATED_MASK;
+ g_print("add STATE_ACTIVATED MASK\n");
+ } else if (strncmp(cmd, "7", 1) == 0) {
+ if (g_device_mask == SOUND_DEVICE_ALL_MASK)
+ g_device_mask = SOUND_DEVICE_STATE_DEACTIVATED_MASK;
+ else
+ g_device_mask |= SOUND_DEVICE_STATE_DEACTIVATED_MASK;
+ g_print("add STATE_DEACTIVATED MASK\n");
+ } else if (strncmp(cmd, "b", 1) == 0) {
+ g_print("device mask[0x%x]\n", g_device_mask);
reset_menu_state();
+ } else {
+ g_print("invalid selection, please select again..\n");
}
break;
- case CURRENT_STATUS_GET_DEVICE_NEXT:
- {
- sound_device_h device;
- sound_device_type_e type;
- sound_device_io_direction_e io_direction;
- sound_device_state_e state;
- int id;
- char *name;
- int ret = SOUND_MANAGER_ERROR_NONE;
- if (!(ret = sound_manager_get_next_device(g_device_list, &device))) {
- g_print("success to get next device\n");
- if ((ret = sound_manager_get_device_type (device, &type)))
- g_print("failed to get device type, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_io_direction (device, &io_direction)))
- g_print("failed to get device io direction, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_id (device, &id)))
- g_print("failed to get device id, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_name (device, &name)))
- g_print("failed to get device name, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_state (device, &state)))
- g_print("failed to get device state, ret[0x%x]\n", ret);
- if (!ret)
- g_print("-- NEXT device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state);
- } else {
- g_print("failed to get next device, ret[0x%x]\n", ret);
- }
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_GET_DEVICE_MASK: {
+ g_print("current device mask[0x%x]\n", g_device_mask);
+ reset_menu_state();
break;
- case CURRENT_STATUS_GET_DEVICE_PREV:
- {
- sound_device_h device;
- sound_device_type_e type;
- sound_device_io_direction_e io_direction;
- sound_device_state_e state;
- int id;
- char *name;
- int ret = SOUND_MANAGER_ERROR_NONE;
- if (!(ret = sound_manager_get_prev_device(g_device_list, &device))) {
- g_print("success to get previous device\n");
- if ((ret = sound_manager_get_device_type (device, &type)))
- g_print("failed to get device type, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_io_direction (device, &io_direction)))
- g_print("failed to get device io direction, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_id (device, &id)))
- g_print("failed to get device id, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_name (device, &name)))
- g_print("failed to get device name, ret[0x%x]\n", ret);
- if ((ret = sound_manager_get_device_state (device, &state)))
- g_print("failed to get device state, ret[0x%x]\n", ret);
- if (!ret)
- g_print("-- PREV device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state);
- } else {
- g_print("failed to get previous device, ret[0x%x]\n", ret);
- }
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_GET_DEVICE_LIST: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ if (!(ret = sound_manager_get_current_device_list(g_device_mask, &g_device_list)))
+ g_print("success to get current device list\n");
+ else
+ g_print("fail to get current device list, ret[0x%x]\n", ret);
+ reset_menu_state();
break;
- case CURRENT_STATUS_SET_DEVICE_CONNECTED_CB:
- {
- if (sound_manager_set_device_connected_cb(g_device_mask, _set_device_connected_cb, NULL))
- g_print("fail to set device connected cb\n");
- else
- g_print("success to set device connected cb\n");
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_GET_DEVICE_NEXT: {
+ sound_device_h device;
+ sound_device_type_e type;
+ sound_device_io_direction_e io_direction;
+ sound_device_state_e state;
+ int id;
+ char *name;
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ if (!(ret = sound_manager_get_next_device(g_device_list, &device))) {
+ g_print("success to get next device\n");
+ if ((ret = sound_manager_get_device_type(device, &type)))
+ g_print("failed to get device type, ret[0x%x]\n", ret);
+ if ((ret = sound_manager_get_device_io_direction(device, &io_direction)))
+ g_print("failed to get device io direction, ret[0x%x]\n", ret);
+ if ((ret = sound_manager_get_device_id(device, &id)))
+ g_print("failed to get device id, ret[0x%x]\n", ret);
+ if ((ret = sound_manager_get_device_name(device, &name)))
+ g_print("failed to get device name, ret[0x%x]\n", ret);
+ if ((ret = sound_manager_get_device_state(device, &state)))
+ g_print("failed to get device state, ret[0x%x]\n", ret);
+ if (!ret)
+ g_print("-- NEXT device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state);
+ } else {
+ g_print("failed to get next device, ret[0x%x]\n", ret);
+ }
+ reset_menu_state();
break;
- case CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB:
- {
- if (sound_manager_unset_device_connected_cb())
- g_print("fail to unset device connected cb\n");
- else
- g_print("success to unset device connected cb\n");
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_GET_DEVICE_PREV: {
+ sound_device_h device;
+ sound_device_type_e type;
+ sound_device_io_direction_e io_direction;
+ sound_device_state_e state;
+ int id;
+ char *name;
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ if (!(ret = sound_manager_get_prev_device(g_device_list, &device))) {
+ g_print("success to get previous device\n");
+ if ((ret = sound_manager_get_device_type(device, &type)))
+ g_print("failed to get device type, ret[0x%x]\n", ret);
+ if ((ret = sound_manager_get_device_io_direction(device, &io_direction)))
+ g_print("failed to get device io direction, ret[0x%x]\n", ret);
+ if ((ret = sound_manager_get_device_id(device, &id)))
+ g_print("failed to get device id, ret[0x%x]\n", ret);
+ if ((ret = sound_manager_get_device_name(device, &name)))
+ g_print("failed to get device name, ret[0x%x]\n", ret);
+ if ((ret = sound_manager_get_device_state(device, &state)))
+ g_print("failed to get device state, ret[0x%x]\n", ret);
+ if (!ret)
+ g_print("-- PREV device type[%d], io_direction[%d], id[%d], name[%s], state[%d]\n", type, io_direction, id, name, state);
+ } else {
+ g_print("failed to get previous device, ret[0x%x]\n", ret);
+ }
+ reset_menu_state();
break;
- case CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB:
- {
- if (sound_manager_set_device_information_changed_cb(g_device_mask, _set_device_info_changed_cb, NULL))
- g_print("fail to set device information changed cb\n");
- else
- g_print("success to set device information changed cb\n");
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_SET_DEVICE_CONNECTED_CB: {
+ if (sound_manager_set_device_connected_cb(g_device_mask, _set_device_connected_cb, NULL))
+ g_print("fail to set device connected cb\n");
+ else
+ g_print("success to set device connected cb\n");
+ reset_menu_state();
break;
- case CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB:
- {
- if (sound_manager_unset_device_information_changed_cb())
- g_print("fail to unset device information changed cb\n");
- else
- g_print("success to unset device information changed cb\n");
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB: {
+ if (sound_manager_unset_device_connected_cb())
+ g_print("fail to unset device connected cb\n");
+ else
+ g_print("success to unset device connected cb\n");
+ reset_menu_state();
break;
- case CURRENT_STATUS_CREATE_STREAM_INFO:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- int stream_type = 0;
- sound_stream_type_e type = SOUND_STREAM_TYPE_MEDIA;
- if (g_stream_info_h) {
- g_print("fail to create stream information, g_stream_info_h(%p) is already set\n", g_stream_info_h);
- reset_menu_state();
- break;
- }
- stream_type = atoi(cmd);
- switch(stream_type) {
- case 0: /* media */
- type = SOUND_STREAM_TYPE_MEDIA;
- break;
- case 1: /* alarm */
- type = SOUND_STREAM_TYPE_ALARM;
- break;
- case 2: /* notification */
- type = SOUND_STREAM_TYPE_NOTIFICATION;
- break;
- case 3: /* ringtone for call*/
- type = SOUND_STREAM_TYPE_RINGTONE_CALL;
- break;
- case 4: /* voice call */
- type = SOUND_STREAM_TYPE_VOICE_CALL;
- break;
- case 5: /* voip */
- type = SOUND_STREAM_TYPE_VOIP;
- break;
- case 6: /* media only for external devices */
- type = SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY;
- break;
- default:
- type = SOUND_STREAM_TYPE_MEDIA;
- break;
- }
- if (type == (int)SOUND_STREAM_TYPE_RINGTONE_CALL || type == (int)SOUND_STREAM_TYPE_VOICE_CALL) {
- ret = sound_manager_create_stream_information_internal(type, focus_callback, NULL, &g_stream_info_h);
- } else {
- ret = sound_manager_create_stream_information(type, focus_callback, NULL, &g_stream_info_h);
- }
- if (ret) {
- g_print("fail to sound_manager_create_stream_information(), ret(0x%x)\n", ret);
- }
+ }
+ case CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB: {
+ if (sound_manager_set_device_information_changed_cb(g_device_mask, _set_device_info_changed_cb, NULL))
+ g_print("fail to set device information changed cb\n");
+ else
+ g_print("success to set device information changed cb\n");
+ reset_menu_state();
+ break;
+ }
+ case CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB: {
+ if (sound_manager_unset_device_information_changed_cb())
+ g_print("fail to unset device information changed cb\n");
+ else
+ g_print("success to unset device information changed cb\n");
+ reset_menu_state();
+ break;
+ }
+ case CURRENT_STATUS_CREATE_STREAM_INFO: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ int stream_type = 0;
+ sound_stream_type_e type = SOUND_STREAM_TYPE_MEDIA;
+ if (g_stream_info_h) {
+ g_print("fail to create stream information, g_stream_info_h(%p) is already set\n", g_stream_info_h);
reset_menu_state();
- }
+ break;
+ }
+ stream_type = atoi(cmd);
+ switch (stream_type) {
+ case 0: /* media */
+ type = SOUND_STREAM_TYPE_MEDIA;
+ break;
+ case 1: /* alarm */
+ type = SOUND_STREAM_TYPE_ALARM;
+ break;
+ case 2: /* notification */
+ type = SOUND_STREAM_TYPE_NOTIFICATION;
+ break;
+ case 3: /* ringtone for call*/
+ type = SOUND_STREAM_TYPE_RINGTONE_CALL;
+ break;
+ case 4: /* voice call */
+ type = SOUND_STREAM_TYPE_VOICE_CALL;
+ break;
+ case 5: /* voip */
+ type = SOUND_STREAM_TYPE_VOIP;
+ break;
+ case 6: /* media only for external devices */
+ type = SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY;
+ break;
+ default:
+ type = SOUND_STREAM_TYPE_MEDIA;
+ break;
+ }
+ if (type == (int)SOUND_STREAM_TYPE_RINGTONE_CALL || type == (int)SOUND_STREAM_TYPE_VOICE_CALL)
+ ret = sound_manager_create_stream_information_internal(type, focus_callback, NULL, &g_stream_info_h);
+ else
+ ret = sound_manager_create_stream_information(type, focus_callback, NULL, &g_stream_info_h);
+
+ if (ret)
+ g_print("fail to sound_manager_create_stream_information(), ret(0x%x)\n", ret);
+
+ reset_menu_state();
break;
- case CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- int device_type = 0;
- sound_device_h device = NULL;
- sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
- sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
- bool need_to_go = false;
- device_type = atoi(cmd);
- switch(device_type) {
- case 0: /* built-in mic */
- selected_type = SOUND_DEVICE_BUILTIN_MIC;
- break;
- case 1: /* built-in spk */
- selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
- break;
- case 2: /* built-in rcv */
- selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
- break;
- case 3: /* audio-jack */
- selected_type = SOUND_DEVICE_AUDIO_JACK;
- break;
- case 4: /* bt */
- selected_type = SOUND_DEVICE_BLUETOOTH;
- break;
- default:
- g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
- reset_menu_state();
- break;
- }
- if (!(ret = sound_manager_get_current_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
- g_print("success to get current device list\n");
- while (!sound_manager_get_next_device(g_device_list, &device)) {
- if (!(ret = sound_manager_get_device_type (device, &type))) {
- if (selected_type == type) {
- need_to_go = true;
- break;
- }
- } else {
- g_print("fail to get type of device, ret(0x%x)\n", ret);
- reset_menu_state();
+ }
+ case CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ int device_type = 0;
+ sound_device_h device = NULL;
+ sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
+ sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
+ bool need_to_go = false;
+
+ device_type = atoi(cmd);
+ switch (device_type) {
+ case 0: /* built-in mic */
+ selected_type = SOUND_DEVICE_BUILTIN_MIC;
+ break;
+ case 1: /* built-in spk */
+ selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
+ break;
+ case 2: /* built-in rcv */
+ selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
+ break;
+ case 3: /* audio-jack */
+ selected_type = SOUND_DEVICE_AUDIO_JACK;
+ break;
+ case 4: /* bt */
+ selected_type = SOUND_DEVICE_BLUETOOTH;
+ break;
+ default:
+ g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
+ reset_menu_state();
+ break;
+ }
+ if (!(ret = sound_manager_get_current_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
+ g_print("success to get current device list\n");
+ while (!sound_manager_get_next_device(g_device_list, &device)) {
+ if (!(ret = sound_manager_get_device_type(device, &type))) {
+ if (selected_type == type) {
+ need_to_go = true;
break;
}
- }
- if (need_to_go) {
- ret = sound_manager_add_device_for_stream_routing (g_stream_info_h, device);
- if (ret) {
- g_print("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
- }
} else {
- g_print("the device is not available now\n");
+ g_print("fail to get type of device, ret(0x%x)\n", ret);
+ reset_menu_state();
+ break;
}
- reset_menu_state();
- } else {
- g_print("fail to get current device list, ret(0x%x)\n", ret);
- reset_menu_state();
}
+ if (need_to_go) {
+ ret = sound_manager_add_device_for_stream_routing(g_stream_info_h, device);
+ if (ret)
+ g_print("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
+ } else
+ g_print("the device is not available now\n");
+ reset_menu_state();
+ } else {
+ g_print("fail to get current device list, ret(0x%x)\n", ret);
+ reset_menu_state();
}
break;
- case CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- int device_type = 0;
- sound_device_h device = NULL;
- sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
- sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
- bool need_to_go = false;
- device_type = atoi(cmd);
- switch(device_type) {
- case 0: /* built-in mic */
- selected_type = SOUND_DEVICE_BUILTIN_MIC;
- break;
- case 1: /* built-in spk */
- selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
- break;
- case 2: /* built-in rcv */
- selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
- break;
- case 3: /* audio-jack */
- selected_type = SOUND_DEVICE_AUDIO_JACK;
- break;
- case 4: /* bt */
- selected_type = SOUND_DEVICE_BLUETOOTH;
- break;
- default:
- g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
- reset_menu_state();
- break;
- }
- if (!(ret = sound_manager_get_current_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
- g_print("success to get current device list\n");
- while (!sound_manager_get_next_device(g_device_list, &device)) {
- if (!(ret = sound_manager_get_device_type (device, &type))) {
- if (selected_type == type) {
- need_to_go = true;
- break;
- }
- } else {
- g_print("fail to get type of device, ret(0x%x)\n", ret);
- reset_menu_state();
+ }
+ case CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ int device_type = 0;
+ sound_device_h device = NULL;
+ sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
+ sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
+ bool need_to_go = false;
+
+ device_type = atoi(cmd);
+ switch (device_type) {
+ case 0: /* built-in mic */
+ selected_type = SOUND_DEVICE_BUILTIN_MIC;
+ break;
+ case 1: /* built-in spk */
+ selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
+ break;
+ case 2: /* built-in rcv */
+ selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
+ break;
+ case 3: /* audio-jack */
+ selected_type = SOUND_DEVICE_AUDIO_JACK;
+ break;
+ case 4: /* bt */
+ selected_type = SOUND_DEVICE_BLUETOOTH;
+ break;
+ default:
+ g_print("invalid argument, device_type(%d) is not valid for this feature\n", device_type);
+ reset_menu_state();
+ break;
+ }
+ if (!(ret = sound_manager_get_current_device_list(SOUND_DEVICE_ALL_MASK, &g_device_list))) {
+ g_print("success to get current device list\n");
+ while (!sound_manager_get_next_device(g_device_list, &device)) {
+ if (!(ret = sound_manager_get_device_type(device, &type))) {
+ if (selected_type == type) {
+ need_to_go = true;
break;
}
- }
- if (need_to_go) {
- ret = sound_manager_remove_device_for_stream_routing (g_stream_info_h, device);
- if (ret) {
- g_print("failed to sound_manager_remove_device_for_stream_routing(), ret(0x%x)\n", ret);
- }
} else {
- g_print("the device is not available now\n");
+ g_print("fail to get type of device, ret(0x%x)\n", ret);
+ reset_menu_state();
+ break;
}
+ }
+ if (need_to_go) {
+ ret = sound_manager_remove_device_for_stream_routing(g_stream_info_h, device);
+ if (ret)
+ g_print("failed to sound_manager_remove_device_for_stream_routing(), ret(0x%x)\n", ret);
+ else
+ g_print("the device is not available now\n");
reset_menu_state();
} else {
g_print("fail to get current device list, ret(0x%x)\n", ret);
}
}
break;
- case CURRENT_STATUS_APPLY_STREAM_ROUTING:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- ret = sound_manager_apply_stream_routing (g_stream_info_h);
- if (ret) {
- g_print("failed to sound_manager_apply_stream_routing(), ret(0x%x)\n", ret);
- }
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_APPLY_STREAM_ROUTING: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ ret = sound_manager_apply_stream_routing(g_stream_info_h);
+ if (ret)
+ g_print("failed to sound_manager_apply_stream_routing(), ret(0x%x)\n", ret);
+
+ reset_menu_state();
break;
- case CURRENT_STATUS_SET_STREAM_ROUTING_OPTION:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- int selection = 0;
- char *name = NULL;
- int value = -1;
- selection = atoi(cmd);
- switch(selection) {
- case 0:
- name = "option_1";
- value = 0;
- break;
- case 1:
- name = "option_1";
- value = 1;
- break;
- case 2:
- name = "option_2";
- value = 0;
- break;
- case 3:
- name = "option_2";
- value = 1;
- break;
- default:
- g_print("invalid argument, try again..\n");
- reset_menu_state();
- break;
- }
- ret = sound_manager_set_stream_routing_option (g_stream_info_h, name, value);
- if (ret) {
- g_print("failed to sound_manager_set_stream_routing_option(), ret(0x%x)\n", ret);
- }
+ }
+ case CURRENT_STATUS_SET_STREAM_ROUTING_OPTION: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ int selection = 0;
+ char *name = NULL;
+ int value = -1;
+
+ selection = atoi(cmd);
+ switch (selection) {
+ case 0:
+ name = "option_1";
+ value = 0;
+ break;
+ case 1:
+ name = "option_1";
+ value = 1;
+ break;
+ case 2:
+ name = "option_2";
+ value = 0;
+ break;
+ case 3:
+ name = "option_2";
+ value = 1;
+ break;
+ default:
+ g_print("invalid argument, try again..\n");
reset_menu_state();
+ break;
}
+ ret = sound_manager_set_stream_routing_option(g_stream_info_h, name, value);
+ if (ret)
+ g_print("failed to sound_manager_set_stream_routing_option(), ret(0x%x)\n", ret);
+
+ reset_menu_state();
break;
- case CURRENT_STATUS_ACQUIRE_FOCUS:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- int focus_type = 0;
- sound_stream_focus_mask_e focus_mask;
- focus_type = atoi(cmd);
- switch(focus_type) {
- case 0: /* playback */
- focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
- break;
- case 1: /* recording */
- focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
- break;
- case 2: /* all */
- focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING;
- break;
- default:
- focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
- break;
- }
- ret = sound_manager_acquire_focus(g_stream_info_h, focus_mask, NULL);
- if (ret) {
- g_print("fail to sound_manager_acquire_focus(), ret(0x%x)\n", ret);
- }
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_ACQUIRE_FOCUS: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ int focus_type = 0;
+ sound_stream_focus_mask_e focus_mask;
+
+ focus_type = atoi(cmd);
+ switch (focus_type) {
+ case 0: /* playback */
+ focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
+ break;
+ case 1: /* recording */
+ focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
+ break;
+ case 2: /* all */
+ focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING;
+ break;
+ default:
+ focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
+ break;
+ }
+ ret = sound_manager_acquire_focus(g_stream_info_h, focus_mask, NULL);
+ if (ret)
+ g_print("fail to sound_manager_acquire_focus(), ret(0x%x)\n", ret);
+
+ reset_menu_state();
break;
- case CURRENT_STATUS_RELEASE_FOCUS:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- int focus_type = 0;
- sound_stream_focus_mask_e focus_mask;
- focus_type = atoi(cmd);
- switch(focus_type) {
- case 0: /* playback */
- focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
- break;
- case 1: /* recording */
- focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
- break;
- case 2: /* both */
- focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING;
- break;
- default:
- focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
- break;
- }
- ret = sound_manager_release_focus(g_stream_info_h, focus_mask, NULL);
- if (ret) {
+ }
+ case CURRENT_STATUS_RELEASE_FOCUS: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ int focus_type = 0;
+ sound_stream_focus_mask_e focus_mask;
+
+ focus_type = atoi(cmd);
+ switch (focus_type) {
+ case 0: /* playback */
+ focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
+ break;
+ case 1: /* recording */
+ focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
+ break;
+ case 2: /* both */
+ focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING;
+ break;
+ default:
+ focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
+ break;
+ }
+ ret = sound_manager_release_focus(g_stream_info_h, focus_mask, NULL);
+ if (ret)
g_print("fail to sound_manager_acquire_focus(), ret(0x%x)\n", ret);
- }
- reset_menu_state();
- }
+
+ reset_menu_state();
break;
- case CURRENT_STATUS_GET_ACQUIRED_FOCUS:
- {
- sound_stream_focus_state_e for_playback;
- sound_stream_focus_state_e for_recording;
- int ret = SOUND_MANAGER_ERROR_NONE;
- if(g_stream_info_h) {
- ret = sound_manager_get_focus_state(g_stream_info_h, &for_playback, &for_recording);
- if (ret) {
- g_print("fail to sound_manager_get_focus_state(), ret(0x%x)\n", ret);
- } else {
- g_print("focus_state(playback:%d, capture:%d)\n", for_playback, for_recording);
- }
- } else {
- g_print("please create stream info. first\n");
- }
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_GET_ACQUIRED_FOCUS: {
+ sound_stream_focus_state_e for_playback;
+ sound_stream_focus_state_e for_recording;
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ if (g_stream_info_h) {
+ ret = sound_manager_get_focus_state(g_stream_info_h, &for_playback, &for_recording);
+ if (ret)
+ g_print("fail to sound_manager_get_focus_state(), ret(0x%x)\n", ret);
+ else
+ g_print("focus_state(playback:%d, capture:%d)\n", for_playback, for_recording);
+
+ } else
+ g_print("please create stream info. first\n");
+
+ reset_menu_state();
break;
- case CURRENT_STATUS_DESTROY_STREAM_INFO:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- ret = sound_manager_destroy_stream_information(g_stream_info_h);
- if (ret) {
- g_print("fail to sound_manager_destroy_stream_information(), ret(0x%x)\n", ret);
- } else {
- g_stream_info_h = NULL;
- }
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_DESTROY_STREAM_INFO: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ ret = sound_manager_destroy_stream_information(g_stream_info_h);
+ if (ret)
+ g_print("fail to sound_manager_destroy_stream_information(), ret(0x%x)\n", ret);
+ else
+ g_stream_info_h = NULL;
+
+ reset_menu_state();
break;
- case CURRENT_STATUS_SET_FOCUS_WATCH_CB:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- int focus_type = 0;
- sound_stream_focus_mask_e focus_mask;
- focus_type = atoi(cmd);
- switch(focus_type) {
- case 0: /* playback */
- focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
- break;
- case 1: /* recording */
- focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
- break;
- case 2: /* both */
- focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING;
- break;
- default:
- focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
- break;
- }
- ret = sound_manager_set_focus_state_watch_cb(focus_mask, focus_watch_callback, NULL);
- if (ret) {
- g_print("fail to sound_manager_set_focus_state_watch_cb(), ret(0x%x)\n", ret);
- }
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_SET_FOCUS_WATCH_CB: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ int focus_type = 0;
+ sound_stream_focus_mask_e focus_mask;
+
+ focus_type = atoi(cmd);
+ switch (focus_type) {
+ case 0: /* playback */
+ focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
+ break;
+ case 1: /* recording */
+ focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING;
+ break;
+ case 2: /* both */
+ focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING;
+ break;
+ default:
+ focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK;
+ break;
+ }
+ ret = sound_manager_set_focus_state_watch_cb(focus_mask, focus_watch_callback, NULL);
+ if (ret)
+ g_print("fail to sound_manager_set_focus_state_watch_cb(), ret(0x%x)\n", ret);
+
+ reset_menu_state();
break;
- case CURRENT_STATUS_UNSET_FOCUS_WATCH_CB:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- ret = sound_manager_unset_focus_state_watch_cb();
- if (ret) {
- g_print("fail to sound_manager_unset_focus_state_watch_cb(), ret(0x%x)\n", ret);
- }
- reset_menu_state();
- }
+ }
+ case CURRENT_STATUS_UNSET_FOCUS_WATCH_CB: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ ret = sound_manager_unset_focus_state_watch_cb();
+ if (ret)
+ g_print("fail to sound_manager_unset_focus_state_watch_cb(), ret(0x%x)\n", ret);
+ reset_menu_state();
break;
- case CURRENT_STATUS_CREATE_VIRTUAL_STREAM:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- if (!g_stream_info_h || g_vstream_h) {
- g_print("fail to create virtual stream, g_stream_info_h(%p)/g_vstream_h(%p)\n", g_stream_info_h, g_vstream_h);
- reset_menu_state();
- break;
- }
- ret = sound_manager_create_virtual_stream(g_stream_info_h, &g_vstream_h);
- if (ret) {
- g_print("fail to sound_manager_create_virtual_stream(), ret(0x%x)\n", ret);
- } else {
- g_print("success to sound_manager_create_virtual_stream(), ret(0x%x)\n", ret);
- }
+ }
+ case CURRENT_STATUS_CREATE_VIRTUAL_STREAM: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ if (!g_stream_info_h || g_vstream_h) {
+ g_print("fail to create virtual stream, g_stream_info_h(%p)/g_vstream_h(%p)\n", g_stream_info_h, g_vstream_h);
reset_menu_state();
+ break;
}
+ ret = sound_manager_create_virtual_stream(g_stream_info_h, &g_vstream_h);
+ if (ret)
+ g_print("fail to sound_manager_create_virtual_stream(), ret(0x%x)\n", ret);
+ else
+ g_print("success to sound_manager_create_virtual_stream(), ret(0x%x)\n", ret);
+
+ reset_menu_state();
break;
- case CURRENT_STATUS_START_VIRTUAL_STREAM:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- if (g_vstream_h) {
- ret = sound_manager_start_virtual_stream(g_vstream_h);
- if (ret) {
- g_print("fail to sound_manager_start_virtual_stream(), ret(0x%x)\n", ret);
- } else {
- g_print("success to sound_manager_start_virtual_stream(), ret(0x%x)\n", ret);
- }
- }
- reset_menu_state();
+ }
+ case CURRENT_STATUS_START_VIRTUAL_STREAM: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ if (g_vstream_h) {
+ ret = sound_manager_start_virtual_stream(g_vstream_h);
+ if (ret)
+ g_print("fail to sound_manager_start_virtual_stream(), ret(0x%x)\n", ret);
+ else
+ g_print("success to sound_manager_start_virtual_stream(), ret(0x%x)\n", ret);
}
+ reset_menu_state();
break;
- case CURRENT_STATUS_STOP_VIRTUAL_STREAM:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- if (g_vstream_h) {
- ret = sound_manager_stop_virtual_stream(g_vstream_h);
- if (ret) {
- g_print("fail to sound_manager_stop_virtual_stream(), ret(0x%x)\n", ret);
- } else {
- g_print("success to sound_manager_stop_virtual_stream(), ret(0x%x)\n", ret);
- }
- }
- reset_menu_state();
+ }
+ case CURRENT_STATUS_STOP_VIRTUAL_STREAM: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ if (g_vstream_h) {
+ ret = sound_manager_stop_virtual_stream(g_vstream_h);
+ if (ret)
+ g_print("fail to sound_manager_stop_virtual_stream(), ret(0x%x)\n", ret);
+ else
+ g_print("success to sound_manager_stop_virtual_stream(), ret(0x%x)\n", ret);
}
+ reset_menu_state();
break;
- case CURRENT_STATUS_DESTROY_VIRTUAL_STREAM:
- {
- int ret = SOUND_MANAGER_ERROR_NONE;
- if (g_vstream_h) {
- ret = sound_manager_destroy_virtual_stream(g_vstream_h);
- if (ret) {
- g_print("fail to sound_manager_destroy_virtual_stream(), ret(0x%x)\n", ret);
- } else {
- g_print("success to sound_manager_destroy_virtual_stream(), ret(0x%x)\n", ret);
- }
- g_vstream_h = NULL;
- }
- reset_menu_state();
+ }
+ case CURRENT_STATUS_DESTROY_VIRTUAL_STREAM: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ if (g_vstream_h) {
+ ret = sound_manager_destroy_virtual_stream(g_vstream_h);
+ if (ret)
+ g_print("fail to sound_manager_destroy_virtual_stream(), ret(0x%x)\n", ret);
+ else
+ g_print("success to sound_manager_destroy_virtual_stream(), ret(0x%x)\n", ret);
+ g_vstream_h = NULL;
}
+ reset_menu_state();
break;
}
+ }
g_timeout_add(100, timeout_menu_display, 0);
}
-gboolean input (GIOChannel *channel)
+gboolean input(GIOChannel *channel)
{
- gchar buf[MAX_STRING_LEN];
- gsize read;
- GError *error = NULL;
+ gchar buf[MAX_STRING_LEN];
+ gsize read;
+ GError *error = NULL;
- g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
- buf[read] = '\0';
- g_strstrip(buf);
- interpret (buf);
+ g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
+ buf[read] = '\0';
+ g_strstrip(buf);
+ interpret(buf);
- return TRUE;
+ return TRUE;
}
int main(int argc, char *argv[])
{
GIOChannel *stdin_channel;
stdin_channel = g_io_channel_unix_new(0);
- g_io_channel_set_flags (stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
+ g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
- g_loop = g_main_loop_new (NULL, 1);
+ g_loop = g_main_loop_new(NULL, 1);
displaymenu();
- g_main_loop_run (g_loop);
+ g_main_loop_run(g_loop);
return 0;
}