-#ifdef USE_FOCUS
-void _mm_sound_client_focus_signal_callback(mm_sound_signal_name_t signal, int value, void *user_data)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- debug_msg("focus signal received, value = %d", value);
-
- if (value == 1) {
- ret = mm_sound_proxy_clear_focus(getpid());
- if (ret)
- debug_error("clear focus failed ret = 0x%x", ret);
- mm_sound_unsubscribe_signal(g_focus_signal_handle);
- g_focus_signal_handle = 0;
- }
-}
-#endif
-
-int mm_sound_client_play_tone(int number, int volume_config, double volume,
- int time, int *handle, bool enable_session)
-{
- int ret = MM_ERROR_NONE;
-// int instance = -1; /* instance is unique to communicate with server : client message queue filter type */
- int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(volume_config);
- char stream_type[MM_SOUND_STREAM_TYPE_LEN] = {0, };
-
- debug_fenter();
-
- /* read session information */
- int session_type = MM_SESSION_TYPE_MEDIA;
- int session_options = 0;
- int is_focus_registered = 0;
-
- ret = mm_sound_get_signal_value(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &is_focus_registered);
- if (ret) {
- debug_error("mm_sound_get_signal_value failed [0x%x]", ret);
- return MM_ERROR_POLICY_INTERNAL;
- }
-
- if (is_focus_registered)
- enable_session = false;
-
- if (enable_session) {
- if (MM_ERROR_NONE != _mm_session_util_read_information(-1, &session_type, &session_options)) {
- debug_warning("[Client] Read Session Information failed. use default \"media\" type\n");
- session_type = MM_SESSION_TYPE_MEDIA;
-
- if(MM_ERROR_NONE != mm_session_init(session_type)) {
- debug_critical("[Client] MMSessionInit() failed\n");
- return MM_ERROR_POLICY_INTERNAL;
- }
- }
- }
-
- // instance = getpid();
- //debug_log("[Client] pid for client ::: [%d]\n", instance);
-
- /* Send msg */
- debug_msg("[Client] Input number : %d\n", number);
- /* Send req memory */
-
- mm_sound_convert_volume_type_to_stream_type(volume_type, stream_type);
- ret = mm_sound_proxy_play_tone(number, time, volume, volume_config,
- session_type, session_options, getpid(), enable_session, handle, stream_type, -1);
-#ifdef USE_FOCUS
- if (enable_session && !g_focus_signal_handle) {
- ret = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &g_focus_signal_handle,
- _mm_sound_client_focus_signal_callback, NULL);
- if (ret) {
- debug_error("mm_sound_subscribe_signal failed [0x%x]", ret);
- return MM_ERROR_POLICY_INTERNAL;
- }
- }
-#endif
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_play_tone_with_stream_info(int tone, char *stream_type, int stream_id,
- double volume, int duration, int *handle)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- ret = mm_sound_proxy_play_tone_with_stream_info(getpid(), tone, stream_type, stream_id, volume, duration, handle);
-
- debug_fleave();
- return ret;
-}
-
-static void _mm_sound_stop_callback_wrapper_func(int ended_handle, void *userdata)
-{
- struct callback_data *cb_data = (struct callback_data*) userdata;
- play_sound_end_callback_data_t *end_cb_data;
-
- debug_log("[Wrapper CB][Play Stop] ended_handle : %d", ended_handle);
-
- if (cb_data == NULL) {
- debug_warning("stop callback data null");
- return;
- }
-
- end_cb_data = (play_sound_end_callback_data_t*) cb_data->extra_data;
-
- if (ended_handle == end_cb_data->watching_handle) {
- debug_log("Interested playing handle end : %d", ended_handle);
- ((mm_sound_stop_callback_func)(cb_data->user_cb))(cb_data->user_data, ended_handle);
- if (mm_sound_proxy_remove_play_sound_end_callback(end_cb_data->subs_id) != MM_ERROR_NONE)
- debug_error("mm_sound_client_dbus_remove_play_file_end_callback failed");
- } else {
- debug_log("Not interested playing handle : %d", ended_handle);
- }
-}
-
-static void play_end_callback_data_free_func(void *data)
-{
- struct callback_data *cb_data = (struct callback_data*) data;
-
- if (cb_data) {
- g_free(cb_data->extra_data);
- g_free(cb_data);
- }
-}
-
-int mm_sound_client_play_sound(MMSoundPlayParam *param, int tone, int *handle)
-{
- int ret = MM_ERROR_NONE;
- int session_type = MM_SESSION_TYPE_MEDIA;
- int session_options = 0;
- int is_focus_registered = 0;
-// int instance = -1; /* instance is unique to communicate with server : client message queue filter type */
- int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(param->volume_config);
- char stream_type[MM_SOUND_STREAM_TYPE_LEN] = {0, };
- struct callback_data *cb_data = NULL;
- play_sound_end_callback_data_t *end_cb_data;
-
- debug_fenter();
-
- /* read session information */
-
- ret = mm_sound_get_signal_value(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &is_focus_registered);
- if (ret) {
- debug_error("mm_sound_get_signal_value failed [0x%x]", ret);
- return MM_ERROR_POLICY_INTERNAL;
- }
-
- if (is_focus_registered)
- param->skip_session = true;
-
- if (param->skip_session == false) {
- if(MM_ERROR_NONE != _mm_session_util_read_information(-1, &session_type, &session_options)) {
- debug_warning("[Client] Read MMSession Type failed. use default \"media\" type\n");
- session_type = MM_SESSION_TYPE_MEDIA;
-
- if(MM_ERROR_NONE != mm_session_init(session_type)) {
- debug_critical("[Client] MMSessionInit() failed\n");
- return MM_ERROR_POLICY_INTERNAL;
- }
- }
- }
-
- /* Send msg */
- if ((param->mem_ptr && param->mem_size)) {
- // Play memory, deprecated
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- mm_sound_convert_volume_type_to_stream_type(volume_type, stream_type);
- ret = mm_sound_proxy_play_sound(param->filename, tone, param->loop, param->volume, param->volume_config,
- session_type, session_options, getpid(), param->skip_session, handle, stream_type, -1);
- if (ret != MM_ERROR_NONE) {
- debug_error("Play Sound Failed");
- goto failed;
- }
- if (param->callback) {
- end_cb_data = (play_sound_end_callback_data_t *) g_malloc0(sizeof(play_sound_end_callback_data_t));
- end_cb_data->watching_handle = *handle;
- GET_CB_DATA(cb_data, param->callback, param->data, end_cb_data);
-
- ret = mm_sound_proxy_add_play_sound_end_callback(_mm_sound_stop_callback_wrapper_func, cb_data,
- play_end_callback_data_free_func, &end_cb_data->subs_id);
- if (ret != MM_ERROR_NONE) {
- debug_error("Add callback for play sound(%d) Failed", *handle);
- }
- }
-#ifdef USE_FOCUS
- if (!param->skip_session && !g_focus_signal_handle) {
- ret = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &g_focus_signal_handle,
- _mm_sound_client_focus_signal_callback, NULL);
- if (ret) {
- debug_error("mm_sound_subscribe_signal failed [0x%x]", ret);
- return MM_ERROR_POLICY_INTERNAL;
- }
- }
-#endif
-
-failed:
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_play_sound_with_stream_info(MMSoundPlayParam *param, int *handle, char* stream_type, int stream_id)
-{
- int ret = MM_ERROR_NONE;
- struct callback_data *cb_data = NULL;
- play_sound_end_callback_data_t *end_cb_data;
-
- ret = mm_sound_proxy_play_sound_with_stream_info(param->filename, param->loop, param->volume,
- getpid(), handle, stream_type, stream_id);
- if (ret != MM_ERROR_NONE) {
- debug_error("Play Sound Failed");
- goto failed;
- }
- if (param->callback) {
- end_cb_data = (play_sound_end_callback_data_t *) g_malloc0(sizeof(play_sound_end_callback_data_t));
- end_cb_data->watching_handle = *handle;
- GET_CB_DATA(cb_data, param->callback, param->data, end_cb_data);
-
- ret = mm_sound_proxy_add_play_sound_end_callback(_mm_sound_stop_callback_wrapper_func, cb_data,
- play_end_callback_data_free_func, &end_cb_data->subs_id);
- if (ret != MM_ERROR_NONE) {
- debug_error("Add callback for play sound(%d) Failed", *handle);
- }
- }
-
-failed:
-
- debug_fleave();
- return ret;
-
-}
-
-int mm_sound_client_stop_sound(int handle)
-{
- int ret = MM_ERROR_NONE;
- debug_fenter();
-
- if (handle < 0 || handle > CLIENT_HANDLE_MAX) {
- ret = MM_ERROR_INVALID_ARGUMENT;
- return ret;
- }
-
- ret = mm_sound_proxy_stop_sound(handle);
-
- debug_fleave();
- return ret;
-}
-
-static int _mm_sound_client_device_list_dump (GList *device_list)