Add defensive code for spurious wakeup in _mmcamcorder_sound_solo_play_wait() 65/288065/2 accepted/tizen/unified/20230215.100656
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 10 Feb 2023 02:31:26 +0000 (11:31 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Fri, 10 Feb 2023 04:07:27 +0000 (13:07 +0900)
[Version] 0.10.286
[Issue Type] Improvement

Change-Id: I8e8c5cd2ea403823a99b8f9776c78156cb4c8f6a
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/mm_camcorder_sound.c

index 625951c..ae57548 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.285
+Version:    0.10.286
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 96301ae..3d242e5 100644 (file)
@@ -210,33 +210,32 @@ int _mmcamcorder_sound_solo_play(MMHandleType handle, const char *sample_name, g
 
 void _mmcamcorder_sound_solo_play_wait(MMHandleType handle)
 {
+       gint64 end_time = 0;
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+       _MMCamcorderGDbusCbInfo *info = NULL;
 
-       mmf_return_if_fail(hcamcorder);
+       mmf_return_if_fail(hcamcorder && hcamcorder->gdbus_info_solo_sound);
 
-       MMCAM_LOG_INFO("START");
+       info = hcamcorder->gdbus_info_solo_sound;
 
-       /* check playing sound count */
-       g_mutex_lock(&hcamcorder->gdbus_info_solo_sound->sync_mutex);
+       MMCAM_LOG_INFO("START - is_playing[%d]", info->is_playing);
 
-       if (hcamcorder->gdbus_info_solo_sound->is_playing) {
-               gint64 end_time = 0;
+       end_time = g_get_monotonic_time() + _MMCAMCORDER_SOLO_PLAY_WAIT_TIMEOUT;
 
-               MMCAM_LOG_INFO("Wait for signal");
+       g_mutex_lock(&info->sync_mutex);
 
-               end_time = g_get_monotonic_time() + _MMCAMCORDER_SOLO_PLAY_WAIT_TIMEOUT;
+       while (info->is_playing) {
+               MMCAM_LOG_INFO("Wait for signal");
 
-               if (g_cond_wait_until(&hcamcorder->gdbus_info_solo_sound->sync_cond,
-                       &hcamcorder->gdbus_info_solo_sound->sync_mutex, end_time)) {
-                       MMCAM_LOG_INFO("signal received.");
-               } else {
-                       MMCAM_LOG_WARNING("capture sound play timeout.");
+               if (!g_cond_wait_until(&info->sync_cond, &info->sync_mutex, end_time)) {
+                       MMCAM_LOG_WARNING("sound play EOS timeout");
+                       break;
                }
-       } else {
-               MMCAM_LOG_WARNING("no playing sound");
+
+               MMCAM_LOG_INFO("signal received, check again[is_playing:%d]", info->is_playing);
        }
 
-       g_mutex_unlock(&hcamcorder->gdbus_info_solo_sound->sync_mutex);
+       g_mutex_unlock(&info->sync_mutex);
 
        MMCAM_LOG_INFO("DONE");