Fix invalid volume when recorded data is NULL 88/117788/1
authorKwangyoun Kim <ky85.kim@samsung.com>
Thu, 19 Jan 2017 08:29:18 +0000 (17:29 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 7 Mar 2017 11:51:47 +0000 (03:51 -0800)
Change-Id: I64fddfbc492617daf1f9f512f66c1a91db00a87a
(cherry picked from commit 304379bd6ce022e7bca0ed2ca71e9d01e6e2cd51)

client/vc_mgr.c
server/vcd_recorder.c

index 2001006..4560dff 100644 (file)
@@ -1723,6 +1723,10 @@ int vc_mgr_start(bool exclusive_command_option)
                }
        }
 
+       g_volume_db = 0;
+       g_prev_volume_db = 0;
+       g_cur_volume_db = 0;
+
        SLOG(LOG_DEBUG, TAG_VCM, "=====");
        SLOG(LOG_DEBUG, TAG_VCM, " ");
 
index 307f75b..4d3cb7e 100644 (file)
@@ -514,10 +514,12 @@ static float get_volume_decibel(char* data, int size)
                count++;
        }
 
-       if (0 == count)
-               rms = 0.0;
-       else
+       if (0 == count) {
+               SLOG(LOG_ERROR, TAG_VCD, "[ERROR] NULL data");
+               rms = 1.0;
+       } else {
                rms = sqrt((float)square_sum/count);
+       }
 
        db = 20 * log10(rms/MAX_AMPLITUDE_MEAN_16);
        return db;