}
}
+static void _player_internal_buffer_release(player_cli_s *pc)
+{
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle[%p]", pc);
+ return;
+ }
+
+ LOGI("ENTER");
+
+ if (!DP_INTERFACE(pc)) {
+ LOGW("display port interface is NULL");
+ goto RELEASE_INTERNAL_MOMORY;
+ }
+
+ if (mm_display_interface_get_type(DP_INTERFACE(pc), &display_type) != MM_ERROR_NONE) {
+ LOGE("get display type failed");
+ return;
+ }
+
+ if (display_type != MM_DISPLAY_TYPE_EVAS)
+ goto RELEASE_INTERNAL_MOMORY;
+
+ if (CALLBACK_INFO(pc)->dp_info.visible != PLAYER_VISIBLE_INFO_FALSE) {
+ if (mm_display_interface_evas_set_visible(DP_INTERFACE(pc), false) != MM_ERROR_NONE) {
+ LOGE("mm_display_interface_evas_set_visible failed");
+ return;
+ }
+ }
+
+ if (mm_display_interface_evas_flush(DP_INTERFACE(pc), false) != MM_ERROR_NONE) {
+ LOGE("mm_display_interface_evas_flush failed");
+ return;
+ }
+
+RELEASE_INTERNAL_MOMORY:
+ _player_release_internal_memory(pc, false);
+ pc->cb_info->video_frame_pool_size = 0;
+ __player_remove_tsurf_list(pc);
+
+ LOGI("LEAVE");
+}
+
static bool _user_callback_handler(callback_cb_info_s *cb_info, muse_player_event_e event, _player_recv_data *recv_data)
{
+ if (!cb_info->user_cb[event] || !_user_callbacks[event]) {
+ LOGE("failed to get callback for event %d", event);
+ return false;
+ }
+
+ _player_cb_data *data = NULL;
+ data = g_new(_player_cb_data, 1);
+ data->int_data = (int)event;
+ data->cb_info = cb_info;
+ data->recv_data = recv_data;
+ _player_event_queue_add(&cb_info->event_queue, data);
+
+ return true;
+}
+
+static bool _event_callback_handler(callback_cb_info_s *cb_info, muse_player_event_e event, _player_recv_data *recv_data)
+{
/* LOGD("get event %d", event); */
- if (event < MUSE_PLAYER_EVENT_TYPE_NUM) {
- if (cb_info->user_cb[event] && _user_callbacks[event]) {
- _player_cb_data *data = NULL;
- data = g_new(_player_cb_data, 1);
- if (!data) {
- LOGE("fail to alloc mem");
- return false;
- }
- data->int_data = (int)event;
- data->cb_info = cb_info;
- data->recv_data = recv_data;
- _player_event_queue_add(&cb_info->event_queue, data);
+ if (event >= MUSE_PLAYER_EVENT_TYPE_NUM) {
+ LOGE("invalid event %d", event);
+ return false;
+ }
+ if (event == MUSE_PLAYER_EVENT_TYPE_STATE_CHANGED ||
+ event == MUSE_PLAYER_EVENT_TYPE_INTERRUPT) {
+ _player_internal_buffer_release((player_cli_s *)cb_info->pc);
+ if (event == MUSE_PLAYER_EVENT_TYPE_STATE_CHANGED) {
+ g_free(recv_data->buffer);
+ g_free(recv_data);
return true;
}
}
- LOGE("failed to add event to queue %d", event);
- return false;
+ return _user_callback_handler(cb_info, event, recv_data);
}
static void _add_ret_msg(muse_player_api_e api, callback_cb_info_s *cb_info, int offset, int parse_len)
last = last->next;
last->next = msg;
}
- } else
+ } else {
LOGE("g_new failure");
+ }
}
static ret_msg_s *_get_ret_msg(muse_player_api_e api, callback_cb_info_s *cb_info)
}
g_mutex_unlock(&cb_info->player_mutex);
if (!muse_core_msg_object_get_value("event", jobj, MUSE_TYPE_INT, &event) ||
- !_user_callback_handler(cb_info, event, recv_data)) {
+ !_event_callback_handler(cb_info, event, recv_data)) {
LOGE("failed to get value or add event to the queue.");
if (recv_data) {
g_free(recv_data->buffer);
cb_info = g_new(callback_cb_info_s, 1);
if (!cb_info)
return NULL;
+
memset(cb_info, 0, sizeof(callback_cb_info_s));
g_mutex_init(&cb_info->player_mutex);
goto ERROR;
}
+ pc->cb_info->pc = pc;
+
ret = client_wait_for_server_ack(api, pc->cb_info, CREATE_CB_TIME_OUT);
if (ret == PLAYER_ERROR_INVALID_OPERATION)
goto ERROR_RETRY;
int player_unprepare(player_h player)
{
int ret = PLAYER_ERROR_NONE;
- int mm_ret = MM_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_UNPREPARE;
player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
player_state_e state = PLAYER_STATE_NONE;
- mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
PLAYER_INSTANCE_CHECK(player);
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);
- if (!DP_INTERFACE(pc))
- goto _PLAYER_UNPREPARE;
-
-
- PLAYER_GET_DISPLAY_TYPE(pc, display_type);
-
- if (display_type != MM_DISPLAY_TYPE_EVAS)
- goto _PLAYER_UNPREPARE;
-
- if (CALLBACK_INFO(pc)->dp_info.visible != PLAYER_VISIBLE_INFO_FALSE) {
- mm_ret = mm_display_interface_evas_set_visible(DP_INTERFACE(pc), false);
- if (mm_ret != MM_ERROR_NONE) {
- LOGE("mm_display_interface_evas_set_visible failed 0x%x", mm_ret);
- return PLAYER_ERROR_INVALID_OPERATION;
- }
- }
-
- mm_ret = mm_display_interface_evas_flush(DP_INTERFACE(pc), false);
- if (mm_ret != MM_ERROR_NONE) {
- LOGE("mm_display_interface_evas_flush failed 0x%x", mm_ret);
- return PLAYER_ERROR_INVALID_OPERATION;
- }
-
-_PLAYER_UNPREPARE:
PLAYER_SEND_MSG(api, pc, ret_buf, ret);
-
- _player_release_internal_memory(pc, false);
- pc->cb_info->video_frame_pool_size = 0;
- __player_remove_tsurf_list(pc);
-
g_free(ret_buf);
EXIT: