From: Eunhae Choi Date: Fri, 19 Oct 2018 09:36:23 +0000 (+0900) Subject: [0.3.104] return pending api before destroy the resources X-Git-Tag: submit/tizen/20181109.060212^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ac97b60f825aa53f19f9e7765df809e012b9944a;p=platform%2Fcore%2Fapi%2Fplayer.git [0.3.104] return pending api before destroy the resources - csharp app can call the destroy during prepare because it works different thread. - player have to send cond signal of each api to make sure return the pending api before destroy the cb info resource. Change-Id: Ide173b6f1d3f0c896ad4b6f3cbd01346af90a77e --- diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index 8e4c4c3..2bd8835 100644 --- a/packaging/capi-media-player.spec +++ b/packaging/capi-media-player.spec @@ -1,6 +1,6 @@ Name: capi-media-player Summary: A Media Player API -Version: 0.3.103 +Version: 0.3.104 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/player.c b/src/player.c index 2956c5b..f38da0e 100644 --- a/src/player.c +++ b/src/player.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1713,6 +1714,8 @@ static void *client_cb_handler(gpointer data) } if (g_atomic_int_get(&cb_info->running)) _notify_disconnected(cb_info); + + g_atomic_int_set(&cb_info->running, 0); LOGD("client cb exit"); return NULL; @@ -1771,9 +1774,19 @@ static void callback_destroy(callback_cb_info_s * cb_info) LOGI("%p Callback destroyed", cb_info); - g_mutex_clear(&cb_info->player_mutex); - for (i = 0; i < MUSE_PLAYER_API_MAX; i++) + for (i = 0; i < MUSE_PLAYER_API_MAX; i++) { + g_mutex_lock(&cb_info->player_mutex); + g_cond_signal(&cb_info->player_cond[i]); + g_mutex_unlock(&cb_info->player_mutex); g_cond_clear(&cb_info->player_cond[i]); + } + + /* to make sure the return of other pending api */ + sched_yield(); + g_mutex_lock(&cb_info->player_mutex); + g_mutex_unlock(&cb_info->player_mutex); + g_mutex_clear(&cb_info->player_mutex); + g_cond_clear(&cb_info->server_ack_cond); g_mutex_clear(&cb_info->data_mutex); @@ -1827,6 +1840,7 @@ int client_wait_for_cb_return(muse_player_api_e api, callback_cb_info_s * cb_inf break; } } + if (!msg) msg = _get_ret_msg(api, cb_info); if (msg) { @@ -1837,11 +1851,17 @@ int client_wait_for_cb_return(muse_player_api_e api, callback_cb_info_s * cb_inf ret = PLAYER_ERROR_INVALID_OPERATION; else if (ret != PLAYER_ERROR_NONE) LOGE("Get error return from server 0x%X", ret); + break; + } + if (!g_atomic_int_get(&cb_info->running)) { + LOGE("callback thread is stopped. %d api did not get return in time", api); + ret = PLAYER_ERROR_INVALID_OPERATION; + break; } else { - LOGE("api %d is the spurious wakeup", api); + LOGW("api %d is the spurious wakeup, wait again", api); } - } while (!msg); + } while (!msg && g_atomic_int_get(&cb_info->running)); g_mutex_unlock(&cb_info->player_mutex); return ret;