return ret;
}
+static void __player_update_state(player_s *handle, player_internal_state_e state)
+{
+ switch (state) {
+ case PLAYER_INTERNAL_STATE_NONE:
+ handle->state = PLAYER_STATE_NONE;
+ handle->internal_state = PLAYER_INTERNAL_STATE_IDLE;
+ break;
+ case PLAYER_INTERNAL_STATE_IDLE:
+ handle->state = PLAYER_STATE_IDLE;
+ handle->internal_state = PLAYER_INTERNAL_STATE_IDLE;
+ break;
+ case PLAYER_INTERNAL_STATE_PRE_READY:
+ handle->internal_state = PLAYER_INTERNAL_STATE_PRE_READY;
+ break;
+ case PLAYER_INTERNAL_STATE_READY:
+ handle->state = PLAYER_STATE_READY;
+ handle->internal_state = PLAYER_INTERNAL_STATE_READY;
+ break;
+ case PLAYER_INTERNAL_STATE_PLAYING:
+ handle->internal_state = PLAYER_INTERNAL_STATE_PLAYING;
+ handle->state = PLAYER_STATE_PLAYING;
+ break;
+ case PLAYER_INTERNAL_STATE_PAUSED:
+ handle->internal_state = PLAYER_INTERNAL_STATE_PAUSED;
+ handle->state = PLAYER_STATE_PAUSED;
+ break;
+ case PLAYER_INTERNAL_STATE_STOPPED:
+ handle->state = PLAYER_STATE_READY;
+ handle->internal_state = PLAYER_INTERNAL_STATE_STOPPED;
+ break;
+ default:
+ break;
+ }
+
+ LOGD("player state is updated to 0x%X, 0x%X", handle->state, handle->internal_state);
+ return;
+}
+
bool __player_state_validate(player_s *handle, player_state_e threshold)
{
if (handle->state < threshold)
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_update_state(handle, PLAYER_INTERNAL_STATE_READY);
((player_prepared_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]);
handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
int ret = mm_player_create(&handle->mm_handle);
if (ret != MM_ERROR_NONE) {
LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION);
- handle->state = PLAYER_STATE_NONE;
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_NONE);
free(handle);
handle = NULL;
return __player_convert_error_code(ret, (char *)__FUNCTION__);
muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE;
*player = (player_h)handle;
- handle->state = PLAYER_STATE_IDLE;
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
- handle->is_stopped = FALSE;
handle->is_display_visible = TRUE;
handle->is_media_stream = FALSE;
__ADD_MESSAGE(handle, PLAYER_MESSAGE_LOOP_EXIT);
- __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;
}
LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
+ /* stop the pause state trasition to release prepare thread */
+ if (handle->internal_state == PLAYER_INTERNAL_STATE_PRE_READY)
+ mm_player_abort_pause(handle->mm_handle);
+
+ __RELEASEIF_PREPARE_THREAD(handle->prepare_async_thread);
+ __RELEASEIF_MESSAGE_THREAD(handle->message_thread);
+
int ret = mm_player_destroy(handle->mm_handle);
LOGI("[%s] Done mm_player_destroy", __FUNCTION__);
} else {
muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE;
- handle->state = PLAYER_STATE_NONE;
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_NONE);
for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) {
if (_check_enabled_user_cb_lock(type))
ret = mm_player_unrealize(handle->mm_handle);
if (ret != MM_ERROR_NONE)
LOGE("[%s] Failed to unrealize - 0x%x", __FUNCTION__, ret);
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
}
LOGI("[%s], done", __FUNCTION__);
return NULL;
PLAYER_TRACE_ASYNC_BEGIN("MM:PLAYER:PREPARE_ASYNC", *(int *)handle);
PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_PRE_READY);
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);
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
return PLAYER_ERROR_INVALID_OPERATION;
} else {
/* LOGI("[%s] Event type : %d ",__FUNCTION__, MUSE_PLAYER_EVENT_TYPE_PREPARE); */
handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
}
LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
return PLAYER_ERROR_OUT_OF_MEMORY;
}
}
handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
}
LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
LOGE("LEAVE mm_err:0x%X", ret);
return __player_convert_error_code(ret, (char *)__FUNCTION__);
PLAYER_INSTANCE_CHECK(player);
player_s *handle = (player_s *)player;
PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_PRE_READY);
handle->last_play_position = 0;
ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void *)handle);
LOGW("[%s] Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)", __FUNCTION__, ret);
} else {
ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_visible", &visible, (char *)NULL);
- if (ret != MM_ERROR_NONE)
+ if (ret != MM_ERROR_NONE) {
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ }
if (!visible)
value = FALSE;
ret = mm_player_realize(handle->mm_handle);
if (ret != MM_ERROR_NONE) {
LOGE("[%s] Failed to realize - 0x%x", __FUNCTION__, ret);
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
return __player_convert_error_code(ret, (char *)__FUNCTION__);
}
LOGE("[%s] Failed to unrealize - 0x%x", __FUNCTION__, uret);
LOGE("[%s] Failed to pause - 0x%x", __FUNCTION__, ret);
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
return __player_convert_error_code(ret, (char *)__FUNCTION__);
} else {
- handle->state = PLAYER_STATE_READY;
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_READY);
LOGI("[%s] End", __FUNCTION__);
PLAYER_TRACE_END();
return PLAYER_ERROR_NONE;
handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
}
- if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
+ if (!__player_state_validate(handle, PLAYER_STATE_READY) && !handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state);
return PLAYER_ERROR_INVALID_STATE;
}
}
LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
+ /* stop the pause state trasition to release prepare thread */
+ if (handle->internal_state == PLAYER_INTERNAL_STATE_PRE_READY)
+ mm_player_abort_pause(handle->mm_handle);
+
__RELEASEIF_PREPARE_THREAD(handle->prepare_async_thread);
int ret = mm_player_unrealize(handle->mm_handle);
if (ret != MM_ERROR_NONE) {
return __player_convert_error_code(ret, (char *)__FUNCTION__);
} else {
- handle->state = PLAYER_STATE_IDLE;
- handle->is_stopped = FALSE;
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
handle->is_display_visible = TRUE;
handle->is_progressive_download = FALSE;
LOGI("[%s] End", __FUNCTION__);
if (ret != MM_ERROR_NONE)
LOGW("[%s] Failed to set display_visible '1' (0x%x)", __FUNCTION__, ret);
}
- if (handle->is_stopped) {
+ if (handle->internal_state == PLAYER_INTERNAL_STATE_STOPPED) {
if (handle->is_progressive_download) {
LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION);
return PLAYER_ERROR_INVALID_OPERATION;
if (ret != MM_ERROR_NONE) {
return __player_convert_error_code(ret, (char *)__FUNCTION__);
} else {
- handle->is_stopped = FALSE;
- handle->state = PLAYER_STATE_PLAYING;
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_PLAYING);
LOGI("[%s] End", __FUNCTION__);
return PLAYER_ERROR_NONE;
}
handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
}
- handle->state = PLAYER_STATE_READY;
- handle->is_stopped = TRUE;
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_STOPPED);
+
LOGI("[%s] End", __FUNCTION__);
return PLAYER_ERROR_NONE;
}
if (ret != MM_ERROR_NONE) {
return __player_convert_error_code(ret, (char *)__FUNCTION__);
} else {
- handle->state = PLAYER_STATE_PAUSED;
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_PAUSED);
LOGI("[%s] End", __FUNCTION__);
return PLAYER_ERROR_NONE;
}
return PLAYER_ERROR_NONE;
}
-int legacy_player_unset_media_packet_video_frame_decoded_cb(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- player_s *handle = (player_s *)player;
-
- LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
-
- int ret = mm_player_set_video_stream_callback(handle->mm_handle, NULL, NULL);
- if (ret != MM_ERROR_NONE)
- return __player_convert_error_code(ret, (char *)__FUNCTION__);
- else
- return PLAYER_ERROR_NONE;
-}
-
static bool __video_stream_changed_callback(void *user_data)
{
player_s *handle = (player_s *)user_data;
int legacy_player_unset_video_stream_changed_cb(player_h player)
{
- int ret;
PLAYER_INSTANCE_CHECK(player);
- player_s *handle = (player_s *)player;
__unset_callback(MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player);
- ret = mm_player_set_video_stream_changed_callback(handle->mm_handle, NULL, NULL);
- if (ret != MM_ERROR_NONE)
- return __player_convert_error_code(ret, (char *)__FUNCTION__);
- else
- return PLAYER_ERROR_NONE;
+ return PLAYER_ERROR_NONE;
}
static bool __media_stream_buffer_status_callback(player_stream_type_e type, player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
int legacy_player_unset_media_stream_buffer_status_cb(player_h player, player_stream_type_e type)
{
- int ret;
PLAYER_INSTANCE_CHECK(player);
- player_s *handle = (player_s *)player;
if (type == PLAYER_STREAM_TYPE_VIDEO)
__unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, player);
else
return PLAYER_ERROR_INVALID_PARAMETER;
- ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, NULL, NULL);
- if (ret != MM_ERROR_NONE)
- return __player_convert_error_code(ret, (char *)__FUNCTION__);
- else
- return PLAYER_ERROR_NONE;
+ return PLAYER_ERROR_NONE;
}
int legacy_player_set_media_stream_seek_cb(player_h player, player_stream_type_e type, player_media_stream_seek_cb callback, void *user_data)
int legacy_player_unset_media_stream_seek_cb(player_h player, player_stream_type_e type)
{
- int ret;
PLAYER_INSTANCE_CHECK(player);
- player_s *handle = (player_s *)player;
if (type == PLAYER_STREAM_TYPE_VIDEO)
__unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, player);
else
return PLAYER_ERROR_INVALID_PARAMETER;
- ret = mm_player_set_media_stream_seek_data_callback(handle->mm_handle, type, NULL, NULL);
- if (ret != MM_ERROR_NONE)
- return __player_convert_error_code(ret, (char *)__FUNCTION__);
- else
- return PLAYER_ERROR_NONE;
+ return PLAYER_ERROR_NONE;
}
int legacy_player_push_media_stream(player_h player, media_packet_h packet)