[0.6.250] Improve to defend the spurious wakeup issue of g_cond_wait_until() 07/248907/1
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 3 Dec 2020 06:46:53 +0000 (15:46 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 3 Dec 2020 06:52:58 +0000 (15:52 +0900)
It is expressed in
: https://developer.gnome.org/glib/stable/glib-Threads.html#g-cond-wait-until

Change-Id: Id5d35f6a403df01c7a976dff7a3b825217f9ba34
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/libmm-player.spec
src/mm_player_priv.c

index a8ea8e7..86b01f3 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.249
+Version:    0.6.250
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index c25a6fc..f6f6305 100644 (file)
@@ -3273,6 +3273,7 @@ __mmplayer_video_stream_get_bo(mmplayer_t *player, int size)
        GList *l = NULL;
        MMPLAYER_RETURN_VAL_IF_FAIL(player, NULL);
        gboolean ret = TRUE;
+       gint64 end_time = 0;
 
        /* check DRC, if it is, destroy the prev bo list to create again */
        if (player->video_bo_size != size) {
@@ -3325,6 +3326,9 @@ __mmplayer_video_stream_get_bo(mmplayer_t *player, int size)
                }
        }
 
+       if (player->ini.video_bo_timeout > 0)
+               end_time = g_get_monotonic_time() + player->ini.video_bo_timeout * G_TIME_SPAN_SECOND;
+
        while (TRUE) {
                /* get bo from list*/
                for (l = g_list_first(player->video_bo_list); l; l = g_list_next(l)) {
@@ -3336,20 +3340,20 @@ __mmplayer_video_stream_get_bo(mmplayer_t *player, int size)
                                return tbm_bo_ref(tmp->bo);
                        }
                }
-               if (!ret) {
-                       LOGE("failed to get bo in %d timeout", player->ini.video_bo_timeout);
-                       MMPLAYER_VIDEO_BO_UNLOCK(player);
-                       return NULL;
-               }
 
                if (player->ini.video_bo_timeout <= 0) {
                        MMPLAYER_VIDEO_BO_WAIT(player);
                } else {
-                       gint64 timeout = g_get_monotonic_time() + player->ini.video_bo_timeout * G_TIME_SPAN_SECOND;
-                       ret = MMPLAYER_VIDEO_BO_WAIT_UNTIL(player, timeout);
+                       ret = MMPLAYER_VIDEO_BO_WAIT_UNTIL(player, end_time);
+                       if (!ret) {
+                               LOGE("failed to get bo in %d timeout", player->ini.video_bo_timeout);
+                               break;
+                       }
                }
-               continue;
        }
+
+       MMPLAYER_VIDEO_BO_UNLOCK(player);
+       return NULL;
 }
 
 static void