From 1e7887042199154751bcf61c18cf45e26f0ae165 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Thu, 16 Aug 2018 20:05:14 +0900 Subject: [PATCH] [ACR-1290] Change pre-condition of unprepare function. - change the pre-condition to cancel the prepare operation Change-Id: I48785eba073eb3014a08df9f27547db49bb59cda --- include/player.h | 9 ++++++--- src/player.c | 23 ++++++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/include/player.h b/include/player.h index 11a5b00..bdba3e2 100644 --- a/include/player.h +++ b/include/player.h @@ -529,8 +529,9 @@ int player_prepare(player_h player); * @brief Prepares the media player for playback, asynchronously. * @since_tizen @if WEARABLE 2.3.1 @else 2.3 @endif * @remarks The mediastorage privilege(http://tizen.org/privilege/mediastorage) must be added if any video/audio files are used to play located in the internal storage. - * @remarks The externalstorage privilege(http://tizen.org/privilege/externalstorage) must be added if any video/audio files are used to play located in the external storage. - * @remarks The internet privilege(http://tizen.org/privilege/internet) must be added if any URLs are used to play from network. + * The externalstorage privilege(http://tizen.org/privilege/externalstorage) must be added if any video/audio files are used to play located in the external storage. + * The internet privilege(http://tizen.org/privilege/internet) must be added if any URLs are used to play from network. \n + * Since 5.0: To cancel the asynchronous preparing, call player_unprepare() even in #PLAYER_STATE_IDLE state. * @param[in] player The handle to the media player * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function @@ -566,7 +567,9 @@ int player_prepare_async(player_h player, player_prepared_cb callback, void* use * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state - * @pre The player state must be higher than #PLAYER_STATE_IDLE. + * @pre Before 5.0: The player state must be one of: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, #PLAYER_STATE_PAUSED. \n + * @pre Since 5.0: The player state must be one of: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, #PLAYER_STATE_PAUSED. + * #PLAYER_STATE_IDLE is allowed only if player preparation was started with player_prepare_async(). * @post The player state will be #PLAYER_STATE_IDLE. * @see player_prepare() */ diff --git a/src/player.c b/src/player.c index de8a98f..94494a3 100644 --- a/src/player.c +++ b/src/player.c @@ -2112,11 +2112,26 @@ int player_unprepare(player_h player) player_cli_s *pc = (player_cli_s *) player; char *ret_buf = NULL; int (*p_disp_evas_display_retrieve_all_packets)(void *, bool) = NULL; + player_state_e state = PLAYER_STATE_NONE; LOGD("ENTER"); - if (!CALLBACK_INFO(pc)) - return PLAYER_ERROR_INVALID_STATE; + if (_get_current_state(pc, &state) != PLAYER_ERROR_NONE) { + LOGE("Failed to get state"); + ret = PLAYER_ERROR_INVALID_OPERATION; + goto EXIT; + } + + if (state < PLAYER_STATE_READY) { + if ((!CALLBACK_INFO(pc)) || (!CALLBACK_INFO(pc)->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE])) { + LOGE("Invalid state %d", state); + ret = PLAYER_ERROR_INVALID_STATE; + goto EXIT; + } + } + + set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK); + set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_PREPARE); #ifdef TIZEN_FEATURE_EVAS_RENDERER if (EVAS_INFO(pc)->support_video && EVAS_HANDLE(pc)) { @@ -2129,16 +2144,14 @@ int player_unprepare(player_h player) PLAYER_SEND_MSG(api, pc, ret_buf, ret); - set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK); - set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_PREPARE); _player_release_internal_memory(pc, false); - pc->cb_info->video_frame_pool_size = 0; __player_remove_tsurf_list(pc); pc->is_audio_only = FALSE; g_free(ret_buf); +EXIT: LOGD("LEAVE 0x%X", ret); return ret; } -- 2.7.4