Add new API for setting display in sub thread 87/249487/2 accepted/tizen/unified/20201215.123254 submit/tizen/20201214.092711
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 14 Dec 2020 02:48:18 +0000 (11:48 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 14 Dec 2020 06:34:23 +0000 (15:34 +0900)
- mm_display_interface_set_display_mainloop_sync();
- mm_display_interface_set_display() should be called in main-thread,
  but, new API is allowed to be called in sub-thread.

[Version] 0.0.10
[Issue Type] New feature

Change-Id: Ia32fab3d643e3fe4f8a66b1e109858e05c69ea27
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-display.spec
src/include/mm_display.h
src/include/mm_display_interface.h
src/include/mm_display_interface_private.h
src/mm_display.c
src/mm_display_interface.c

index 8603f88..341d742 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-display
 Summary:    Multimedia framework display library
-Version:    0.0.9
+Version:    0.0.10
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index ca1240c..65e8814 100644 (file)
@@ -43,8 +43,15 @@ typedef void *mm_display_h;
 
 int mm_display_init(mm_display_h *handle);
 int mm_display_deinit(mm_display_h handle);
+
+/* NOTE: This function should be called in main thread. */
 int mm_display_set_display(mm_display_h handle, mm_display_type_e type, void *display, int *parent_id);
+/* NOTE: This function is allowed to call in sub thread, but main thread could be blocked until it's being called. */
+int mm_display_set_display_mainloop_sync(mm_display_h handle, mm_display_type_e type, void *display, int *parent_id);
+
 int mm_display_get_type(mm_display_h handle, mm_display_type_e *type);
+int mm_display_get_window_rect(mm_display_h handle, MMRectType *window_rect);
+
 #ifdef TIZEN_FEATURE_EVAS_RENDERER
 int mm_display_evas_set_rotation(mm_display_h handle, int rotation);
 int mm_display_evas_get_rotation(mm_display_h handle, int *rotation);
index 23989eb..6bd06cc 100644 (file)
@@ -37,9 +37,15 @@ typedef void (*mm_display_evas_rendered_cb)(media_packet_h packet, void *user_da
 
 int mm_display_interface_init(mm_display_interface_h *handle);
 int mm_display_interface_deinit(mm_display_interface_h handle);
+
+/* NOTE: This function should be called in main thread. */
 int mm_display_interface_set_display(mm_display_interface_h handle, mm_display_type_e type, void *display, int *parent_id);
+/* NOTE: This function is allowed to call in sub thread, but main thread could be blocked until it's being called. */
+int mm_display_interface_set_display_mainloop_sync(mm_display_interface_h handle, mm_display_type_e type, void *display, int *parent_id);
+
 int mm_display_interface_get_type(mm_display_interface_h handle, mm_display_type_e *type);
 int mm_display_interface_get_window_rect(mm_display_interface_h handle, MMRectType *window_rect);
+
 int mm_display_interface_evas_set_rotation(mm_display_interface_h handle, int rotation);
 int mm_display_interface_evas_get_rotation(mm_display_interface_h handle, int *rotation);
 int mm_display_interface_evas_set_visible(mm_display_interface_h handle, bool visible);
index 5b5d034..7602c22 100644 (file)
@@ -34,6 +34,7 @@ typedef struct mm_display_interface {
        int (*init)(void **);
        int (*deinit)(void *);
        int (*set_display)(void *, mm_display_type_e, void *, int *);
+       int (*set_display_mainloop_sync)(void *, mm_display_type_e, void *, int *);
        int (*get_type)(void *, mm_display_type_e *);
        int (*get_window_rect)(void *, MMRectType *);
        int (*evas_set_rotation)(void *, int);
index 1a75bb7..126d257 100644 (file)
@@ -348,6 +348,28 @@ int mm_display_set_display(mm_display_h handle, mm_display_type_e type, void *di
 }
 
 
+int mm_display_set_display_mainloop_sync(mm_display_h handle, mm_display_type_e type, void *display, int *parent_id)
+{
+       int ret = MM_ERROR_NONE;
+
+       LOGD("enter - type %d", type);
+
+       if (ecore_thread_main_loop_begin() < 0) {
+               LOGE("ecore_thread_main_loop_begin failed");
+               return MM_ERROR_COMMON_INTERNAL;
+       }
+
+       ret = mm_display_set_display(handle, type, display, parent_id);
+
+       LOGI("ret 0x%x", ret);
+
+       if (ecore_thread_main_loop_end() < 0)
+               LOGE("ecore_thread_main_loop_end failed");
+
+       return ret;
+}
+
+
 int mm_display_get_type(mm_display_h handle, mm_display_type_e *type)
 {
        mm_display_t *dp_handle = (mm_display_t *)handle;
index 5f3bc44..6f807bf 100644 (file)
@@ -77,6 +77,7 @@ int mm_display_interface_init(mm_display_interface_h *handle)
        sym_ret = g_module_symbol(module, "mm_display_init", (gpointer *)&new_interface->init);
        sym_ret &= g_module_symbol(module, "mm_display_deinit", (gpointer *)&new_interface->deinit);
        sym_ret &= g_module_symbol(module, "mm_display_set_display", (gpointer *)&new_interface->set_display);
+       sym_ret &= g_module_symbol(module, "mm_display_set_display_mainloop_sync", (gpointer *)&new_interface->set_display_mainloop_sync);
        sym_ret &= g_module_symbol(module, "mm_display_get_type", (gpointer *)&new_interface->get_type);
        sym_ret &= g_module_symbol(module, "mm_display_get_window_rect", (gpointer *)&new_interface->get_window_rect);
 #ifdef TIZEN_FEATURE_EVAS_RENDERER
@@ -176,6 +177,19 @@ int mm_display_interface_set_display(mm_display_interface_h handle, mm_display_t
 }
 
 
+int mm_display_interface_set_display_mainloop_sync(mm_display_interface_h handle, mm_display_type_e type, void *display, int *parent_id)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+
+       if (!interface->set_display_mainloop_sync) {
+               LOGE("NULL function pointer");
+               return MM_ERROR_UNKNOWN;
+       }
+
+       return interface->set_display_mainloop_sync(interface->dp_handle, type, display, parent_id);
+}
+
+
 int mm_display_interface_get_type(mm_display_interface_h handle, mm_display_type_e *type)
 {
        DECLARE_CHECK_INTERFACE_HANDLE(handle);