From: Kwangyoun Kim Date: Thu, 19 Jan 2017 08:29:18 +0000 (+0900) Subject: Fix invalid volume when recorded data is NULL X-Git-Tag: accepted/tizen/unified/20170406.054054~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fdb034c336bc86ad0f237009a6ea5b4d6d26faf7;p=platform%2Fcore%2Fuifw%2Fvoice-control.git Fix invalid volume when recorded data is NULL Change-Id: I64fddfbc492617daf1f9f512f66c1a91db00a87a (cherry picked from commit 304379bd6ce022e7bca0ed2ca71e9d01e6e2cd51) --- diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 2001006..4560dff 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -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, " "); diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index 307f75b..4d3cb7e 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -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;