Fix aarch64 casting build warnings
[platform/core/multimedia/libmm-sound.git] / mm_sound_client.c
index a3b4cff..9b60ee6 100644 (file)
@@ -195,101 +195,6 @@ void mm_sound_convert_volume_type_to_stream_type(int volume_type, char *stream_t
 /*****************************************************************************************
                            DBUS SUPPORTED FUNCTIONS
 ******************************************************************************************/
-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("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_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");
-               return ret;
-       }
-       if (param->callback) {
-               end_cb_data = (play_sound_end_callback_data_t *) g_try_malloc0(sizeof(play_sound_end_callback_data_t));
-               if (!end_cb_data) {
-                       debug_error("Failed to alloc end_cb_data");
-                       return MM_ERROR_OUT_OF_MEMORY;
-               }
-               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);
-       }
-
-       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)
 {
        int ret = MM_ERROR_NONE;
@@ -469,7 +374,7 @@ static void _mm_sound_device_connected_callback_wrapper_func(int device_id, cons
                return;
        }
 
-       device_flags = (int) cb_data->extra_data;
+       device_flags = (int)(uintptr_t)cb_data->extra_data;
        if (!device_is_match_with_mask(device_type, io_direction, state, device_flags))
                return;
 
@@ -490,7 +395,7 @@ int mm_sound_client_add_device_connected_callback(int device_flags, mm_sound_dev
 
        debug_fenter();
 
-       GET_CB_DATA(cb_data, func, userdata, (void*) device_flags);
+       GET_CB_DATA(cb_data, func, userdata, (void*)(uintptr_t)device_flags);
 
        ret = mm_sound_proxy_add_device_connected_callback(_mm_sound_device_connected_callback_wrapper_func,
                                                                                                        cb_data, g_free, subs_id);
@@ -527,7 +432,7 @@ static void _mm_sound_device_info_changed_callback_wrapper_func(int device_id, c
                return;
        }
 
-       device_flags = (int) cb_data->extra_data;
+       device_flags = (int)(uintptr_t)cb_data->extra_data;
        if (!device_is_match_with_mask(device_type, io_direction, state, device_flags))
                return;
 
@@ -548,7 +453,7 @@ int mm_sound_client_add_device_info_changed_callback(int device_flags, mm_sound_
 
        debug_fenter();
 
-       GET_CB_DATA(cb_data, func, userdata, (void *) device_flags);
+       GET_CB_DATA(cb_data, func, userdata, (void *)(uintptr_t)device_flags);
 
        ret = mm_sound_proxy_add_device_info_changed_callback(_mm_sound_device_info_changed_callback_wrapper_func,
                                                                                                                cb_data, g_free, subs_id);
@@ -585,7 +490,7 @@ static void _mm_sound_device_state_changed_callback_wrapper_func(int device_id,
                return;
        }
 
-       device_flags = (int) cb_data->extra_data;
+       device_flags = (int)(uintptr_t)cb_data->extra_data;
 
        if (!device_is_match_with_mask(device_type, io_direction, state, device_flags))
                return;
@@ -607,7 +512,7 @@ int mm_sound_client_add_device_state_changed_callback(int device_flags, mm_sound
 
        debug_fenter();
 
-       GET_CB_DATA(cb_data, func, userdata, (void *) device_flags);
+       GET_CB_DATA(cb_data, func, userdata, (void *)(uintptr_t)device_flags);
 
        ret = mm_sound_proxy_add_device_state_changed_callback(_mm_sound_device_state_changed_callback_wrapper_func,
                                                                                                                cb_data, g_free, id);
@@ -643,7 +548,7 @@ static void _mm_sound_device_running_changed_callback_wrapper_func(int device_id
                return;
        }
 
-       device_flags = (int) cb_data->extra_data;
+       device_flags = (int)(uintptr_t)cb_data->extra_data;
 
        if (!device_is_match_with_mask(device_type, io_direction, state, device_flags))
                return;
@@ -665,7 +570,7 @@ int mm_sound_client_add_device_running_changed_callback(int device_flags, mm_sou
 
        debug_fenter();
 
-       GET_CB_DATA(cb_data, func, userdata, (void *) device_flags);
+       GET_CB_DATA(cb_data, func, userdata, (void *)(uintptr_t)device_flags);
 
        ret = mm_sound_proxy_add_device_running_changed_callback(_mm_sound_device_running_changed_callback_wrapper_func,
                                                                                                                        cb_data, g_free, id);
@@ -952,7 +857,7 @@ int mm_sound_client_add_volume_changed_callback_internal(mm_sound_volume_changed
 
        debug_fenter();
 
-       GET_CB_DATA(cb_data, func, userdata, (void*)is_for_internal);
+       GET_CB_DATA(cb_data, func, userdata, (void*)(uintptr_t)is_for_internal);
 
        ret = mm_sound_proxy_add_volume_changed_callback(_mm_sound_volume_changed_callback_wrapper_func, cb_data, g_free, subs_id);
 
@@ -1114,6 +1019,7 @@ int mm_sound_client_register_focus(int pid, const char *stream_type,
                goto cleanup;
        }
 
+       g_mutex_init(&g_focus_sound_handle[index].focus_lock);
        focus_init_callback(index, false);
 
 cleanup:
@@ -1141,12 +1047,9 @@ int mm_sound_client_unregister_focus(int id)
                goto cleanup;
        }
 
-       if (!g_mutex_trylock(&g_focus_sound_handle[index].focus_lock)) {
-               debug_warning("maybe focus_callback is being called, try one more time..");
-               usleep(2500000); /* 2.5 sec */
-               if (g_mutex_trylock(&g_focus_sound_handle[index].focus_lock))
-                       debug_msg("finally got focus_lock");
-       }
+       g_mutex_lock(&g_focus_sound_handle[index].focus_lock);
+
+       g_focus_sound_handle[index].is_destroying = true;
 
        ret = mm_sound_proxy_unregister_focus(index);
        if (ret == MM_ERROR_NONE)
@@ -1154,8 +1057,6 @@ int mm_sound_client_unregister_focus(int id)
        else
                debug_error("Error occurred : 0x%x", ret);
 
-       g_mutex_unlock(&g_focus_sound_handle[index].focus_lock);
-
        focus_deinit_callback(index, false);
        g_focus_sound_handle[index].focus_fd = 0;
        g_focus_sound_handle[index].focus_pid = 0;
@@ -1164,6 +1065,10 @@ int mm_sound_client_unregister_focus(int id)
        g_focus_sound_handle[index].is_used = false;
        focus_deinit_context(index, false);
 
+       g_mutex_unlock(&g_focus_sound_handle[index].focus_lock);
+       g_mutex_clear(&g_focus_sound_handle[index].focus_lock);
+
+       g_focus_sound_handle[index].is_destroying = false;
 cleanup:
        MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
        debug_fleave();
@@ -1560,39 +1465,3 @@ int mm_sound_client_remove_ducking_state_changed_callback(unsigned int subs_id)
        return ret;
 }
 
-int mm_sound_client_add_test_callback(mm_sound_test_cb func, void* user_data, unsigned int *subs_id)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       ret = mm_sound_proxy_add_test_callback(func, user_data, g_free, subs_id);
-
-       debug_fleave();
-       return ret;
-}
-
-int mm_sound_client_remove_test_callback(unsigned int subs_id)
-{
-       int ret = MM_ERROR_NONE;
-       debug_fenter();
-
-       ret = mm_sound_proxy_remove_test_callback(subs_id);
-
-       debug_fleave();
-       return ret;
-}
-
-int mm_sound_client_test(int a, int b, int* getv)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       ret = mm_sound_proxy_test(a, b, getv);
-       debug_log("%d * %d -> result : %d", a, b, *getv);
-
-       debug_fleave();
-
-       return ret;
-}