webrtc_display: Improve codes regarding applying display in default context 56/249256/2
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 9 Dec 2020 08:37:07 +0000 (17:37 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 14 Dec 2020 05:55:18 +0000 (14:55 +0900)
Use g_main_context_invoke() instead of g_idle_add() to call the callback
function directly if the context is owned by caller.
Use g_idle_remove_by_data() to remove the idle function that might remain.

[Version] 0.1.70
[Issue Type] Improvement

Change-Id: I089c3cc876f55330050f532719d391a0181d07dc
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
src/webrtc_display.c

index 88da9519afc30e5c734fb9cd41becbdffcfb745d..0bbc79a52baf6553bed0b080ed27cb071dd308fe 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.1.69
+Version:    0.1.70
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index a47c46f9eac1cbdf8f5f0256c97eaaef58be3b7b..b500ac30bdf879f83c7ac738563d04db72c36b39 100644 (file)
@@ -621,7 +621,7 @@ void _video_stream_decoded_cb(GstElement *object, GstBuffer *buffer, GstPad *pad
        webrtc_display_s *display = (webrtc_display_s*)data;
        media_packet_h packet;
 
-       RET_IF(display == NULL, "sink is NULL");
+       RET_IF(display == NULL, "display is NULL");
 
        LOG_DEBUG("object[%p] buffer[%p] pad[%p] display[%p]", object, buffer, pad, display);
 
@@ -703,7 +703,7 @@ int _apply_display(webrtc_display_s *display)
        case WEBRTC_DISPLAY_TYPE_OVERLAY:
                LOG_DEBUG("it's OVERLAY type");
 
-               g_idle_add(__set_overlay_display_idle_cb, display);
+               g_main_context_invoke(NULL, __set_overlay_display_idle_cb, display);
                break;
 
        case WEBRTC_DISPLAY_TYPE_EVAS:
@@ -712,13 +712,13 @@ int _apply_display(webrtc_display_s *display)
                if (display->tbm == NULL)
                        display->tbm = _alloc_tbm();
 
-               g_idle_add(__set_evas_display_idle_cb, display);
+               g_main_context_invoke(NULL, __set_evas_display_idle_cb, display);
                break;
 
        case WEBRTC_DISPLAY_TYPE_ECORE_WL:
                LOG_DEBUG("it's ECORE_WL type");
 
-               g_idle_add(__set_overlay_display_idle_cb, display);
+               g_main_context_invoke(NULL, __set_overlay_display_idle_cb, display);
                break;
 
        default:
@@ -747,10 +747,12 @@ webrtc_display_s *_alloc_display(void)
 
 void _release_display(webrtc_display_s *display)
 {
-       RET_IF(display == NULL, "webrtc is NULL");
+       RET_IF(display == NULL, "display is NULL");
 
        g_mutex_lock(&display->mutex);
 
+       g_idle_remove_by_data(display);
+
        if (display->mm_display) {
                LOG_DEBUG("deinit display->mm_display[%p]", display->mm_display);
                mm_display_interface_deinit(display->mm_display);