Unlock mutex before invoking state callback 67/245267/2
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 6 Oct 2020 07:37:02 +0000 (16:37 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 8 Oct 2020 07:11:53 +0000 (16:11 +0900)
Codes about the mutex to secure the state are also added
in __webrtcbin_peer_connection_state_cb().

[Version] 0.1.35
[Issue Type] Improvement

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

index 0ed53a9d582cae8e4fc341b753541b48ad0dd2e2..6cdf74cebddc74e11ba590b84b9ede2a1ef1b448 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.1.34
+Version:    0.1.35
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index e66b2e0b0a4a9d186b0e7282378891885f371881..ef72e4a5763b9ff940e3abb82b137ddff1708872 100644 (file)
@@ -223,11 +223,12 @@ static gboolean __bus_watch_cb(GstBus *bus, GstMessage *message, gpointer user_d
                if (__meet_gst_state(webrtc->pend_state, gst_state_new)) {
                        webrtc_state_e old_state = webrtc->state;
                        webrtc->state = webrtc->pend_state;
-
+                       g_mutex_unlock(&webrtc->mutex);
                        __invoke_state_changed_cb(webrtc, old_state, webrtc->state);
+                       break;
                }
-               g_mutex_unlock(&webrtc->mutex);
 
+               g_mutex_unlock(&webrtc->mutex);
                break;
 
        case GST_MESSAGE_ASYNC_DONE:
@@ -517,11 +518,17 @@ static void __webrtcbin_peer_connection_state_cb(GstElement *webrtcbin, GParamSp
        switch (peer_connection_state) {
        case GST_WEBRTC_PEER_CONNECTION_STATE_NEW:
                new_state = "NEW";
+
+               g_mutex_lock(&webrtc->mutex);
                if (webrtc->state == WEBRTC_STATE_NEGOTIATING) {
                        webrtc_state_e old_state = webrtc->state;
                        webrtc->state = webrtc->pend_state = WEBRTC_STATE_PLAYING;
+                       g_mutex_unlock(&webrtc->mutex);
                        __invoke_state_changed_cb(webrtc, old_state, webrtc->state);
+                       break;
                }
+
+               g_mutex_unlock(&webrtc->mutex);
                break;
 
        case GST_WEBRTC_PEER_CONNECTION_STATE_CONNECTING: