From: Hyunil Date: Wed, 29 Jan 2020 10:11:46 +0000 (+0900) Subject: Add checking symbol pointer from dlsym X-Git-Tag: accepted/tizen/unified/20200212.125857^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=68baa96bffd62e1cc1a9666e907139205ae48be0;p=platform%2Fcore%2Fapi%2Fplayer.git Add checking symbol pointer from dlsym Change-Id: Ic22de47fc33de42010f922f882a618c6fdba79db Signed-off-by: Hyunil --- diff --git a/include/player_private.h b/include/player_private.h index 11e1d15..e6da9f9 100644 --- a/include/player_private.h +++ b/include/player_private.h @@ -254,11 +254,10 @@ do { \ #define PLAYER_DISP_DLSYM(handle, sym, function_name) \ do { \ - char *error; \ sym = dlsym(handle, function_name); \ - if ((error = dlerror()) != NULL) { \ + if (!sym) { \ + LOGE("dlsym error %s", dlerror()); \ dlclose(handle); \ - LOGE("dlsym error %s", error); \ } \ } while (0) diff --git a/src/player.c b/src/player.c index 5541f2a..ffe6769 100644 --- a/src/player.c +++ b/src/player.c @@ -733,12 +733,13 @@ static void __seek_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *re dl_handle = dlopen(PATH_DISP_LIB, RTLD_LAZY); if (dl_handle) { PLAYER_DISP_DLSYM(dl_handle, p_disp_set_evas_display_visible, "disp_set_evas_display_visible"); - int ret = p_disp_set_evas_display_visible(cb_info->evas_info->handle, true); - dlclose(dl_handle); - if (ret != MM_ERROR_NONE) - LOGW("failed to set visible at evas 0x%x", ret); - else - cb_info->evas_info->visible = EVAS_VISIBLE_TRUE; + if (p_disp_set_evas_display_visible) { + if (p_disp_set_evas_display_visible(cb_info->evas_info->handle, true) != MM_ERROR_NONE) + LOGW("failed to set visible"); + else + cb_info->evas_info->visible = EVAS_VISIBLE_TRUE; + dlclose(dl_handle); + } } else { LOGW("not support video rendering"); } @@ -1616,7 +1617,7 @@ static bool _user_callback_handler(callback_cb_info_s *cb_info, muse_player_even /* LOGD("get event %d", event); */ if (event < MUSE_PLAYER_EVENT_TYPE_NUM) { - if (cb_info->user_cb[event] && _user_callbacks[event]){ + if (cb_info->user_cb[event] && _user_callbacks[event]) { _player_cb_data *data = NULL; data = g_new(_player_cb_data, 1); if (!data) { @@ -2145,8 +2146,11 @@ int player_destroy(player_h player) if (EVAS_INFO(pc)->support_video && EVAS_HANDLE(pc)) { player_unset_media_packet_video_frame_decoded_cb(player); PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_destroy_evas_display, "disp_destroy_evas_display"); - if (p_disp_destroy_evas_display(&EVAS_HANDLE(pc)) != MM_ERROR_NONE) + if (!p_disp_destroy_evas_display || + p_disp_destroy_evas_display(&EVAS_HANDLE(pc)) != MM_ERROR_NONE) { LOGW("fail to unset evas client"); + return PLAYER_ERROR_INVALID_OPERATION; + } __player_unset_retrieve_buffer_cb(player); } g_free(EVAS_INFO(pc)); @@ -2270,9 +2274,11 @@ int player_unprepare(player_h player) #ifdef TIZEN_FEATURE_EVAS_RENDERER if (EVAS_INFO(pc)->support_video && EVAS_HANDLE(pc)) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_evas_display_retrieve_all_packets, "disp_evas_display_retrieve_all_packets"); - ret = p_disp_evas_display_retrieve_all_packets(EVAS_HANDLE(pc), false); - if (ret != PLAYER_ERROR_NONE) - LOGI("mm_evas_renderer_retrieve_all_packets returned error"); + if (!p_disp_evas_display_retrieve_all_packets || + p_disp_evas_display_retrieve_all_packets(EVAS_HANDLE(pc), false) != PLAYER_ERROR_NONE) { + LOGE("mm_evas_renderer_retrieve_all_packets returned error"); + return PLAYER_ERROR_INVALID_OPERATION; + } } #endif @@ -2634,9 +2640,9 @@ int player_start(player_h player) if (EVAS_HANDLE(pc) && (EVAS_INFO(pc)->visible == EVAS_VISIBLE_NONE || EVAS_INFO(pc)->visible == EVAS_VISIBLE_TRUE)) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_visible, "disp_set_evas_display_visible"); - ret = p_disp_set_evas_display_visible(EVAS_HANDLE(pc), true); - if (ret != MM_ERROR_NONE) { - LOGE("mm_evas_renderer_set_visible err 0x%x", ret); + if (!p_disp_set_evas_display_visible || + p_disp_set_evas_display_visible(EVAS_HANDLE(pc), true) != MM_ERROR_NONE) { + LOGE("mm_evas_renderer_set_visible err"); return PLAYER_ERROR_INVALID_OPERATION; } /* avoid setting true at all times, when player is resumed */ @@ -2684,9 +2690,9 @@ int player_stop(player_h player) EVAS_INFO(pc)->support_video && (EVAS_INFO(pc)->visible == EVAS_VISIBLE_NONE || EVAS_INFO(pc)->visible == EVAS_VISIBLE_TRUE)) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_visible, "disp_set_evas_display_visible"); - ret = p_disp_set_evas_display_visible(EVAS_HANDLE(pc), false); - if (ret != MM_ERROR_NONE) { - LOGE("mm_evas_renderer_set_visible err 0x%x", ret); + if (!p_disp_set_evas_display_visible || + p_disp_set_evas_display_visible(EVAS_HANDLE(pc), false) != MM_ERROR_NONE) { + LOGE("mm_evas_renderer_set_visible err"); return PLAYER_ERROR_INVALID_OPERATION; } /* do not update EVAS_INFO(pc)->visible to set visible true if start again */ @@ -3097,8 +3103,11 @@ int player_set_display(player_h player, player_display_type_e type, player_displ LOGW("evas client already exists"); player_unset_media_packet_video_frame_decoded_cb(player); PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_destroy_evas_display, "disp_destroy_evas_display"); - if (p_disp_destroy_evas_display(&EVAS_HANDLE(pc)) != MM_ERROR_NONE) + if (!p_disp_destroy_evas_display || + p_disp_destroy_evas_display(&EVAS_HANDLE(pc)) != MM_ERROR_NONE) { LOGW("fail to unset evas client"); + return PLAYER_ERROR_INVALID_OPERATION; + } __player_unset_retrieve_buffer_cb(player); /* need to set display information again to new handle */ EVAS_INFO(pc)->update_needed = TRUE; @@ -3107,11 +3116,14 @@ int player_set_display(player_h player, player_display_type_e type, player_displ /* set evas_render or wayland */ if (conv_type == PLAYER_PRIVATE_DISPLAY_TYPE_OVERLAY) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_wl_display, "disp_set_wl_display"); + if (!p_disp_set_wl_display) + return PLAYER_ERROR_INVALID_OPERATION; wl_surface_id = p_disp_set_wl_display(ELM_WAYLAND_WIN, display); if (wl_surface_id > 0) { wl_win.surface_id = wl_surface_id; wl_win.type = conv_type; - } else return PLAYER_ERROR_INVALID_OPERATION; + } else + return PLAYER_ERROR_INVALID_OPERATION; } #ifdef TIZEN_FEATURE_EVAS_RENDERER else if (conv_type == PLAYER_PRIVATE_DISPLAY_TYPE_EVAS) { @@ -3121,26 +3133,31 @@ int player_set_display(player_h player, player_display_type_e type, player_displ } PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_create_evas_display, "disp_create_evas_display"); - ret = p_disp_create_evas_display(display, &EVAS_HANDLE(pc)); - if (ret != MM_ERROR_NONE) return PLAYER_ERROR_INVALID_OPERATION; + if (!p_disp_create_evas_display || + p_disp_create_evas_display(display, &EVAS_HANDLE(pc)) != MM_ERROR_NONE) + return PLAYER_ERROR_INVALID_OPERATION; /* before evas handle is created, user could set display information */ if (EVAS_INFO(pc)->update_needed) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_old_info, "disp_set_evas_display_old_info"); - ret = p_disp_set_evas_display_old_info(display, EVAS_HANDLE(pc), EVAS_INFO(pc)->mode, EVAS_INFO(pc)->rotation, EVAS_INFO(pc)->visible); - if (ret != MM_ERROR_NONE) return PLAYER_ERROR_INVALID_OPERATION; + if (!p_disp_set_evas_display_old_info || + p_disp_set_evas_display_old_info(display, EVAS_HANDLE(pc), EVAS_INFO(pc)->mode, EVAS_INFO(pc)->rotation, EVAS_INFO(pc)->visible) != MM_ERROR_NONE) + return PLAYER_ERROR_INVALID_OPERATION; if (EVAS_INFO(pc)->mode == PLAYER_DISPLAY_MODE_DST_ROI) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_roi_area, "disp_set_evas_display_roi_area"); - ret = p_disp_set_evas_display_roi_area(EVAS_HANDLE(pc), EVAS_INFO(pc)->roi_x, EVAS_INFO(pc)->roi_y, EVAS_INFO(pc)->roi_w, EVAS_INFO(pc)->roi_h); - if (ret != MM_ERROR_NONE) return PLAYER_ERROR_INVALID_OPERATION; + if (!p_disp_set_evas_display_roi_area || + p_disp_set_evas_display_roi_area(EVAS_HANDLE(pc), EVAS_INFO(pc)->roi_x, EVAS_INFO(pc)->roi_y, EVAS_INFO(pc)->roi_w, EVAS_INFO(pc)->roi_h) != MM_ERROR_NONE) + return PLAYER_ERROR_INVALID_OPERATION; } EVAS_INFO(pc)->update_needed = FALSE; } PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_media_packet_video_decode_cb, "disp_media_packet_video_decode_cb"); - ret = player_set_media_packet_video_frame_decoded_cb(player, p_disp_media_packet_video_decode_cb, (void *)EVAS_HANDLE(pc)); - if (ret != PLAYER_ERROR_NONE) - LOGW("fail to set decoded callback"); + if (!p_disp_media_packet_video_decode_cb || + player_set_media_packet_video_frame_decoded_cb(player, p_disp_media_packet_video_decode_cb, (void *)EVAS_HANDLE(pc)) != MM_ERROR_NONE) { + LOGE("fail to set decoded callback"); + return PLAYER_ERROR_INVALID_OPERATION; + } if (__player_set_retrieve_buffer_cb(player, __retrieve_buffer_cb, pc)) LOGW("fail to set __retrieve_buffer_cb"); } @@ -3177,8 +3194,8 @@ int player_set_display_mode(player_h player, player_display_mode_e mode) #ifdef TIZEN_FEATURE_EVAS_RENDERER if (EVAS_HANDLE(pc)) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_disp_mode, "disp_set_evas_display_disp_mode"); - ret = p_disp_set_evas_display_disp_mode(EVAS_HANDLE(pc), mode); - if (ret != MM_ERROR_NONE) + if (!p_disp_set_evas_display_disp_mode || + p_disp_set_evas_display_disp_mode(EVAS_HANDLE(pc), mode) != MM_ERROR_NONE) return PLAYER_ERROR_INVALID_OPERATION; else return PLAYER_ERROR_NONE; @@ -3213,12 +3230,13 @@ int player_get_display_mode(player_h player, player_display_mode_e *pmode) #ifdef TIZEN_FEATURE_EVAS_RENDERER if (EVAS_HANDLE(pc)) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_get_evas_display_disp_mode, "disp_get_evas_display_disp_mode"); - ret = p_disp_get_evas_display_disp_mode(EVAS_HANDLE(pc), &mode); - *pmode = (player_display_mode_e) mode; - if (ret != MM_ERROR_NONE) + if (!p_disp_get_evas_display_disp_mode || + p_disp_get_evas_display_disp_mode(EVAS_HANDLE(pc), &mode) != MM_ERROR_NONE) return PLAYER_ERROR_INVALID_OPERATION; - else - return PLAYER_ERROR_NONE; + + *pmode = (player_display_mode_e) mode; + + return PLAYER_ERROR_NONE; } #endif PLAYER_SEND_MSG(api, pc, ret_buf, ret); @@ -3323,6 +3341,8 @@ int player_set_display_roi_area(player_h player, int x, int y, int width, int he #ifdef TIZEN_FEATURE_EVAS_RENDERER if (EVAS_HANDLE(pc)) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_roi_area, "disp_set_evas_display_roi_area"); + if (!p_disp_set_evas_display_roi_area) + return PLAYER_ERROR_INVALID_OPERATION; ret = p_disp_set_evas_display_roi_area(EVAS_HANDLE(pc), x, y, width, height); if (ret == MM_ERROR_EVASRENDER_INVALID_ARGUMENT) return PLAYER_ERROR_INVALID_PARAMETER; @@ -3389,8 +3409,8 @@ int player_set_display_rotation(player_h player, player_display_rotation_e rotat #ifdef TIZEN_FEATURE_EVAS_RENDERER if (EVAS_HANDLE(pc)) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_rotation, "disp_set_evas_display_rotation"); - ret = p_disp_set_evas_display_rotation(EVAS_HANDLE(pc), rotation); - if (ret != MM_ERROR_NONE) + if (!p_disp_set_evas_display_rotation || + p_disp_set_evas_display_rotation(EVAS_HANDLE(pc), rotation) != MM_ERROR_NONE) return PLAYER_ERROR_INVALID_OPERATION; else return PLAYER_ERROR_NONE; @@ -3424,12 +3444,13 @@ int player_get_display_rotation(player_h player, player_display_rotation_e *prot #ifdef TIZEN_FEATURE_EVAS_RENDERER if (EVAS_HANDLE(pc)) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_get_evas_display_rotation, "disp_get_evas_display_rotation"); - ret = p_disp_get_evas_display_rotation(EVAS_HANDLE(pc), &rotation); - *protation = (player_display_rotation_e) rotation; - if (ret != MM_ERROR_NONE) + if (!p_disp_get_evas_display_rotation || + p_disp_get_evas_display_rotation(EVAS_HANDLE(pc), &rotation) != MM_ERROR_NONE) return PLAYER_ERROR_INVALID_OPERATION; - else - return PLAYER_ERROR_NONE; + + *protation = (player_display_rotation_e) rotation; + + return PLAYER_ERROR_NONE; } #endif PLAYER_SEND_MSG(api, pc, ret_buf, ret); @@ -3460,8 +3481,8 @@ int player_set_display_visible(player_h player, bool visible) #ifdef TIZEN_FEATURE_EVAS_RENDERER if (EVAS_HANDLE(pc)) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_visible, "disp_set_evas_display_visible"); - ret = p_disp_set_evas_display_visible(EVAS_HANDLE(pc), visible); - if (ret != MM_ERROR_NONE) + if (!p_disp_set_evas_display_visible || + p_disp_set_evas_display_visible(EVAS_HANDLE(pc), visible) != MM_ERROR_NONE) return PLAYER_ERROR_INVALID_OPERATION; EVAS_INFO(pc)->visible = visible ? EVAS_VISIBLE_TRUE : EVAS_VISIBLE_FALSE; @@ -3498,16 +3519,15 @@ int player_is_display_visible(player_h player, bool *pvisible) #ifdef TIZEN_FEATURE_EVAS_RENDERER if (EVAS_HANDLE(pc)) { PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_get_evas_display_visible, "disp_get_evas_display_visible"); - ret = p_disp_get_evas_display_visible(EVAS_HANDLE(pc), &visible); + if (!p_disp_get_evas_display_visible || + p_disp_get_evas_display_visible(EVAS_HANDLE(pc), &visible) != MM_ERROR_NONE) + return PLAYER_ERROR_INVALID_OPERATION; + if (visible) *pvisible = TRUE; else *pvisible = FALSE; - - if (ret != MM_ERROR_NONE) - return PLAYER_ERROR_INVALID_OPERATION; - else - return PLAYER_ERROR_NONE; + return PLAYER_ERROR_NONE; } #endif PLAYER_SEND_MSG(api, pc, ret_buf, ret); @@ -4131,11 +4151,10 @@ static void __retrieve_buffer_cb(void *user_data) LOGW("player_is_gapless is failed"); return; } - PLAYER_DISP_DLSYM(player->dl_handle, p_disp_evas_display_retrieve_all_packets, "disp_evas_display_retrieve_all_packets"); - ret = p_disp_evas_display_retrieve_all_packets(EVAS_HANDLE(player), gapless); - if (ret != PLAYER_ERROR_NONE) - LOGI("mm_evas_renderer_retrieve_all_packets returned error"); + if (!p_disp_evas_display_retrieve_all_packets || + p_disp_evas_display_retrieve_all_packets(EVAS_HANDLE(player), gapless) != PLAYER_ERROR_NONE) + LOGE("mm_evas_renderer_retrieve_all_packets returned error"); } static int __player_set_retrieve_buffer_cb(player_h player, player_retrieve_buffer_cb callback, void *user_data) @@ -4384,22 +4403,22 @@ int player_push_media_stream(player_h player, media_packet_h packet) LOGD("ENTER"); - if(media_packet_get_buffer_data_ptr(packet, (void **)&buf) != MEDIA_PACKET_ERROR_NONE) { + if (media_packet_get_buffer_data_ptr(packet, (void **)&buf) != MEDIA_PACKET_ERROR_NONE) { LOGE("failed to get buffer data ptr"); return PLAYER_ERROR_INVALID_OPERATION; } - if(media_packet_get_buffer_size(packet, &push_media.size) != MEDIA_PACKET_ERROR_NONE) { + if (media_packet_get_buffer_size(packet, &push_media.size) != MEDIA_PACKET_ERROR_NONE) { LOGE("failed to get buffer size"); return PLAYER_ERROR_INVALID_OPERATION; } - if(media_packet_get_pts(packet, &push_media.pts) != MEDIA_PACKET_ERROR_NONE) { + if (media_packet_get_pts(packet, &push_media.pts) != MEDIA_PACKET_ERROR_NONE) { LOGE("failed to get buffer pts"); return PLAYER_ERROR_INVALID_OPERATION; } - if(media_packet_get_format(packet, &format) != MEDIA_PACKET_ERROR_NONE) { /* format ref count is increased */ + if (media_packet_get_format(packet, &format) != MEDIA_PACKET_ERROR_NONE) { /* format ref count is increased */ LOGE("failed to get media format"); return PLAYER_ERROR_INVALID_OPERATION; } diff --git a/src/player_internal.c b/src/player_internal.c index 7364f8e..8817722 100644 --- a/src/player_internal.c +++ b/src/player_internal.c @@ -169,6 +169,8 @@ int player_set_ecore_wl_display(player_h player, player_display_type_e type, voi return PLAYER_ERROR_INVALID_PARAMETER; PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_wl_display, "disp_set_wl_display"); + if (!p_disp_set_wl_display) + return PLAYER_ERROR_INVALID_OPERATION; wl_surface_id = p_disp_set_wl_display(ECORE_WAYLAND_WIN, ecore_wl2_window); if (wl_surface_id > 0) { wl_win.surface_id = wl_surface_id;