SET(submodule "sound-manager")
# for package file
-SET(dependents "mm-sound dlog capi-base-common mm-session libpulse gio-2.0 vconf capi-system-info")
+SET(dependents "mm-sound dlog capi-base-common libpulse gio-2.0 vconf")
SET(pc_dependents "capi-base-common")
# for deb
/**
* @ingroup CAPI_MEDIA_FRAMEWORK
* @defgroup CAPI_MEDIA_SOUND_MANAGER_MODULE Sound Manager
- * @brief The @ref CAPI_MEDIA_SOUND_MANAGER_MODULE API provides functions to get and set sound parameters like volume, stream policy, session policy and devices.
+ * @brief The @ref CAPI_MEDIA_SOUND_MANAGER_MODULE API provides functions to get and set sound parameters like volume, stream policy and devices.
*
* @section CAPI_MEDIA_SOUND_MANAGER_MODULE_HEADER Required Header
* \#include <sound_manager.h>
* - handle a volume changed notification
* - determine/control a sound stream policy
* - handle the notification of a sound focus status change
- * - determine a sound session policy (Deprecated)
- * - handle the notification of a sound session interruption (Deprecated)
* - query the basic information of connected sound devices
- * - handle the notification for connection of a sound device, and for changed information of a sound device
+ * - handle the notification for connection of a sound device
*
* @subsection CAPI_MEDIA_SOUND_MANAGER_LIFE_CYCLE_ASYNCHRONOUS_OPERATIONS Asynchronous operations
* The Sound Manager API allows only asynchronous operations. \n
* <li> sound_manager_volume_changed_cb() - invoked when volume level is changed.<p></li>
* <li> sound_stream_focus_state_changed_cb() - invoked when the state of focus that belongs to the stream_info is changed.<p></li>
* <li> sound_stream_focus_state_watch_cb() - invoked when the focus state for each sound stream type is changed.<p></li>
- * <li> sound_session_interrupted_cb() - invoked when the session is interrupted. (Deprecated)<p></li>
- * <li> sound_device_connected_cb() - invoked when the connection of a sound device is changed.<p></li>
- * <li> sound_device_information_changed_cb() - invoked when the information of a sound device is changed.<p></li>
+ * <li> sound_device_connection_changed_cb() - invoked when the connection of a sound device is changed.<p></li>
* </ul>
*
* @subsection CAPI_MEDIA_SOUND_MANAGER_MODULE_LIFE_CYCLE_CALLBACK_OPERATIONS Callback(Event) Operations
* <th><b> DESCRIPTION</b></th>
* </tr>
* <tr>
- * <td> sound_manager_set_volume_changed_cb()</td>
- * <td> sound_manager_unset_volume_changed_cb()</td>
+ * <td> sound_manager_add_volume_changed_cb()</td>
+ * <td> sound_manager_remove_volume_changed_cb()</td>
* <td> sound_manager_volume_changed_cb()</td>
* <td> This callback is called when volume value is changed.</td>
* </tr>
* <td> This callback is called when the focus state for each sound stream type is changed regardless of the process.</td>
* </tr>
* <tr>
- * <td> sound_manager_set_session_interrupted_cb()</td>
- * <td> sound_manager_unset_session_interrupted_cb()</td>
- * <td> sound_session_interrupted_cb()</td>
- * <td> This callback is called when audio session is interrupted. (Deprecated)</td>
- * </tr>
- * <tr>
- * <td> sound_manager_set_device_connected_cb()</td>
- * <td> sound_manager_unset_device_connected_cb()</td>
+ * <td> sound_manager_add_device_connection_changed_cb()</td>
+ * <td> sound_manager_remove_device_connection_changed_cb()</td>
* <td> sound_device_connected_cb()</td>
* <td> This callback is called when the connection of a sound device is changed.</td>
* </tr>
- * <tr>
- * <td> sound_manager_set_device_information_changed_cb()</td>
- * <td> sound_manager_unset_device_information_changed_cb()</td>
- * <td> sound_device_information_changed_cb()</td>
- * <td> This callback is called when the information of a sound device is changed.</td>
- * </tr>
* </table></div>
*
*/
* The volume level of each type can be adjusted with sound_manager_set_volume().
*
* The type of currently playing sound may be obtained by calling sound_manager_get_current_sound_type().
- * To set the type of the currently playing sound forcibly, call sound_manager_set_current_sound_type().
*
*
*/
*
*/
-/**
- * @ingroup CAPI_MEDIA_SOUND_MANAGER_MODULE
- * @defgroup CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE Session
- * @brief The @ref CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE API provides functions to control a session. (Deprecated)
- * @section CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE_HEADER Required Header
- * \#include <sound_manager.h>
- *
- * @section CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE_OVERVIEW Overview
- * The Sound Manager Session API allows you to:
- * - determine a sound session policy
- * - handle the notification of a sound session interruption
- *
- * The Sound Manager has predefined sound sessions (media, alarm, notification, emergency, voip)
- *
- * @section CAPI_MEDIA_SOUND_MANAGER_MODULE_FEATURE Related Features
- * APIs for voip sound session and voip stream type are related with the following features:\n
- * - http://tizen.org/feature/microphone\n
- *
- * It is recommended to design feature related codes in your application for reliability.\n
- *
- * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
- *
- * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
- *
- * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>Feature Element</b>.</a>
- *
-*/
-
/**
* @ingroup CAPI_MEDIA_SOUND_MANAGER_MODULE
* @defgroup CAPI_MEDIA_SOUND_MANAGER_DEVICE_MODULE Device
* @section CAPI_MEDIA_SOUND_MANAGER_DEVICE_MODULE_OVERVIEW Overview
* The Sound Manager Device API allows you to:
* - query the basic information of connected sound devices.
- * - handle the sound device's connection and information change notification.
+ * - handle the sound device's connection state change notification.
*
- * The list of currently connected sound device can be obtained by calling sound_manager_get_current_device_list().
+ * The list of currently connected sound device can be obtained by calling sound_manager_get_device_list().
* To get the handle of each sound device, call sound_manager_get_next_device() and sound_manager_get_prev_device().
*
- * Device information, such as "type", "IO direction", "state", "ID", "name", can be obtained by calling corresponding APIs.
+ * Device information, such as "type", "IO direction", "ID", "name", can be obtained by calling corresponding APIs.
*
*
*/
SOUND_BEHAVIOR_FADING = 0x0002, /**< Fading effect */
} sound_behavior_e;
-/**
- * @}
- */
-
-/**
- * @addtogroup CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE
- * @{
- */
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() and sound_stream_type_e instead.
- * @brief Enumeration for session type.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- */
-typedef enum {
- SOUND_SESSION_TYPE_MEDIA = 0, /**< Media type */
- SOUND_SESSION_TYPE_ALARM, /**< Alarm type */
- SOUND_SESSION_TYPE_NOTIFICATION, /**< Notification type */
- SOUND_SESSION_TYPE_EMERGENCY, /**< Emergency type */
- SOUND_SESSION_TYPE_VOIP, /**< VoIP type */
-} sound_session_type_e;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_acquire_focus() or not instead.
- * @brief Enumeration for session option for starting.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- */
-typedef enum {
- SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START = 0, /**< This session will be mixed with others when starting (default) */
- SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START, /**< This session will interrupt other sessions when starting */
-} sound_session_option_for_starting_e;
-
-/**
- * @deprecated Deprecated since 3.0. In sound_stream_focus_state_changed_cb, you can choose to stop playing or not.
- * @brief Enumeration for session option during play.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- */
-typedef enum {
- SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY = 0, /**< This session will be interrupted by other sessions during play (default) */
- SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY, /**< This session will not be interrupted by other media sessions */
-} sound_session_option_for_during_play_e;
-
-/**
- * @deprecated Deprecated since 3.0. In sound_stream_focus_state_changed_cb, you can choose to resume playing or not.
- * @brief Enumeration for session option for resumption.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- */
-typedef enum {
- SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM = 0, /**< This session will be resumed according to system policy (default) */
- SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED, /**< This session will be resumed according to system policy and when the media session which interrupted this session is paused */
-} sound_session_option_for_resumption_e;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_apply_stream_routing() instead.
- * @brief Enumeration for voip session mode.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- */
-typedef enum {
- SOUND_SESSION_VOIP_MODE_RINGTONE = 0, /**< voip mode for ringtone */
- SOUND_SESSION_VOIP_MODE_VOICE_WITH_BUILTIN_RECEIVER, /**< voip mode for during call with built-in receiver */
- SOUND_SESSION_VOIP_MODE_VOICE_WITH_BUILTIN_SPEAKER, /**< voip mode for during call with built-in speaker */
- SOUND_SESSION_VOIP_MODE_VOICE_WITH_AUDIO_JACK, /**< voip mode for during call with audio jack */
- SOUND_SESSION_VOIP_MODE_VOICE_WITH_BLUETOOTH, /**< voip mode for during call with bluetooth */
-} sound_session_voip_mode_e;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_stream_focus_state_changed_cb instead.
- * @brief Enumeration for sound session interrupted type.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- */
-typedef enum {
- SOUND_SESSION_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed*/
- SOUND_SESSION_INTERRUPTED_BY_MEDIA, /**< Interrupted by media application*/
- SOUND_SESSION_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call*/
- SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones*/
- SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by a resource conflict*/
- SOUND_SESSION_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm*/
- SOUND_SESSION_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency*/
- SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification*/
-} sound_session_interrupted_code_e;
-
/**
* @}
*/
SOUND_DEVICE_BUILTIN_RECEIVER, /**< Built-in receiver */
SOUND_DEVICE_BUILTIN_MIC, /**< Built-in mic */
SOUND_DEVICE_AUDIO_JACK, /**< Audio jack that can be connected to wired accessory such as headphone, headset, and so on */
- SOUND_DEVICE_BLUETOOTH, /**< Bluetooth (Deprecated since 3.0) */
- SOUND_DEVICE_BLUETOOTH_MEDIA = SOUND_DEVICE_BLUETOOTH, /**< Bluetooth device representing media (A2DP) profile (Since 3.0) */
+ SOUND_DEVICE_BLUETOOTH_MEDIA, /**< Bluetooth device representing media (A2DP) profile (Since 3.0) */
SOUND_DEVICE_HDMI, /**< HDMI */
- SOUND_DEVICE_MIRRORING, /**< MIRRORING (Deprecated since 3.0) */
- SOUND_DEVICE_FORWARDING = SOUND_DEVICE_MIRRORING, /**< Device for forwarding (Since 3.0) */
+ SOUND_DEVICE_FORWARDING, /**< Device for forwarding (Since 3.0) */
SOUND_DEVICE_USB_AUDIO, /**< USB Audio */
SOUND_DEVICE_BLUETOOTH_VOICE, /**< Bluetooth device representing voice (SCO) profile (Since 3.0) */
} sound_device_type_e;
SOUND_DEVICE_ALL_MASK = 0xFFFF, /**< Mask for all devices */
} sound_device_mask_e;
-/**
-* @deprecated Deprecated since 3.0. Use sound_manager_add_device_state_changed_cb() instead.
-* @brief Enumeration for changed information of sound device.
-* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
-*/
-typedef enum {
- SOUND_DEVICE_CHANGED_INFO_STATE, /**< State of the device was changed */
- SOUND_DEVICE_CHANGED_INFO_IO_DIRECTION, /**< IO direction of the device was changed */
-} sound_device_changed_info_e;
-
/**
* @}
*/
*/
typedef void (*sound_stream_focus_state_watch_cb) (int id, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data);
-/**
- * @}
- */
-
-/**
- * @addtogroup CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE
- * @{
- */
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_stream_focus_state_changed_cb instead.
- * @brief Called when the playing sound session is interrupted.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] code The interrupted code
- * @param[in] user_data The user data passed from the callback registration function
- * @pre You should register this callback using sound_manager_set_session_interrupted_cb().
- * @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);
-
/**
* @}
*/
* @{
*/
-/**
- * @deprecated Deprecated since 3.0. Use sound_device_connection_changed_cb() instead.
- * @brief Called when the state of connection of a sound device was changed.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] sound_device_h The sound_device
- * @param[in] is_connected The state of device connection: (@c true = connected, @c false = disconnected)
- * @param[in] user_data The user data passed from the callback registration function
- * @pre You should register this callback using sound_manager_set_device_connected_cb().
- * @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);
-
-/**
- * @deprecated Deprecated since 3.0.
- * @brief Called when the information of a sound device was changed.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] sound_device_h The sound_device
- * @param[in] changed_info The entry of sound device information
- * @param[in] user_data The user data passed from the callback registration function
- * @pre You should register this callback using sound_manager_set_device_information_changed_cb().
- * @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);
-
/**
* @brief Called when the connection state of a sound device was changed.
* @since_tizen 3.0
*/
int sound_manager_get_volume(sound_type_e type, int *volume);
-/**
- * @deprecated Deprecated since 3.0.
- * @brief Sets the type of the sound being currently played.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] type The sound type to set
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @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) TIZEN_DEPRECATED_API;
-
/**
* @brief Gets the type of the sound being currently played.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
int sound_manager_get_current_sound_type(sound_type_e *type);
-/**
- * @deprecated Deprecated since 3.0.
- * @brief Unsets the type of the sound being currently played.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @see sound_manager_set_current_sound_type()
- * @see sound_manager_get_current_sound_type()
- */
-int sound_manager_unset_current_sound_type(void) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_add_volume_changed_cb() instead.
- * @brief Registers a callback function to be invoked when the volume level is changed.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] callback Callback function to indicate change in volume
- * @param[in] user_data The user data to be passed to the callback function
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @post sound_manager_volume_changed_cb() will be invoked.
- * @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) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_remove_volume_changed_cb() instead.
- * @brief Unregisters the volume change callback.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @return 0 on success, otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @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) TIZEN_DEPRECATED_API;
-
/**
* @brief Adds a callback function to be invoked when the volume level is changed.
* @since_tizen 3.0
*/
int sound_manager_remove_focus_state_watch_cb(int id);
-/**
- * @}
- */
-
-/**
- * @addtogroup CAPI_MEDIA_SOUND_MANAGER_SESSION_MODULE
- * @{
- */
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
- * @brief Sets the application's sound session type.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] type The session type to set
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
- * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
- * @see sound_manager_get_session_type()
- * @see sound_manager_set_media_session_option()
- * @see sound_manager_get_media_session_option()
- * @see sound_manager_set_media_session_resumption_option()
- * @see sound_manager_get_media_session_resumption_option()
- * @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) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0.
- * @brief Gets the application's sound session type.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] type The session type
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @see sound_manager_set_session_type()
- * @see sound_manager_set_media_session_option()
- * @see sound_manager_get_media_session_option()
- * @see sound_manager_set_media_session_resumption_option()
- * @see sound_manager_get_media_session_resumption_option()
- * @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) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
- * @brief Sets the media sound session option.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] s_option The session option for starting
- * @param[in] d_option The session option for during play
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
- * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
- * @see sound_manager_set_session_type()
- * @see sound_manager_get_session_type()
- * @see sound_manager_get_media_session_option()
- * @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) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
- * @brief Gets the media sound session option.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[out] s_option The session option for starting
- * @param[out] d_option The session option for during play
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
- * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
- * @see sound_manager_set_session_type()
- * @see sound_manager_get_session_type()
- * @see sound_manager_set_media_session_option()
- * @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) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
- * @brief Sets the media sound session resumption option.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] option The session resumption option
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
- * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
- * @see sound_manager_set_session_type()
- * @see sound_manager_get_session_type()
- * @see sound_manager_set_media_session_option()
- * @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) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
- * @brief Gets the media sound session resumption option.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[out] option The session resumption option
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
- * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
- * @see sound_manager_set_session_type()
- * @see sound_manager_get_session_type()
- * @see sound_manager_set_media_session_option()
- * @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) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
- * @brief Sets the mode of the voip sound session.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] mode The voip session mode
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
- * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
- * @pre Call sound_manager_set_session_type(#SOUND_SESSION_TYPE_VOIP) before calling this function.
- * @see sound_manager_set_session_type()
- * @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) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
- * @brief Gets the mode of the voip sound session.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[out] mode The voip session mode
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported
- * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
- * @pre Call sound_manager_set_session_type(#SOUND_SESSION_TYPE_VOIP) before calling this function.
- * @see sound_manager_set_session_type()
- * @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) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_create_stream_information() instead.
- * @brief Registers a callback function to be invoked when the sound session being played was interrupted.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] callback The interrupted callback function
- * @param[in] user_data The user data to be passed to the callback function
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
- * @post sound_session_interrupted_cb() will be invoked.
- * @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) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0.
- * @brief Unregisters the callback function which is called when the sound session being played is interrupted.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @return 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @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) TIZEN_DEPRECATED_API;
-
/**
* @}
*/
* @{
*/
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_get_device_list() instead.
- * @brief Gets the list consisting of connected devices.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
- * @remarks @a Calling this API will deallocate previously obtained list and each item.\n
- * Use sound_manager_get_next_device() to get the first node of the list.
- *
- * @param[in] device_mask The mask value
- * @param[out] device_list The list of connected devices
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_NO_DATA No data
- * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @see sound_manager_get_next_device()
- * @see sound_manager_get_prev_device()
- * @see sound_manager_get_device_type()
- * @see sound_manager_get_device_io_direction()
- * @see sound_manager_get_device_id()
- * @see sound_manager_get_device_name()
- */
-int sound_manager_get_current_device_list(sound_device_mask_e device_mask, sound_device_list_h *device_list) TIZEN_DEPRECATED_API;
-
/**
* @brief Gets the list consisting of connected devices.
* @since_tizen 3.0
* @deprecated Deprecated since 4.0.
* @brief Gets the state of the device.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] device The device item
- * @param[out] state The state of the device
+ * @param[in] device The device item
+ * @param[out] state The state of the device
* @return @c 0 on success,
* otherwise a negative error value
* @retval #SOUND_MANAGER_ERROR_NONE Success
*/
int sound_manager_get_device_state(sound_device_h device, sound_device_state_e *state) TIZEN_DEPRECATED_API;
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_add_device_connection_changed_cb() instead.
- * @brief Registers a callback function to be invoked when the state of connection of a sound device was changed.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
- * @remarks The initial state of sound devices connected is deactivated.
- *
- * @param[in] device_mask The mask value
- * @param[in] callback The interrupted callback function
- * @param[in] user_data The user data to be passed to the callback function
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @post sound_device_connected_cb() will be invoked.
- * @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) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_remove_device_connection_changed_cb() instead.
- * @brief Unregisters the callback function which is called when the state of connection of a sound device was changed.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @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) TIZEN_DEPRECATED_API;
-
/**
* @brief Adds a callback function to be invoked when the connection state of a sound device was changed.
* @since_tizen 3.0
* @retval #SOUND_MANAGER_ERROR_NONE Success
* @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @post sound_device_connected_cb() will be invoked.
+ * @post sound_device_connection_changed_cb() will be invoked.
* @see sound_manager_remove_device_connection_changed_cb()
* @see sound_device_connection_changed_cb()
*/
*/
int sound_manager_remove_device_connection_changed_cb(int id);
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_add_device_state_changed_cb() instead.
- * @brief Registers a callback function to be invoked when the information of a sound device was changed.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] device_mask The mask value
- * @param[in] callback The interrupted callback function
- * @param[in] user_data The user data to be passed to the callback function
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @post sound_device_information_changed_cb() will be invoked.
- * @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) TIZEN_DEPRECATED_API;
-
-/**
- * @deprecated Deprecated since 3.0. Use sound_manager_remove_device_state_changed_cb() instead.
- * @brief Unregisters the callback function which is called when the information of a sound device was changed.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @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) TIZEN_DEPRECATED_API;
-
/**
* @deprecated Deprecated since 4.0.
* @brief Adds a callback function to be invoked when the state of a sound device was changed.
*/
int sound_manager_get_device_state_by_id(int device_id, sound_device_state_e *state);
-/**
- * @internal
- * @brief Gets the internal stream information handle for VoIP session.
- * @since_tizen 3.0
- *
- * @remarks If VoIP session is not set in this process, it'll return #SOUND_MANAGER_ERROR_NO_DATA.
- *
- * @param[out] stream_info The handle of stream information
- *
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_NO_DATA No data
- * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @see sound_manager_set_session_type()
- * @see sound_manager_set_voip_session_mode()
- */
-int sound_manager_get_internal_voip_stream_information(sound_stream_info_h *stream_info);
-
/**
* @internal
* @brief Disable session backward compatibility.
*/
int sound_manager_get_device_state_by_id(int device_id, sound_device_state_e *state);
-/**
- * @internal
- * @brief Gets the internal stream information handle for VoIP session.
- * @since_tizen 3.0
- *
- * @remarks If VoIP session is not set in this process, it'll return #SOUND_MANAGER_ERROR_NO_DATA.
- *
- * @param[out] stream_info The handle of stream information
- *
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #SOUND_MANAGER_ERROR_NONE Success
- * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SOUND_MANAGER_ERROR_NO_DATA No data
- * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @see sound_manager_set_session_type()
- * @see sound_manager_set_voip_session_mode()
- */
-int sound_manager_get_internal_voip_stream_information(sound_stream_info_h *stream_info);
-
/**
* @internal
* @brief Disable session backward compatibility.
#include <gio/gio.h>
#include <glib.h>
-#include <mm_session.h>
-#include <mm_session_private.h>
#include <mm_sound.h>
#include <mm_sound_focus.h>
#include <mm_sound_private.h>
LOGE("mutex unlock failed"); \
}
-#define SM_REF_FOR_STREAM_INFO(x_count, x_return) \
-{ \
- if (!x_count) { \
- /* send signal to other framework to release internal focus */ \
- x_return = mm_sound_send_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 1); \
- } \
- if (x_return) \
- LOGW("failed to send signal for stream info creation"); \
- else \
- g_stream_info_count++; \
-} \
-
-#define SM_UNREF_FOR_STREAM_INFO(x_count) \
-{ \
- if (x_count > 0) \
- x_count--; \
-} \
-
#define SM_SAFE_FREE(x_val) do { \
if (x_val) { \
free(x_val); \
#define DIRECTION_OUT_STR "out"
#define SOUND_TYPE_MASTER_STR "master"
-#define EXT_INFO_VOIP_SESSION "for voip session"
-
typedef enum _sound_stream_direction {
SOUND_STREAM_DIRECTION_OUTPUT = 1,
SOUND_STREAM_DIRECTION_INPUT
sound_stream_info_s *stream_info;
} virtual_sound_stream_info_s;
-typedef enum {
- _SESSION_MODE_RINGTONE = 0, /**< session mode(voip/call) for ringtone */
- _SESSION_MODE_VOICE_WITH_BUILTIN_RECEIVER, /**< session mode(voip/call) for during call with built-in receiver */
- _SESSION_MODE_VOICE_WITH_BUILTIN_SPEAKER, /**< session mode(voip/call) for during call with built-in speaker */
- _SESSION_MODE_VOICE_WITH_AUDIO_JACK, /**< session mode(voip/call) for during call with audio jack */
- _SESSION_MODE_VOICE_WITH_BLUETOOTH_SCO, /**< session mode(voip/call) for during call with bluetooth */
-} _session_mode_e;
-
-typedef struct {
- int is_registered;
- unsigned int subs_id; /* for internal device connected subscription */
- void *user_data;
- sound_session_interrupted_cb user_cb;
-} _session_interrupt_info_s;
-
typedef struct {
int id;
void *user_data;
sound_stream_focus_state_watch_cb user_cb;
} _focus_watch_info_s;
-typedef struct {
- unsigned int subs_id;
- void *user_data;
- sound_manager_volume_changed_cb user_cb;
-} _volume_changed_info_s;
-
-typedef struct {
- unsigned int subs_id;
- void *user_data;
- sound_device_connected_cb user_cb;
-} _device_connected_info_s;
-
-typedef struct {
- unsigned int subs_id;
- void *user_data;
- sound_device_information_changed_cb user_cb;
-} _device_changed_info_s;
-
-void _focus_session_interrupt_cb(mm_sound_focus_state_e state, const char *reason, void *user_data);
-
void _voip_focus_state_change_callback(sound_stream_info_h stream_info,
sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state,
sound_stream_focus_change_reason_e reason, int sound_behavior, const char *extra_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, int option, const char *extra_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, const char *extra_info, void *user_data);
void _pa_stream_state_cb(pa_stream *s, void * userdata);
-int _set_session_mode(_session_mode_e mode);
-
-int _make_pa_connection_and_register_focus(sound_stream_info_s *stream_h, bool is_for_session, sound_stream_focus_state_changed_cb callback, void *user_data);
+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);
Name: capi-media-sound-manager
Summary: Sound Manager library
-Version: 0.4.24
+Version: 0.5.0
Release: 0
Group: Multimedia/API
License: Apache-2.0
BuildRequires: cmake
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(mm-sound)
-BuildRequires: pkgconfig(mm-session)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(libpulse)
BuildRequires: pkgconfig(gio-2.0)
-BuildRequires: pkgconfig(capi-system-info)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
#include "sound_manager.h"
#include "sound_manager_private.h"
-#include <system_info.h>
-#define FEATURE_MICROPHONE "http://tizen.org/feature/microphone"
-
-_session_interrupt_info_s g_session_interrupt_cb_table = {0, 0, NULL, NULL};
-_volume_changed_info_s g_volume_changed_cb_table = {0, NULL, NULL};
-_device_connected_info_s g_device_connected_cb_table = {0, NULL, NULL};
-_device_changed_info_s g_device_info_changed_cb_table = {0, NULL, NULL};
_focus_watch_info_s focus_watch_info_arr[SOUND_STREAM_INFO_ARR_MAX];
-sound_session_type_e g_cached_session = -1;
-_session_mode_e g_cached_session_mode = -1;
-int g_cached_voip_device_id = -1;
-int g_cached_voip_device_id2 = -1;
-extern sound_stream_info_s *g_voip_stream_info;
-extern sound_stream_info_s *g_voip_ringtone_stream_info;
-extern virtual_sound_stream_info_s *g_voip_vstream_h;
-extern virtual_sound_stream_info_s *g_voip_ringtone_vstream_h;
-
-/* These variables will be removed when session features are deprecated. */
-extern int g_stream_info_count;
-extern pthread_mutex_t g_stream_info_count_mutex;
-pthread_mutex_t g_session_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t g_interrupt_cb_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t g_device_info_cb_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t g_device_conn_cb_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t g_volume_cb_mutex = PTHREAD_MUTEX_INITIALIZER;
-
int sound_manager_get_max_volume(sound_type_e type, int *max)
{
const char *volume_type = NULL;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_set_current_sound_type(sound_type_e type)
-{
- int ret = MM_ERROR_NONE;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release.", __func__);
- if (type >= SOUND_TYPE_NUM)
- return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
- ret = mm_sound_volume_primary_type_set(type);
-
- return _convert_sound_manager_error_code(__func__, ret);
-}
-
int sound_manager_get_current_sound_type(sound_type_e *type)
{
int ret = MM_ERROR_NONE;
return _convert_sound_manager_error_code(__func__, ret);
}
-int sound_manager_unset_current_sound_type(void)
-{
- int ret = MM_ERROR_NONE;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release.", __func__);
- ret = mm_sound_volume_primary_type_set(VOLUME_TYPE_UNKNOWN);
-
- 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 ret = MM_ERROR_NONE;
- unsigned int subs_id = 0;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. "
- "Use sound_manager_add_volume_changed_cb() instead.", __func__);
-
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_volume_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
- ret = mm_sound_add_volume_changed_callback((mm_sound_volume_changed_cb)callback, user_data, &subs_id);
- if (ret == MM_ERROR_NONE) {
- g_volume_changed_cb_table.subs_id = subs_id;
- g_volume_changed_cb_table.user_cb = (sound_manager_volume_changed_cb)callback;
- g_volume_changed_cb_table.user_data = user_data;
- }
-
- SM_LEAVE_CRITICAL_SECTION(&g_volume_cb_mutex);
-
- return _convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_unset_volume_changed_cb(void)
-{
- int ret = MM_ERROR_NONE;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. "
- "Use sound_manager_remove_volume_changed_cb() instead.", __func__);
-
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_volume_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
- if (g_volume_changed_cb_table.subs_id > 0) {
- ret = mm_sound_remove_volume_changed_callback(g_volume_changed_cb_table.subs_id);
- if (ret == MM_ERROR_NONE) {
- g_volume_changed_cb_table.subs_id = 0;
- g_volume_changed_cb_table.user_cb = NULL;
- g_volume_changed_cb_table.user_data = NULL;
- }
- } else {
- ret = MM_ERROR_SOUND_INTERNAL;
- }
-
- SM_LEAVE_CRITICAL_SECTION(&g_volume_cb_mutex);
-
- return _convert_sound_manager_error_code(__func__, ret);
-}
-
int sound_manager_add_volume_changed_cb(sound_manager_volume_changed_cb callback, void *user_data, int *id)
{
int ret = MM_ERROR_NONE;
SM_NULL_ARG_CHECK(stream_info);
- if (g_session_interrupt_cb_table.is_registered)
- return _convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INTERNAL);
-
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, MM_ERROR_SOUND_INTERNAL);
-
sound_stream_info_s *stream_h = malloc(sizeof(sound_stream_info_s));
if (!stream_h) {
ret = MM_ERROR_OUT_OF_MEMORY;
memset(stream_h, 0, sizeof(sound_stream_info_s));
ret = _convert_stream_type(stream_type, &stream_h->stream_type);
if (ret == MM_ERROR_NONE) {
- ret = _make_pa_connection_and_register_focus(stream_h, false, callback, user_data);
+ 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_REF_FOR_STREAM_INFO(g_stream_info_count, ret);
- LOGI("stream_h(%p), index(%u), user_cb(%p), cnt(%d), ret(0x%x)", stream_h, stream_h->index, stream_h->user_cb, g_stream_info_count, ret);
+ LOGI("stream_h(%p), index(%u), user_cb(%p), ret(0x%x)", stream_h, stream_h->index, stream_h->user_cb, ret);
}
}
if (ret)
SM_SAFE_FREE(stream_h);
- SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
-
return _convert_sound_manager_error_code(__func__, ret);
}
SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
if (ret == MM_ERROR_NONE) {
SM_SAFE_FREE(stream_h);
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, MM_ERROR_SOUND_INTERNAL);
- SM_UNREF_FOR_STREAM_INFO(g_stream_info_count);
- SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
}
- LOGD("cnt(%d)", g_stream_info_count);
-
return _convert_sound_manager_error_code(__func__, ret);
}
SM_NULL_ARG_CHECK(callback);
SM_NULL_ARG_CHECK(id);
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, SOUND_MANAGER_ERROR_INTERNAL);
for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++)
if (focus_watch_info_arr[i].id == 0)
ret = mm_sound_set_focus_watch_callback((mm_sound_focus_type_e)focus_mask, _focus_watch_callback, &focus_watch_info_arr[i], id);
if (ret == MM_ERROR_NONE) {
- SM_REF_FOR_STREAM_INFO(g_stream_info_count, ret);
focus_watch_info_arr[i].id = *id;
focus_watch_info_arr[i].user_data = user_data;
focus_watch_info_arr[i].user_cb = callback;
}
LEAVE:
- SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
-
- LOGD("cnt(%d), id(%d)", g_stream_info_count, *id);
+ LOGD("id(%d)", *id);
return _convert_sound_manager_error_code(__func__, ret);
}
LOGI(">> enter");
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++)
if (focus_watch_info_arr[i].id == id)
break;
ret = mm_sound_unset_focus_watch_callback(id);
if (ret == MM_ERROR_NONE) {
- SM_UNREF_FOR_STREAM_INFO(g_stream_info_count);
focus_watch_info_arr[i].id = 0;
focus_watch_info_arr[i].user_data = NULL;
focus_watch_info_arr[i].user_cb = NULL;
}
LEAVE:
- SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
-
- LOGD("cnt(%d)", g_stream_info_count);
-
- return _convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_set_session_type(sound_session_type_e type)
-{
- int ret = MM_ERROR_NONE;
- int cur_session = -1;
- int new_session = MM_SESSION_TYPE_MEDIA;
- bool mic_enable = false;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
- LOGI(">> enter : type=%d", type);
-
- if (type > SOUND_SESSION_TYPE_VOIP)
- return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
- /* If session type is VOIP but MIC is not enabled, return false */
- if (type == SOUND_SESSION_TYPE_VOIP) {
- ret = system_info_get_platform_bool(FEATURE_MICROPHONE, &mic_enable);
- LOGI("system_info_platform [%s]=[%d], ret[%d]", FEATURE_MICROPHONE, mic_enable, ret);
- if (ret != SYSTEM_INFO_ERROR_NONE || !mic_enable)
- return _convert_sound_manager_error_code(__func__, MM_ERROR_NOT_SUPPORT_API);
- }
-
- /* it is not supported both session and stream feature at the same time */
- if (g_stream_info_count) {
- LOGE("Could not set this type(%d) because of being used stream feature", type);
- return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
- }
-
- switch (type) {
- case SOUND_SESSION_TYPE_MEDIA:
- new_session = MM_SESSION_TYPE_MEDIA;
- break;
- case SOUND_SESSION_TYPE_ALARM:
- new_session = MM_SESSION_TYPE_ALARM;
- break;
- case SOUND_SESSION_TYPE_NOTIFICATION:
- new_session = MM_SESSION_TYPE_NOTIFY;
- break;
- case SOUND_SESSION_TYPE_EMERGENCY:
- new_session = MM_SESSION_TYPE_EMERGENCY;
- break;
- case SOUND_SESSION_TYPE_VOIP:
- new_session = MM_SESSION_TYPE_VOIP;
- break;
- }
-
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_session_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
- /* valid session check */
- ret = mm_session_get_current_type(&cur_session);
- if (ret == MM_ERROR_NONE) {
- if (cur_session == MM_SESSION_TYPE_MEDIA_RECORD) {
- if (type > SOUND_SESSION_TYPE_MEDIA) {
- LOGE("Could not set this type(%d) during camera/recorder/audio-io(in)/radio", type);
- ret = MM_ERROR_POLICY_INTERNAL;
- goto LEAVE;
- }
- }
- }
-
- if (g_session_interrupt_cb_table.is_registered) {
- if (new_session == cur_session ||
- ((new_session == SOUND_SESSION_TYPE_MEDIA) && (cur_session == MM_SESSION_TYPE_MEDIA_RECORD))) {
- LOGI("already set type=%d, ret=0x%x", type, ret);
- goto LEAVE;
- }
-
- ret = mm_session_finish();
- if (ret != MM_ERROR_NONE)
- goto LEAVE;
-
- g_session_interrupt_cb_table.is_registered = 0;
- if (cur_session == MM_SESSION_TYPE_VOIP) {
- /* De-initialize regarding VoIP session */
- g_cached_session_mode = -1;
- g_cached_voip_device_id = -1;
- g_cached_voip_device_id2 = -1;
- if (g_voip_vstream_h) {
- _stop_progress_virtual_stream(g_voip_vstream_h);
- g_voip_vstream_h = NULL;
- }
- if (g_voip_ringtone_vstream_h) {
- _stop_progress_virtual_stream(g_voip_ringtone_vstream_h);
- g_voip_ringtone_vstream_h = NULL;
- }
- if (g_voip_ringtone_stream_info) {
- if ((ret = mm_sound_release_focus(g_voip_ringtone_stream_info->index, g_voip_ringtone_stream_info->acquired_focus, EXT_INFO_VOIP_SESSION)))
- LOGE("failed to release focus for ringtone-voip stream info, ret(0x%x)", ret);
- } else if (g_voip_stream_info) {
- if ((ret = mm_sound_release_focus(g_voip_stream_info->index, g_voip_stream_info->acquired_focus, EXT_INFO_VOIP_SESSION)))
- LOGE("failed to release focus for voip stream info, ret(0x%x)", ret);
- }
- if (g_voip_stream_info) {
- ret = _destroy_pa_connection_and_unregister_focus(g_voip_stream_info);
- SM_SAFE_FREE(g_voip_stream_info);
- if (ret != MM_ERROR_NONE)
- goto LEAVE;
- }
- if (g_voip_ringtone_stream_info) {
- ret = _destroy_pa_connection_and_unregister_focus(g_voip_ringtone_stream_info);
- SM_SAFE_FREE(g_voip_ringtone_stream_info);
- if (ret != MM_ERROR_NONE)
- goto LEAVE;
- }
- }
- }
- ret = mm_session_init(new_session);
- if (ret == MM_ERROR_NONE)
- g_session_interrupt_cb_table.is_registered = 1;
-
- LOGI("type=%d", type);
-LEAVE:
- SM_LEAVE_CRITICAL_SECTION(&g_session_mutex);
-
- return _convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_get_session_type(sound_session_type_e *type)
-{
- int ret = MM_ERROR_NONE;
- int cur_session;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release.", __func__);
- if (type == NULL)
- return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_session_mutex, SOUND_MANAGER_ERROR_INVALID_PARAMETER);
-
- ret = mm_session_get_current_type(&cur_session);
- if (ret != MM_ERROR_NONE) {
- LOGW("session hasn't been set, setting default session");
- cur_session = SOUND_SESSION_TYPE_DEFAULT;
- ret = mm_session_init(cur_session);
- if (ret == MM_ERROR_NONE)
- 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 reached here. just prevent code */
- cur_session = SOUND_SESSION_TYPE_DEFAULT;
- }
-
- switch (cur_session) {
- case MM_SESSION_TYPE_MEDIA:
- case MM_SESSION_TYPE_MEDIA_RECORD:
- *type = SOUND_SESSION_TYPE_MEDIA;
- break;
- case MM_SESSION_TYPE_ALARM:
- *type = SOUND_SESSION_TYPE_ALARM;
- break;
- case MM_SESSION_TYPE_NOTIFY:
- *type = SOUND_SESSION_TYPE_NOTIFICATION;
- break;
- case MM_SESSION_TYPE_EMERGENCY:
- *type = SOUND_SESSION_TYPE_EMERGENCY;
- break;
- case MM_SESSION_TYPE_VOIP:
- *type = SOUND_SESSION_TYPE_VOIP;
- break;
- default:
- *type = cur_session;
- break;
- }
-
- LOGI("type=%d", *type);
-
- SM_LEAVE_CRITICAL_SECTION(&g_session_mutex);
-
- return SOUND_MANAGER_ERROR_NONE;
-}
-
-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;
- int session_option = 0;
- int updated = 0;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
- LOGI(">> enter : option for starting=%d, for during play=%d", s_option, d_option);
-
- if (s_option > SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START)
- return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
- if (d_option > SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY)
- return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
- ret = mm_session_get_current_information(&session, &session_option);
- 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)
- 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 {
- return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
- }
- }
-
- switch (s_option) {
- 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)
- 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)
- return _convert_sound_manager_error_code(__func__, ret);
-
- updated = 1;
- }
- break;
- }
-
- switch (d_option) {
- 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)
- 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)
- return _convert_sound_manager_error_code(__func__, ret);
-
- updated = 1;
- }
- break;
- }
-
- if (updated)
- LOGI("updated");
- else
- LOGI("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 ret = MM_ERROR_NONE;
- int session = 0;
- int session_options = 0;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
- LOGI(">> enter");
-
- if (s_option == NULL || d_option == NULL)
- return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
- ret = mm_session_get_current_information(&session, &session_options);
- if (ret != 0) {
- ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
- 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
- return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
- }
- /* get option */
- if (session_options & MM_SESSION_OPTION_PAUSE_OTHERS)
- *s_option = SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START;
- else
- *s_option = SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START;
-
- if (session_options & MM_SESSION_OPTION_UNINTERRUPTIBLE)
- *d_option = SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY;
- else
- *d_option = SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY;
-
- LOGI(" 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 ret = MM_ERROR_NONE;
- int session = 0;
- int session_option = 0;
- int updated = 0;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
- LOGI(">> enter : option for resumption=%d (0:by system, 1:by system or media paused)", option);
-
- if (option > SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED)
- return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
- ret = mm_session_get_current_information(&session, &session_option);
- 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)
- 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
- 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)
- 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)
- return _convert_sound_manager_error_code(__func__, ret);
-
- updated = 1;
- }
- break;
- }
-
- if (updated)
- LOGI("updated");
- else
- LOGI("already set same option(0x%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 ret = MM_ERROR_NONE;
- int session = 0;
- int session_options = 0;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
- LOGI(">> enter");
-
- if (option == NULL)
- return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
- ret = mm_session_get_current_information(&session, &session_options);
- if (ret != 0) {
- LOGW("session hasn't been set, setting default session");
- ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
- 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
- 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)
- *option = SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED;
- else
- *option = SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM;
-
- LOGI("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 ret = MM_ERROR_NONE;
- int session = 0;
- int session_options = 0;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
- LOGI(">> enter : mode=%d", mode);
-
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_session_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
- ret = mm_session_get_current_information(&session, &session_options);
- if (ret != MM_ERROR_NONE)
- goto LEAVE;
-
- if (session != MM_SESSION_TYPE_VOIP) {
- ret = MM_ERROR_POLICY_INTERNAL;
- goto LEAVE;
- }
-
- if (mode > SOUND_SESSION_VOIP_MODE_VOICE_WITH_BLUETOOTH) {
- ret = MM_ERROR_INVALID_ARGUMENT;
- goto LEAVE;
- }
-
- ret = _set_session_mode((_session_mode_e)mode);
-
- LOGI("session=%d, mode=%d(0:RINGTONE 1:MIC_RCV 2:MIC_SPK 3:EAR 4:BT)", session, mode);
-
-LEAVE:
- SM_LEAVE_CRITICAL_SECTION(&g_session_mutex);
-
- return _convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_get_voip_session_mode(sound_session_voip_mode_e *mode)
-{
- int ret = MM_ERROR_NONE;
- int session = 0;
- int session_options = 0;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
-
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_session_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
- if (mode == NULL) {
- LOGE("mode is null");
- ret = MM_ERROR_INVALID_ARGUMENT;
- goto LEAVE;
- }
-
- ret = mm_session_get_current_information(&session, &session_options);
- if (ret != MM_ERROR_NONE) {
- LOGI("session = %d, option = %d", session, session_options);
- goto LEAVE;
- }
-
- if (session != MM_SESSION_TYPE_VOIP || g_cached_session_mode == -1) {
- ret = MM_ERROR_POLICY_INTERNAL;
- goto LEAVE;
- }
-
- *mode = (sound_session_voip_mode_e)g_cached_session_mode;
-
- LOGI("session=%d, mode=%d", session, *mode);
-
-LEAVE:
- SM_LEAVE_CRITICAL_SECTION(&g_session_mutex);
-
- return _convert_sound_manager_error_code(__func__, ret);
-}
-
-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;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_interrupt_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
- if (callback == NULL) {
- ret = MM_ERROR_INVALID_ARGUMENT;
- goto LEAVE;
- }
-
- /* it is not supported both session and stream feature at the same time */
- if (g_stream_info_count) {
- ret = MM_ERROR_POLICY_INTERNAL;
- goto LEAVE;
- }
-
- if (g_session_interrupt_cb_table.user_cb == NULL) {
- if ((ret = mm_sound_add_device_connected_callback(SOUND_DEVICE_ALL_MASK, (mm_sound_device_connected_cb)_device_connected_cb, NULL, &subs_id))) {
- ret = MM_ERROR_INVALID_ARGUMENT;
- goto LEAVE;
- }
- if ((ret = mm_sound_focus_set_session_interrupt_callback((mm_sound_focus_session_interrupt_cb)_focus_session_interrupt_cb, NULL))) {
- if (mm_sound_remove_device_connected_callback(subs_id) != MM_ERROR_NONE)
- LOGW("mm_sound_remove_device_connected_callback failed");
- ret = MM_ERROR_INVALID_ARGUMENT;
- goto LEAVE;
- }
- g_session_interrupt_cb_table.subs_id = subs_id;
- }
- g_session_interrupt_cb_table.user_cb = (sound_session_interrupted_cb)callback;
- g_session_interrupt_cb_table.user_data = user_data;
-
-LEAVE:
- SM_LEAVE_CRITICAL_SECTION(&g_interrupt_cb_mutex);
-
- return _convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_unset_session_interrupted_cb(void)
-{
- int ret = MM_ERROR_NONE;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release.", __func__);
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_interrupt_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
- if (!g_session_interrupt_cb_table.user_cb) {
- ret = MM_ERROR_SOUND_INTERNAL;
- goto LEAVE;
- }
-
- if ((ret = mm_sound_focus_unset_session_interrupt_callback())) {
- 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");
- ret = MM_ERROR_SOUND_INTERNAL;
- goto LEAVE;
- }
-
- if ((ret = mm_sound_remove_device_connected_callback(g_session_interrupt_cb_table.subs_id))) {
- ret = MM_ERROR_SOUND_INTERNAL;
- goto LEAVE;
- }
-
- g_session_interrupt_cb_table.subs_id = 0;
- g_session_interrupt_cb_table.user_cb = NULL;
- g_session_interrupt_cb_table.user_data = NULL;
-
-LEAVE:
- SM_LEAVE_CRITICAL_SECTION(&g_interrupt_cb_mutex);
-
- 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 ret = MM_ERROR_NONE;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_get_device_list() instead.", __func__);
- ret = mm_sound_get_current_device_list(device_mask, device_list);
-
return _convert_sound_manager_error_code(__func__, ret);
}
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 ret = MM_ERROR_NONE;
- unsigned int subs_id = 0;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. "
- "Use sound_manager_add_device_connection_changed_cb() instead.", __func__);
-
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_conn_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
- ret = mm_sound_add_device_connected_callback((mm_sound_device_flags_e)device_mask, (mm_sound_device_connected_cb)callback, user_data, &subs_id);
- if (ret == MM_ERROR_NONE) {
- g_device_connected_cb_table.subs_id = subs_id;
- g_device_connected_cb_table.user_cb = (sound_device_connected_cb)callback;
- g_device_connected_cb_table.user_data = user_data;
- }
-
- SM_LEAVE_CRITICAL_SECTION(&g_device_conn_cb_mutex);
-
- return _convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_unset_device_connected_cb(void)
-{
- int ret = MM_ERROR_NONE;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. "
- "Use sound_manager_remove_device_connection_changed_cb() instead.", __func__);
-
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_conn_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
- if (g_device_connected_cb_table.subs_id == 0) {
- ret = MM_ERROR_SOUND_INTERNAL;
- goto LEAVE;
- }
-
- ret = mm_sound_remove_device_connected_callback(g_device_connected_cb_table.subs_id);
- if (ret == MM_ERROR_NONE) {
- g_device_connected_cb_table.subs_id = 0;
- g_device_connected_cb_table.user_cb = NULL;
- g_device_connected_cb_table.user_data = NULL;
- }
-
-LEAVE:
- SM_LEAVE_CRITICAL_SECTION(&g_device_conn_cb_mutex);
-
- return _convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_add_device_connection_changed_cb(int device_mask, sound_device_connected_cb callback, void *user_data, int *id)
+int sound_manager_add_device_connection_changed_cb(int device_mask, sound_device_connection_changed_cb callback, void *user_data, int *id)
{
int ret = MM_ERROR_NONE;
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 ret = MM_ERROR_NONE;
- unsigned int subs_id = 0;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. "
- "Use sound_manager_add_device_state_changed_cb() instead.", __func__);
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_info_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
- ret = mm_sound_add_device_information_changed_callback((mm_sound_device_flags_e)device_mask, (mm_sound_device_info_changed_cb)callback, user_data, &subs_id);
- if (ret == MM_ERROR_NONE) {
- g_device_info_changed_cb_table.subs_id = subs_id;
- g_device_info_changed_cb_table.user_cb = (sound_device_information_changed_cb)callback;
- g_device_info_changed_cb_table.user_data = user_data;
- }
-
- SM_LEAVE_CRITICAL_SECTION(&g_device_info_cb_mutex);
-
- return _convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_unset_device_information_changed_cb(void)
-{
- int ret = MM_ERROR_NONE;
-
- LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. "
- "Use sound_manager_remove_device_state_changed_cb() instead.", __func__);
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_info_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
- if (g_device_info_changed_cb_table.subs_id == 0) {
- ret = MM_ERROR_SOUND_INTERNAL;
- goto LEAVE;
- }
-
- ret = mm_sound_remove_device_information_changed_callback(g_device_info_changed_cb_table.subs_id);
- if (ret == MM_ERROR_NONE) {
- g_device_info_changed_cb_table.subs_id = 0;
- g_device_info_changed_cb_table.user_cb = NULL;
- g_device_info_changed_cb_table.user_data = NULL;
- }
-
-LEAVE:
- SM_LEAVE_CRITICAL_SECTION(&g_device_info_cb_mutex);
-
- return _convert_sound_manager_error_code(__func__, ret);
-}
-
int sound_manager_add_device_state_changed_cb(int device_mask, sound_device_state_changed_cb callback, void *user_data, int *id)
{
int ret = MM_ERROR_NONE;
__attribute__ ((destructor))
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)
- LOGE("[%s] failed to mm_session_finish(), ret(0x%x)", __func__, ret);
-
- g_session_interrupt_cb_table.is_registered = 0;
- LOGI("<LEAVE>");
- }
}
__attribute__ ((constructor))
#include <sound_manager_internal.h>
#include <mm_sound.h>
-/* These variables will be removed when session features are deprecated. */
-extern int g_stream_info_count;
-extern pthread_mutex_t g_stream_info_count_mutex;
-extern pthread_mutex_t g_session_mutex;
-extern sound_stream_info_s *g_voip_stream_info;
-extern sound_stream_info_s *g_voip_ringtone_stream_info;
-extern virtual_sound_stream_info_s *g_voip_vstream_h;
-extern virtual_sound_stream_info_s *g_voip_ringtone_vstream_h;
-
#ifndef TIZEN_FEATURE_TV_PROD
int sound_manager_get_max_master_volume(int *max_level)
{
SM_NULL_ARG_CHECK(stream_info);
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, MM_ERROR_SOUND_INTERNAL);
-
sound_stream_info_s *stream_h = malloc(sizeof(sound_stream_info_s));
if (!stream_h) {
ret = MM_ERROR_OUT_OF_MEMORY;
ret = _convert_stream_type_for_internal(stream_type, &stream_h->stream_type);
if (ret == MM_ERROR_NONE) {
_set_focus_availability(stream_h);
- ret = _make_pa_connection_and_register_focus(stream_h, false, callback, user_data);
+ ret = _make_pa_connection_and_register_focus(stream_h, callback, user_data);
if (!ret) {
*stream_info = (sound_stream_info_h)stream_h;
LOGI("stream_h(%p), index(%u), user_cb(%p), ret(0x%x)", stream_h, stream_h->index, stream_h->user_cb, ret);
if (ret)
SM_SAFE_FREE(stream_h);
- SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
-
return _convert_sound_manager_error_code(__func__, ret);
}
return _convert_sound_manager_error_code(__func__, ret);
}
-/* This function is only for audio-io session backward compatibility */
-int sound_manager_get_internal_voip_stream_information(sound_stream_info_h *stream_info)
-{
- SM_NULL_ARG_CHECK(stream_info);
-
- SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_session_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
- if (g_voip_vstream_h == NULL && g_voip_ringtone_vstream_h == NULL) {
- LOGE("voip mode is not set");
- SM_LEAVE_CRITICAL_SECTION(&g_session_mutex);
- return SOUND_MANAGER_ERROR_NO_DATA;
- }
-
- if (g_voip_ringtone_vstream_h) {
- LOGI("ringtone mode is activated");
- *stream_info = (sound_stream_info_h)g_voip_ringtone_stream_info;
- } else {
- *stream_info = (sound_stream_info_h)g_voip_stream_info;
- }
-
- LOGI("internal VoIP stream_info[%p]", *stream_info);
-
- SM_LEAVE_CRITICAL_SECTION(&g_session_mutex);
-
- return SOUND_MANAGER_ERROR_NONE;
-}
-
int sound_manager_disable_session_backward_compatibility(void)
{
- int ret = MM_ERROR_NONE;
-
- ret = mm_sound_send_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 1);
-
- LOGW("Declared not to have session backward compatibility in this process[%u]", getpid());
-
- return _convert_sound_manager_error_code(__func__, ret);
+ LOGI("Please do not call this function since Tizen 5.0. No need to call it.");
+ return MM_ERROR_NONE;
}
int sound_manager_create_virtual_stream(sound_stream_info_h stream_info, virtual_sound_stream_h *virtual_stream)
#define VCONF_PATH_PREFIX_VOLUME "file/private/sound/volume/"
#define VCONF_PATH_MAX 64
-#define CHECK_AND_SET_DEVICE(x_dst_device1, x_dst_device2, x_src_device) \
-do { \
- if (!x_dst_device1) \
- x_dst_device1 = x_src_device; \
- else if (!x_dst_device2) \
- x_dst_device2 = x_src_device; \
- else { \
- LOGE("all dst devices are already set"); \
- goto ERROR_CASE; \
- } \
-} while (0) \
-
-extern _session_interrupt_info_s g_session_interrupt_cb_table;
-extern _session_mode_e g_cached_session_mode;
-extern int g_cached_voip_device_id;
-extern int g_cached_voip_device_id2;
-sound_stream_info_s *g_voip_stream_info = NULL;
-sound_stream_info_s *g_voip_ringtone_stream_info = NULL;
-virtual_sound_stream_info_s *g_voip_vstream_h = NULL;
-virtual_sound_stream_info_s *g_voip_ringtone_vstream_h = NULL;
-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 ret = SOUND_MANAGER_ERROR_NONE;
return MM_ERROR_NONE;
}
-//LCOV_EXCL_START
-static int _convert_stream_type_to_interrupt_reason(const char *stream_type, sound_session_interrupted_code_e *change_reason)
-{
- SM_NULL_ARG_CHECK_FOR_PRIV(stream_type);
- SM_NULL_ARG_CHECK_FOR_PRIV(change_reason);
-
- if (!strncmp(stream_type, "media", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "radio", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "voice-information", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "voice-recognition", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "voice-recognition-service", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "loopback", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "ext-media", SOUND_STREAM_TYPE_LEN)) {
- *change_reason = SOUND_SESSION_INTERRUPTED_BY_MEDIA;
-
- } else if (!strncmp(stream_type, "alarm", SOUND_STREAM_TYPE_LEN)) {
- *change_reason = SOUND_SESSION_INTERRUPTED_BY_ALARM;
-
- } else if (!strncmp(stream_type, "notification", SOUND_STREAM_TYPE_LEN)) {
- *change_reason = SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION;
-
- } else if (!strncmp(stream_type, "emergency", SOUND_STREAM_TYPE_LEN)) {
- *change_reason = SOUND_SESSION_INTERRUPTED_BY_EMERGENCY;
-
- } else if (!strncmp(stream_type, "ringtone-voip", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "ringtone-call", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "ringbacktone-call", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "voip", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "call-voice", SOUND_STREAM_TYPE_LEN) ||
- !strncmp(stream_type, "call-video", SOUND_STREAM_TYPE_LEN)) {
- *change_reason = SOUND_SESSION_INTERRUPTED_BY_CALL;
-
- } else {
- LOGE("not supported stream_type(%s) for session interrupted cb", stream_type);
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- return MM_ERROR_NONE;
-}
-//LCOV_EXCL_STOP
-
static int __get_dbus_connection(GDBusConnection **conn)
{
GError *err = NULL;
return;
}
-//LCOV_EXCL_START
-static int _check_media_stream_exist_by_pid(unsigned int pid, const char *direction, bool *exist)
-{
- int ret = MM_ERROR_NONE;
- GVariant *result = NULL;
- GDBusConnection *conn = NULL;
- GError *err = NULL;
- const gchar *dbus_ret = NULL;
-
- assert(exist);
- assert(direction);
-
- if ((ret = __get_dbus_connection(&conn)))
- return ret;
-
- result = g_dbus_connection_call_sync(conn,
- PA_BUS_NAME,
- PA_STREAM_MANAGER_OBJECT_PATH,
- PA_STREAM_MANAGER_INTERFACE,
- PA_STREAM_MANAGER_METHOD_NAME_CHECK_STREAM_EXIST_BY_PID,
- g_variant_new("(uss)", pid, "media", direction),
- G_VARIANT_TYPE("(s)"),
- G_DBUS_CALL_FLAGS_NONE,
- 2000,
- NULL,
- &err);
- if (!result || err) {
- LOGE("g_dbus_connection_call_sync() for CHECK_STREAM_EXIST_BY_PID error (%s)", err ? err->message : NULL);
- g_error_free(err);
- ret = MM_ERROR_SOUND_INTERNAL;
- goto LEAVE;
- }
-
- 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)))
- *exist = true;
- else if (!strncmp("STREAM_MANAGER_RETURN_ERROR_NO_STREAM", dbus_ret, strlen(dbus_ret)))
- *exist = false;
- else
- ret = MM_ERROR_SOUND_INTERNAL;
-
-LEAVE:
- g_variant_unref(result);
- g_object_unref(conn);
-
- return ret;
-}
-
-void _focus_session_interrupt_cb(mm_sound_focus_state_e state, const char *reason, void *user_data)
-{
- sound_session_interrupted_code_e e;
- int ret = MM_ERROR_NONE;
- int cur_session = -1;
- int cur_session_option = -1;
-
- if (!g_session_interrupt_cb_table.user_cb) {
- LOGE("user_cb is null");
- return;
- }
- if (_convert_stream_type_to_interrupt_reason(reason, &e)) {
- LOGE("failed to session _convert_stream_type_to_interrupt_reason[%s]", reason);
- return;
- }
-
- ret = mm_session_get_current_information(&cur_session, &cur_session_option);
- if (ret == MM_ERROR_INVALID_HANDLE) {
- cur_session = MM_SESSION_TYPE_MEDIA;
- } else if (ret != MM_ERROR_NONE) {
- LOGE("failed to mm_session_get_current_type()");
- return;
- }
-
- if (state == FOCUS_IS_RELEASED) {
- if (cur_session != MM_SESSION_TYPE_MEDIA &&
- cur_session != MM_SESSION_TYPE_MEDIA_RECORD) {
- LOGI("current session is not media, skip resumption");
- return;
- }
- if (e == SOUND_SESSION_INTERRUPTED_BY_MEDIA) {
- /* check if this media session is resumable */
- if (cur_session_option == -1 ||
- !(cur_session_option & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED)) {
- LOGI("current media session option is not resumable by media, skip resumption");
- return;
- }
- }
- e = SOUND_SESSION_INTERRUPTED_COMPLETED;
- }
-
- LOGE("session interrupted by [%s], interrupted code[%d], user_cb[%p]", reason, e, g_session_interrupt_cb_table.user_cb);
- g_session_interrupt_cb_table.user_cb(e, g_session_interrupt_cb_table.user_data);
-
- return;
-}
-
-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) {
- LOGE("getting device type failed");
- return;
- }
-
- switch (type) {
- case MM_SOUND_DEVICE_TYPE_AUDIOJACK:
- case MM_SOUND_DEVICE_TYPE_BLUETOOTH_A2DP:
- case MM_SOUND_DEVICE_TYPE_BLUETOOTH_SCO:
- case MM_SOUND_DEVICE_TYPE_HDMI:
- case MM_SOUND_DEVICE_TYPE_MIRRORING:
- case MM_SOUND_DEVICE_TYPE_USB_AUDIO:
- if (!is_connected) {
- bool stream_exist = false;
- LOGI("sound device(%d) is unplugged", type);
- if (!_check_media_stream_exist_by_pid(getpid(), "out", &stream_exist)) {
- if (stream_exist) {
- LOGI("invoke user_cb(%p) for interrupted_by_earjack_unplug", g_session_interrupt_cb_table.user_cb);
- g_session_interrupt_cb_table.user_cb(SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG, g_session_interrupt_cb_table.user_data);
- }
- break;
- }
- if (!_check_media_stream_exist_by_pid(getpid(), "in", &stream_exist)) {
- if (stream_exist) {
- LOGI("invoke user_cb(%p) for interrupted_by_earjack_unplug", g_session_interrupt_cb_table.user_cb);
- g_session_interrupt_cb_table.user_cb(SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG, g_session_interrupt_cb_table.user_data);
- }
- break;
- }
- }
- break;
- default:
- break;
- }
-
- return;
-}
-
-/* This is an internal callback for the VOIP SESSION */
-void _voip_focus_state_change_callback(sound_stream_info_h stream_info,
- sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state,
- sound_stream_focus_change_reason_e reason, int sound_behavior, const char *extra_info, void *user_data)
-{
- sound_stream_info_s *info = (sound_stream_info_s *)stream_info;
- LOGI(">> enter, stream_info(%p), change_reason(%d), sound_behavior(0x%x), extra_info(%s)", stream_info, reason, sound_behavior, extra_info);
-
- if (!info) {
- LOGE("stream info is null");
- return;
- }
-
- if (!(info->acquired_focus & SOUND_STREAM_FOCUS_FOR_PLAYBACK) ||
- !(info->acquired_focus & SOUND_STREAM_FOCUS_FOR_RECORDING)) {
- /* stop virtual stream for rintone-voip or voip */
- if (g_voip_ringtone_vstream_h) {
- _stop_progress_virtual_stream(g_voip_ringtone_vstream_h);
- g_voip_ringtone_vstream_h = NULL;
- LOGW("internal voip ringtone stream is interrupted by (%d)", reason);
- }
- if (g_voip_vstream_h) {
- _stop_progress_virtual_stream(g_voip_vstream_h);
- g_voip_vstream_h = NULL;
- LOGW("internal voip stream is interrupted by (%d)", reason);
- }
- }
-
- LOGI("<< leave");
-
- return;
-}
-//LCOV_EXCL_STOP
-
-int _set_session_mode(_session_mode_e mode)
-{
- int ret = MM_ERROR_NONE;
- MMSoundDeviceList_t device_list = NULL;
- MMSoundDevice_t tmp_device = NULL;
- MMSoundDevice_t proper_device = NULL;
- MMSoundDevice_t proper_device2 = NULL;
- MMSoundDevice_t proper_device_builtin_mic = NULL;
- MMSoundDevice_t prev_device = NULL;
- MMSoundDevice_t prev_device2 = NULL;
- mm_sound_device_type_e type;
- int id = -1;
-
- if (g_cached_session_mode == mode) {
- LOGW("session_mode(%d) is same as before", mode);
- return ret;
- }
-
- if (mode == _SESSION_MODE_RINGTONE) {
- if (g_voip_vstream_h) {
- _stop_progress_virtual_stream(g_voip_vstream_h);
- g_voip_vstream_h = NULL;
- }
- if (!g_voip_ringtone_stream_info) {
- g_voip_ringtone_stream_info = malloc(sizeof(sound_stream_info_s));
- if (!g_voip_ringtone_stream_info) {
- ret = MM_ERROR_OUT_OF_MEMORY;
- goto ERROR_CASE_RINGTONE;
- }
- memset(g_voip_ringtone_stream_info, 0, sizeof(sound_stream_info_s));
- g_voip_ringtone_stream_info->stream_type = "ringtone-voip";
- if ((ret = _make_pa_connection_and_register_focus(g_voip_ringtone_stream_info, true, _voip_focus_state_change_callback, NULL))) {
- SM_SAFE_FREE(g_voip_ringtone_stream_info);
- goto ERROR_CASE_RINGTONE;
- }
- }
-
- if ((ret = mm_sound_acquire_focus(g_voip_ringtone_stream_info->index, FOCUS_FOR_BOTH, EXT_INFO_VOIP_SESSION))) {
- if (ret != MM_ERROR_SOUND_INVALID_STATE)
- goto ERROR_CASE_RINGTONE;
- LOGI("already acquired, skip it");
- ret = MM_ERROR_NONE;
- }
-
- g_voip_ringtone_stream_info->acquired_focus |= FOCUS_FOR_BOTH;
- _update_focus_status(g_voip_ringtone_stream_info->index, (unsigned int)g_voip_ringtone_stream_info->acquired_focus);
-
- /* create and start virtual stream for ringtone-voip */
- if (!g_voip_ringtone_vstream_h) {
- if ((ret = _make_progress_virtual_stream(g_voip_ringtone_stream_info, &g_voip_ringtone_vstream_h))) {
- ret = MM_ERROR_SOUND_INTERNAL;
- goto ERROR_CASE_RINGTONE;
- }
- }
-
- } else {
- /* _SESSION_MODE_VOICE_WITH_BUILTIN_RECEIVER: Built-in RCV and Built-in MIC
- * _SESSION_MODE_VOICE_WITH_BUILTIN_SPEAKER : Built-in SPK and Built-in MIC
- * _SESSION_MODE_VOICE_WITH_AUDIO_JACK : Earphone SPK & MIC(4P) or Earphone SPK & Built-in MIC(3P)
- * _SESSION_MODE_VOICE_WITH_BLUETOOTH_SCO : Bluetooth SPK & MIC */
-
- /* check if the device is available now */
- if ((ret = mm_sound_get_device_list(MM_SOUND_DEVICE_ALL_FLAG, &device_list))) {
- LOGE("failed to get current device list");
- goto ERROR_CASE;
- }
-
- while ((mm_sound_get_next_device(device_list, &tmp_device) == MM_ERROR_NONE)) {
- if ((ret = mm_sound_get_device_type(tmp_device, &type)))
- goto ERROR_CASE;
- if ((ret = mm_sound_get_device_id(tmp_device, &id)))
- goto ERROR_CASE;
-
- if (g_cached_voip_device_id == id || g_cached_voip_device_id2 == id)
- CHECK_AND_SET_DEVICE(prev_device, prev_device2, tmp_device);
-
- switch (mode) {
- case _SESSION_MODE_VOICE_WITH_BUILTIN_RECEIVER:
- if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER || type == MM_SOUND_DEVICE_TYPE_BUILTIN_MIC)
- CHECK_AND_SET_DEVICE(proper_device, proper_device2, tmp_device);
- break;
- case _SESSION_MODE_VOICE_WITH_BUILTIN_SPEAKER:
- if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER || type == MM_SOUND_DEVICE_TYPE_BUILTIN_MIC)
- CHECK_AND_SET_DEVICE(proper_device, proper_device2, tmp_device);
- break;
- //LCOV_EXCL_START
- case _SESSION_MODE_VOICE_WITH_AUDIO_JACK:
- if (type == MM_SOUND_DEVICE_TYPE_BUILTIN_MIC)
- proper_device_builtin_mic = tmp_device;
-
- if (type == MM_SOUND_DEVICE_TYPE_AUDIOJACK) {
- mm_sound_device_io_direction_e direction;
- if ((ret = mm_sound_get_device_io_direction(tmp_device, &direction)))
- goto ERROR_CASE;
- if (direction == MM_SOUND_DEVICE_IO_DIRECTION_BOTH) { /* 4P earpiece */
- CHECK_AND_SET_DEVICE(proper_device, proper_device2, tmp_device);
- } else if (direction == MM_SOUND_DEVICE_IO_DIRECTION_OUT) { /* 3P earpiece */
- proper_device = proper_device_builtin_mic;
- proper_device2 = tmp_device;
- } else {
- LOGE("invalid direction[%d] for audiojack device", direction);
- goto ERROR_CASE;
- }
- }
- break;
- case _SESSION_MODE_VOICE_WITH_BLUETOOTH_SCO:
- if (type == MM_SOUND_DEVICE_TYPE_BLUETOOTH_SCO)
- CHECK_AND_SET_DEVICE(proper_device, proper_device2, tmp_device);
- break;
- //LCOV_EXCL_STOP
- default:
- break;
- }
- }
-
- if (!proper_device && !proper_device2) {
- LOGE("failed to find any proper device");
- goto ERROR_CASE_NO_DESTROY;
- }
-
- if (g_voip_ringtone_vstream_h) {
- _stop_progress_virtual_stream(g_voip_ringtone_vstream_h);
- g_voip_ringtone_vstream_h = NULL;
- }
-
- if (!g_voip_stream_info) {
- g_voip_stream_info = malloc(sizeof(sound_stream_info_s));
- if (!g_voip_stream_info) {
- LOGE("failed to malloc for g_voip_stream_info");
- goto ERROR_CASE;
- }
- memset(g_voip_stream_info, 0, sizeof(sound_stream_info_s));
- LOGI("g_voip_stream_info(%p) is newly created", g_voip_stream_info);
- g_voip_stream_info->stream_type = "voip";
- if ((ret = _make_pa_connection_and_register_focus(g_voip_stream_info, true, _voip_focus_state_change_callback, NULL))) {
- SM_SAFE_FREE(g_voip_stream_info);
- goto ERROR_CASE;
- }
-
- if ((ret = mm_sound_acquire_focus(g_voip_stream_info->index, FOCUS_FOR_BOTH, EXT_INFO_VOIP_SESSION))) {
- if (ret != MM_ERROR_SOUND_INVALID_STATE)
- goto ERROR_CASE;
- LOGI("already acquired, skip it");
- ret = MM_ERROR_NONE;
- }
-
- if (proper_device) {
- if ((ret = _add_device_for_stream_routing(g_voip_stream_info, proper_device)))
- goto ERROR_CASE;
- }
- if (proper_device2) {
- if ((ret = _add_device_for_stream_routing(g_voip_stream_info, proper_device2)))
- goto ERROR_CASE;
- }
-
- if ((ret = _apply_stream_routing(g_voip_stream_info)))
- goto ERROR_CASE;
-
- 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 {
- if ((ret = mm_sound_acquire_focus(g_voip_stream_info->index, FOCUS_FOR_BOTH, EXT_INFO_VOIP_SESSION))) {
- if (ret != MM_ERROR_SOUND_INVALID_STATE)
- goto ERROR_CASE_NO_DESTROY;
- LOGI("already acquired, skip it");
- ret = MM_ERROR_NONE;
- }
-
- if (prev_device) {
- if ((ret = _remove_device_for_stream_routing(g_voip_stream_info, prev_device)))
- goto ERROR_CASE_NO_DESTROY;
- }
- if (prev_device2) {
- if ((ret = _remove_device_for_stream_routing(g_voip_stream_info, prev_device2)))
- goto ERROR_CASE_NO_DESTROY;
- }
- if (proper_device) {
- if ((ret = _add_device_for_stream_routing(g_voip_stream_info, proper_device)))
- goto ERROR_CASE_NO_DESTROY;
- }
- if (proper_device2) {
- if ((ret = _add_device_for_stream_routing(g_voip_stream_info, proper_device2)))
- goto ERROR_CASE_NO_DESTROY;
- }
- if ((ret = _apply_stream_routing(g_voip_stream_info)))
- goto ERROR_CASE_NO_DESTROY;
- }
-
- if (!g_voip_vstream_h) {
- if ((ret = _make_progress_virtual_stream(g_voip_stream_info, &g_voip_vstream_h))) {
- ret = MM_ERROR_SOUND_INTERNAL;
- goto ERROR_CASE;
- }
- }
- if (proper_device)
- mm_sound_get_device_id(proper_device, &g_cached_voip_device_id);
- else
- g_cached_voip_device_id = -1;
- if (proper_device2)
- mm_sound_get_device_id(proper_device2, &g_cached_voip_device_id2);
- else
- g_cached_voip_device_id2 = -1;
- if (device_list)
- mm_sound_free_device_list(device_list);
- }
- g_cached_session_mode = mode;
-
- return ret;
-//LCOV_EXCL_START
-ERROR_CASE_RINGTONE:
- if (g_voip_ringtone_vstream_h) {
- _destroy_virtual_stream(g_voip_ringtone_vstream_h);
- g_voip_ringtone_vstream_h = NULL;
- }
- if (g_voip_ringtone_stream_info) {
- _destroy_pa_connection_and_unregister_focus(g_voip_ringtone_stream_info);
- SM_SAFE_FREE(g_voip_ringtone_stream_info);
- }
- return ret;
-ERROR_CASE:
- if (g_voip_vstream_h) {
- _destroy_virtual_stream(g_voip_vstream_h);
- g_voip_vstream_h = NULL;
- }
- if (g_voip_stream_info) {
- _destroy_pa_connection_and_unregister_focus(g_voip_stream_info);
- SM_SAFE_FREE(g_voip_stream_info);
- }
-ERROR_CASE_NO_DESTROY:
- if (device_list)
- mm_sound_free_device_list(device_list);
- ret = MM_ERROR_SOUND_INTERNAL;
- return ret;
-//LCOV_EXCL_STOP
-}
-
-int _make_pa_connection_and_register_focus(sound_stream_info_s *stream_h, bool is_for_session, sound_stream_focus_state_changed_cb callback, void *user_data)
+int _make_pa_connection_and_register_focus(sound_stream_info_s *stream_h, sound_stream_focus_state_changed_cb callback, void *user_data)
{
int ret = MM_ERROR_NONE;
int pa_ret = PA_OK;
/* register focus */
if (!stream_h->is_focus_unavailable) {
- if (is_for_session)
- ret = mm_sound_register_focus_for_session(stream_h->index, getpid(), stream_h->stream_type, _focus_state_change_callback, stream_h);
- else
- ret = mm_sound_register_focus(stream_h->index, stream_h->stream_type, _focus_state_change_callback, stream_h);
+ ret = mm_sound_register_focus(stream_h->index, stream_h->stream_type, _focus_state_change_callback, stream_h);
if (ret == MM_ERROR_NONE) {
stream_h->user_cb = callback;
stream_h->user_data = user_data;
SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
if (stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL &&
- stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL_EXT) {
+ stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL_EXT) {
LOGE("route type is not manual or manual-ext");
return MM_ERROR_POLICY_INTERNAL;
}
CURRENT_STATUS_GET_MAX_VOLUME,
CURRENT_STATUS_SET_VOLUME,
CURRENT_STATUS_GET_VOLUME,
- CURRENT_STATUS_SET_CURRENT_SOUND_TYPE,
CURRENT_STATUS_GET_CURRENT_SOUND_TYPE,
- CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE,
- CURRENT_STATUS_SET_VOLUME_CHANGED_CB,
- CURRENT_STATUS_UNSET_VOLUME_CHANGED_CB,
- CURRENT_STATUS_SET_SESSION_TYPE,
- CURRENT_STATUS_GET_SESSION_TYPE,
- CURRENT_STATUS_SET_MEDIA_SESSION_OPTION,
- CURRENT_STATUS_GET_MEDIA_SESSION_OPTION,
- CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION,
- CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION,
- CURRENT_STATUS_SET_VOIP_SESSION_MODE,
- CURRENT_STATUS_GET_VOIP_SESSION_MODE,
- CURRENT_STATUS_SET_CALL_SESSION_MODE,
- CURRENT_STATUS_GET_CALL_SESSION_MODE,
- CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB,
- CURRENT_STATUS_UNSET_SESSION_INTERRUPTED_CB,
+ CURRENT_STATUS_ADD_VOLUME_CHANGED_CB,
+ CURRENT_STATUS_REMOVE_VOLUME_CHANGED_CB,
CURRENT_STATUS_SET_DEVICE_MASK,
CURRENT_STATUS_GET_DEVICE_MASK,
- CURRENT_STATUS_GET_CURRENT_DEVICE_LIST,
CURRENT_STATUS_PRINT_DEVICE_LIST,
CURRENT_STATUS_GET_DEVICE_LIST,
CURRENT_STATUS_FREE_DEVICE_LIST,
CURRENT_STATUS_GET_DEVICE_NEXT,
CURRENT_STATUS_GET_DEVICE_PREV,
CURRENT_STATUS_GET_DEVICE_STATE_BY_ID,
- CURRENT_STATUS_SET_DEVICE_CONNECTED_CB,
- CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB,
CURRENT_STATUS_ADD_DEVICE_CONNECTION_CHANGED_CB,
CURRENT_STATUS_REMOVE_DEVICE_CONNECTION_CHANGED_CB,
- CURRENT_STATUS_SET_DEVICE_INFO_CHANGED_CB,
- CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB,
CURRENT_STATUS_ADD_DEVICE_STATE_CHANGED_CB,
CURRENT_STATUS_REMOVE_DEVICE_STATE_CHANGED_CB,
CURRENT_STATUS_CREATE_STREAM_INFO,
sound_device_mask_e g_device_mask = SOUND_DEVICE_ALL_MASK;
sound_stream_info_h g_stream_info_h = NULL;
virtual_sound_stream_h g_vstream_h = NULL;
+int g_volume_cb_id;
int g_device_conn_cb_id;
int g_device_state_cb_id;
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, "av", 3) == 0)
+ g_menu_state = CURRENT_STATUS_ADD_VOLUME_CHANGED_CB;
+ else if (strncmp(cmd, "rv", 3) == 0)
+ g_menu_state = CURRENT_STATUS_REMOVE_VOLUME_CHANGED_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, "gcl", 3) == 0)
- g_menu_state = CURRENT_STATUS_GET_CURRENT_DEVICE_LIST;
else if (strncmp(cmd, "gl", 3) == 0)
g_menu_state = CURRENT_STATUS_GET_DEVICE_LIST;
else if (strncmp(cmd, "pl", 3) == 0)
g_menu_state = CURRENT_STATUS_GET_DEVICE_PREV;
else if (strncmp(cmd, "gd", 3) == 0)
g_menu_state = CURRENT_STATUS_GET_DEVICE_STATE_BY_ID;
- 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, "adcc", 4) == 0)
g_menu_state = CURRENT_STATUS_ADD_DEVICE_CONNECTION_CHANGED_CB;
else if (strncmp(cmd, "rdcc", 4) == 0)
g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_CONNECTION_CHANGED_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, "adsc", 4) == 0)
g_menu_state = CURRENT_STATUS_ADD_DEVICE_STATE_CHANGED_CB;
else if (strncmp(cmd, "rdsc", 4) == 0)
g_print("gx. Get Max Volume \t");
g_print("gv. Get Volume \t");
g_print("sv. Set Volume \n");
- g_print("st. Set Current Sound Type \t");
- g_print("gt. Get Current Sound Type \t");
- g_print("ut. Unset Current Sound Type \n");
- g_print("vc. Set Volume Changed CB \t");
- g_print("uv. Unset Volume Changed CB \n");
+ g_print("gt. Get Current Sound Type \n");
+ g_print("av. Add Volume Changed CB \t");
+ g_print("rv. Remove Volume Changed CB \n");
#ifndef TIZEN_FEATURE_TV_PROD
g_print("mgx. *Get Max Master Volume \t");
g_print("mgv. *Get Master Volume \t");
g_print("msv. *Set Master Volume \n");
#endif
- g_print("-----------------------------------------------------------------------------------------\n");
- g_print(" SESSION MODULE \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");
- g_print("gm. Get Media Session Option \n");
- g_print("sr. Set Media Session Resumption Option \t");
- g_print("gr. Get Media Session Resumption Option \n");
- g_print("so. Set Voip Session Mode \t");
- g_print("go. Get Voip Session Mode \n");
- g_print("sc. Set Session Interruped CB \t");
- g_print("us. Unset Session Interrupted CB \n");
g_print("-----------------------------------------------------------------------------------------\n");
g_print(" DEVICE MODULE \n");
g_print("-----------------------------------------------------------------------------------------\n");
g_print("sk. Set Devices Mask(default ALL)\t");
g_print("gk. Get Devices Mask\n");
- g_print("gcl. Get Devices List\t");
g_print("pl. Print Devices List\t");
g_print("gl. Get Devices List\t");
g_print("fl. Free Devices List\n");
g_print("gn. Get Next Device\t\t");
g_print("gp. Get Prev Device\n");
g_print("gd. *Get Device State by Id\n");
- g_print("sd. Set Device Connenected CB\t\t");
- g_print("ud. Unset Device Connenected CB\n");
- g_print("si. Set Device Information Changed CB\t");
- g_print("ui. Unset Device Information Changed CB\n");
g_print("adcc. Add Device Connenection Changed CB\t\t");
g_print("rdcc. Remove Device Connenection Changed CB\n");
g_print("adsc. Add Device State Changed CB\t\t");
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");
- flag = 1;
- } 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_ADD_VOLUME_CHANGED_CB)
+ g_print("*** press enter to add volume changed cb\n");
+ else if (g_menu_state == CURRENT_STATUS_REMOVE_VOLUME_CHANGED_CB)
+ g_print("*** press enter to remove volume changed 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_CURRENT_DEVICE_LIST)
- g_print("*** press enter to get current device list\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_PRINT_DEVICE_LIST)
g_print("*** press enter to get previous device from the list\n");
else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_STATE_BY_ID)
g_print("*** press enter device id to get state\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_ADD_DEVICE_CONNECTION_CHANGED_CB)
g_print("*** press enter to add device connected cb\n");
else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_CONNECTION_CHANGED_CB)
g_print("*** press enter to remove 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_ADD_DEVICE_STATE_CHANGED_CB)
g_print("*** press enter to add device state changed cb\n");
else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_STATE_CHANGED_CB)
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;
- }
- }
- return 1;
-}
-
-void _set_volume_changed_cb(sound_type_e type, unsigned int volume, void *user_data)
+void _volume_changed_cb(sound_type_e type, unsigned int volume, void *user_data)
{
g_print("***the volume has changed. the volume of this sound type(%d) is : %d \n", type, volume);
}
-void _set_session_interrupted_cb(sound_session_interrupted_code_e code, void *user_data)
-{
- g_print("***your session has been interrupted by (%d)\n", code);
-}
-
/* If failed to get some property, just give some default value */
void _get_device_props_simple(sound_device_h device, int *id, char **type, char **name,
const char **direc, const char **state, int *vendor_id, int *product_id)
}
}
-void _set_device_connected_cb(sound_device_h device, bool is_connected, void *user_data)
+void _device_connected_cb(sound_device_h device, bool is_connected, void *user_data)
{
int id = -1;
int vendor_id = -1;
g_print(" Direc[ %-4s ] State[ %-12s ] VendorID[ %04x ], ProductID[ %04x ]\n", direc, state, vendor_id, product_id);
}
-void _set_device_info_changed_cb(sound_device_h device, sound_device_changed_info_e changed_info, void *user_data)
-{
-
- int id = -1;
- int vendor_id = -1;
- int product_id = -1;
- char *type, *name;
- const char *direc, *state;
- const char *changed_info_str[] = {"State", "Direction", "Avail-Mode"};
-
- _get_device_props_simple(device, &id, &type, &name, &direc, &state, &vendor_id, &product_id);
-
- g_print("[Device #%d %s %s] %s changed\n", id, type, name, changed_info_str[changed_info]);
- g_print(" Direc[ %-4s ] State[ %-12s ] VendorID[ %04x ], ProductID[ %04x ]\n", direc, state, vendor_id, product_id);
-}
-
void _device_state_changed_cb(sound_device_h device, sound_device_state_e state, void *user_data)
{
int id = -1;
reset_menu_state();
break;
}
- case CURRENT_STATUS_SET_CURRENT_SOUND_TYPE: {
- sound_type_e type;
- if (convert_sound_type(&type, cmd) == 1) {
- if (sound_manager_set_current_sound_type(type) != SOUND_MANAGER_ERROR_NONE)
- 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: {
sound_type_e type;
if (sound_manager_get_current_sound_type(&type) != SOUND_MANAGER_ERROR_NONE)
reset_menu_state();
break;
}
- case CURRENT_STATUS_UNSET_CURRENT_SOUND_TYPE: {
- if (sound_manager_unset_current_sound_type() != SOUND_MANAGER_ERROR_NONE)
- 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_SET_VOLUME_CHANGED_CB: {
- if (sound_manager_set_volume_changed_cb(_set_volume_changed_cb, NULL) != SOUND_MANAGER_ERROR_NONE)
- 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_UNSET_VOLUME_CHANGED_CB: {
- if (sound_manager_unset_volume_changed_cb() != SOUND_MANAGER_ERROR_NONE)
- 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_SET_SESSION_TYPE: {
- sound_session_type_e type;
- if (convert_session_type(&type, cmd) == 1) {
- if (sound_manager_set_session_type(type) != SOUND_MANAGER_ERROR_NONE)
- g_print("fail to set session type\n");
- else
- g_print("success to set session type(%d)\n", type);
- }
- reset_menu_state();
- break;
- }
- case CURRENT_STATUS_GET_SESSION_TYPE: {
- sound_session_type_e type;
- if (sound_manager_get_session_type(&type) != SOUND_MANAGER_ERROR_NONE)
- 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: {
- 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) != SOUND_MANAGER_ERROR_NONE) {
- 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_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_UNINTERRUPTIBLE_DURING_PLAY < option_d)
- g_print("not supported option type\n");
- else {
- if (sound_manager_set_media_session_option(option_s, option_d) != SOUND_MANAGER_ERROR_NONE)
- 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;
- }
- }
- break;
- }
- case CURRENT_STATUS_GET_MEDIA_SESSION_OPTION: {
- sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
- sound_session_option_for_starting_e option_s;
- sound_session_option_for_during_play_e option_d;
- if (sound_manager_set_session_type(type) != SOUND_MANAGER_ERROR_NONE)
- g_print("fail to set media session type\n");
- else {
- if (sound_manager_get_media_session_option(&option_s, &option_d) != SOUND_MANAGER_ERROR_NONE)
- 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();
- break;
- }
- case CURRENT_STATUS_SET_MEDIA_SESSION_RESUMPTION_OPTION: {
- sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
- sound_session_option_for_resumption_e option_r;
- if (sound_manager_set_session_type(type) != SOUND_MANAGER_ERROR_NONE)
- 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_OR_MEDIA_PAUSED < option_r)
- g_print("not supported option type\n");
- else {
- if (sound_manager_set_media_session_resumption_option(option_r) != SOUND_MANAGER_ERROR_NONE)
- g_print("fail to set media session resumption option\n");
- else
- g_print("succese to set media session resumption option\n");
- }
- }
- reset_menu_state();
- break;
- }
- case CURRENT_STATUS_GET_MEDIA_SESSION_RESUMPTION_OPTION: {
- sound_session_type_e type = SOUND_SESSION_TYPE_MEDIA;
- sound_session_option_for_resumption_e option_r;
- if (sound_manager_set_session_type(type) != SOUND_MANAGER_ERROR_NONE)
- g_print("fail to set media session type\n");
- else {
- if (sound_manager_get_media_session_resumption_option(&option_r) != SOUND_MANAGER_ERROR_NONE)
- 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();
- 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");
- 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);
- else
- g_print("success to get voip session mode, mode[%d]\n", mode);
- reset_menu_state();
- break;
- }
- case CURRENT_STATUS_SET_SESSION_INTERRUPTED_CB: {
- if (sound_manager_set_session_interrupted_cb(_set_session_interrupted_cb, NULL) != SOUND_MANAGER_ERROR_NONE)
- g_print("fail to set interrupted changed cb\n");
+ case CURRENT_STATUS_ADD_VOLUME_CHANGED_CB: {
+ if (sound_manager_add_volume_changed_cb(_volume_changed_cb, NULL, &g_volume_cb_id) != SOUND_MANAGER_ERROR_NONE)
+ g_print("fail to add volume changed cb\n");
else
- g_print("success to set interrupted changed cb\n");
+ g_print("success to add volume changed cb, id[%d]\n", g_volume_cb_id);
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");
+ case CURRENT_STATUS_REMOVE_VOLUME_CHANGED_CB: {
+ if (sound_manager_remove_volume_changed_cb(g_volume_cb_id) != SOUND_MANAGER_ERROR_NONE)
+ g_print("fail to remove volume changed cb, id[%d]\n", g_volume_cb_id);
else
- g_print("success to unset interrupted changed cb\n");
+ g_print("success to remove volume changed cb, id[%d]\n", g_volume_cb_id);
reset_menu_state();
break;
}
reset_menu_state();
break;
}
- case CURRENT_STATUS_GET_CURRENT_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_GET_DEVICE_LIST: {
int ret = SOUND_MANAGER_ERROR_NONE;
if (!(ret = sound_manager_get_device_list(g_device_mask, &g_device_list)))
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();
- 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();
- break;
- }
case CURRENT_STATUS_ADD_DEVICE_CONNECTION_CHANGED_CB: {
- if (sound_manager_add_device_connection_changed_cb(g_device_mask, _set_device_connected_cb, NULL, &g_device_conn_cb_id))
+ if (sound_manager_add_device_connection_changed_cb(g_device_mask, _device_connected_cb, NULL, &g_device_conn_cb_id))
g_print("fail to add device connection changed cb\n");
else
g_print("success to add device connection changed cb\n");
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();
- 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_ADD_DEVICE_STATE_CHANGED_CB: {
if (sound_manager_add_device_state_changed_cb(g_device_mask, _device_state_changed_cb, NULL, &g_device_state_cb_id))
g_print("fail to add device state changed cb\n");
return TRUE;
}
-/* it will be removed when session features are deprecated. */
-void signal_callback(mm_sound_signal_name_t signal, int value, void *user_data)
-{
- g_print("*** signal callback is called: signal(%d), value(%d), user_data(%p)\n", signal, value, user_data);
-}
-
int main(int argc, char *argv[])
{
- unsigned int subscribe_id = 0;
- int ret = MM_ERROR_NONE;
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_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
g_loop = g_main_loop_new(NULL, 1);
- /* subscribe a signal for convering session-focus */
- /* it will be removed when session features are deprecated. */
- if ((ret = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &subscribe_id, signal_callback, NULL)))
- g_print("failed to subscribe signal, ret(0x%x)\n", ret);
-
displaymenu();
g_main_loop_run(g_loop);
- /* it will be removed when session features are deprecated. */
- if (subscribe_id)
- mm_sound_unsubscribe_signal(subscribe_id);
-
return 0;
}