[ACR-1236] Add new restriction about _set_display 87/180787/4
authorEunhae Choi <eunhae1.choi@samsung.com>
Mon, 4 Jun 2018 07:30:23 +0000 (16:30 +0900)
committerHyunil Park <hyunil46.park@samsung.com>
Thu, 7 Jun 2018 03:36:04 +0000 (03:36 +0000)
Change-Id: I4eb6b78340dfad1cec1ca78bbeecc9f031f8ddb3

include/player.h
src/player.c

index 7cbe4b689b9e7ea87e66205740aeda8939182de7..65f0a172d35e1bf797e81d7fba6df946e2d17f61 100644 (file)
@@ -947,6 +947,11 @@ int player_is_looping(player_h player, bool *looping);
  * @remarks We are not supporting changing display.
  * @remarks This function have be called before calling the player_prepare() or player_prepare_async() \n
  *          to reflect the display type.
+ * @remarks This function must be called in main thread of application.
+ *          Otherwise, it will return #PLAYER_ERROR_INVALID_OPERATION by internal restriction.
+ *          To avoid #PLAYER_ERROR_INVALID_OPERATION in sub thread, ecore_thread_main_loop_begin() and
+ *          ecore_thread_main_loop_end() can be used, but deadlock can be also occurred if main thread is busy.
+ *          So, it's not recommended to use them. (since 5.0)
  * @param[in]   player The handle to the media player
  * @param[in]   type The display type
  * @param[in]   display The handle to display
@@ -962,6 +967,8 @@ int player_is_looping(player_h player, bool *looping);
  * @see player_set_display_roi_area
  * @see player_set_display_visible
  * @see player_set_display_rotation
+ * @see ecore_thread_main_loop_begin()
+ * @see ecore_thread_main_loop_end()
  */
 int player_set_display(player_h player, player_display_type_e type, player_display_h display);
 
index 52aeabbb5d857bb767332203473bf17a010f2b5e..93c9cf190c0d1b8282cbd35451ffcd23f6a7561c 100644 (file)
@@ -18,6 +18,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
+#include <sys/stat.h>
+#include <syscall.h>
 #include <unistd.h>
 #include <tbm_bufmgr.h>
 #include <tbm_surface.h>
@@ -2769,8 +2771,17 @@ int player_set_display(player_h player, player_display_type_e type, player_displ
        void (*p_disp_get_evas_display_geometry_info)(void *, int *, int *, int *, int *) = NULL;
        void (*p_disp_media_packet_video_decode_cb)(media_packet_h, void *) = NULL;
 #endif
+       pid_t pid = getpid();
+       pid_t tid = syscall(SYS_gettid);
 
        LOGD("ENTER");
+
+       LOGD("Check if API is called in main thread. pid [%d], tid [%d]", pid, tid);
+       if (pid != tid) {
+               LOGE("API isn't called in main thread");
+               return PLAYER_ERROR_INVALID_OPERATION;
+       }
+
        PLAYER_VIDEO_SUPPORTABLE_CHECK(pc);
 
        /* init */