From: Eunhae Choi Date: Thu, 23 Nov 2017 08:58:17 +0000 (+0900) Subject: [0.2.67] add lock for prepare cb X-Git-Tag: submit/tizen_4.0/20171123.062529^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ec6abbfac693f11fcbe7c63f8d0d0099da7d3b4;p=platform%2Fcore%2Fmultimedia%2Fmmsvc-player.git [0.2.67] add lock for prepare cb Change-Id: Id8f63450224bd435e46706613b11da5d63fece87 --- diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index 5ca9893..d8c98ca 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -496,6 +496,8 @@ static void __message_cb_loop(void *data) case PLAYER_MESSAGE_PREPARED: { LOGW("PLAYER_MESSAGE_PREPARED"); + + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { handle->state = PLAYER_STATE_READY; ((player_prepared_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]); @@ -504,6 +506,7 @@ static void __message_cb_loop(void *data) } else { LOGE("null handle in PLAYER_MESSAGE_PREPARED"); } + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); } break; case PLAYER_MESSAGE_ERROR: @@ -576,6 +579,8 @@ static int __msg_callback(int message, void *param, void *user_data) switch (message) { case MM_MESSAGE_ERROR: /* 0x01 */ err_code = __player_convert_error_code(msg->code, (char *)__FUNCTION__); + + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); if (PLAYER_ERROR_NOT_SUPPORTED_FILE == err_code && handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { LOGW("failed to pause, so prepare cb will be released soon"); handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; @@ -584,16 +589,19 @@ static int __msg_callback(int message, void *param, void *user_data) handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; } } + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); break; case MM_MESSAGE_STATE_CHANGED: /* 0x03 */ LOGI("STATE CHANGED INTERNALLY - from : %d, to : %d (CAPI State : %d)", msg->state.previous, msg->state.current, handle->state); if ((handle->is_progressive_download && msg->state.previous == MM_PLAYER_STATE_NULL && msg->state.current == MM_PLAYER_STATE_READY) || (msg->state.previous == MM_PLAYER_STATE_READY && msg->state.current == MM_PLAYER_STATE_PAUSED)) { + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { /* asyc && prepared cb has been set */ LOGI("[%s] Prepared! [current state : %d]", __FUNCTION__, handle->state); PLAYER_TRACE_ASYNC_END("MM:PLAYER:PREPARE_ASYNC", *(int *)handle); __ADD_MESSAGE(handle, PLAYER_MESSAGE_PREPARED); } + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); } break; case MM_MESSAGE_READY_TO_RESUME: /* 0x05 */ @@ -1109,6 +1117,7 @@ int legacy_player_destroy(player_h player) __RELEASEIF_PREPARE_THREAD(handle->prepare_async_thread); __RELEASEIF_MESSAGE_THREAD(handle->message_thread); + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; if (handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { @@ -1116,6 +1125,7 @@ int legacy_player_destroy(player_h player) handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; } } + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); int ret = mm_player_destroy(handle->mm_handle); @@ -1192,15 +1202,19 @@ int legacy_player_prepare_async(player_h player, player_prepared_cb callback, vo PLAYER_TRACE_ASYNC_BEGIN("MM:PLAYER:PREPARE_ASYNC", *(int *)handle); PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); + handle->last_play_position = 0; if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION (0x%08x) : preparing... we can't do any more ", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); return PLAYER_ERROR_INVALID_OPERATION; } else { /* LOGI("[%s] Event type : %d ",__FUNCTION__, MUSE_PLAYER_EVENT_TYPE_PREPARE); */ handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = callback; handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = user_data; } + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void *)handle); if (ret != MM_ERROR_NONE) @@ -1234,11 +1248,13 @@ int legacy_player_prepare_async(player_h player, player_prepared_cb callback, vo if (ret != 0) { LOGE("[%s] failed to create thread ret = %d", __FUNCTION__, ret); + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; /* user_data will be free at player_disp_prepare_async() */ handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; } + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); return PLAYER_ERROR_OUT_OF_MEMORY; } } @@ -1248,11 +1264,13 @@ int legacy_player_prepare_async(player_h player, player_prepared_cb callback, vo ERROR: LOGW("prepare cb is released"); + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; /* user_data will be free at player_disp_prepare_async() */ handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; } + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); LOGE("LEAVE mm_err:0x%X", ret); return __player_convert_error_code(ret, (char *)__FUNCTION__); @@ -1338,6 +1356,7 @@ int legacy_player_unprepare(player_h player) return PLAYER_ERROR_INVALID_STATE; } + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { LOGW("Need to check. prepare cb have to be reset before"); handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; @@ -1346,6 +1365,7 @@ int legacy_player_unprepare(player_h player) handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; } } + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); __RELEASEIF_PREPARE_THREAD(handle->prepare_async_thread); diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index c75d4b5..cd5742b 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.66 +Version: 0.2.67 Release: 0 Group: Multimedia/Libraries License: Apache-2.0