Use buffer size as minimum value of buffer_size and BUFFER_LENGTH 37/230937/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 16 Apr 2020 06:25:32 +0000 (15:25 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 16 Apr 2020 06:25:32 +0000 (15:25 +0900)
buffer_size can be different from BUFFER_LENGTH.
However, if buffer_size is bigger than BUFFER_LENGTH, buffer overflow can be occured.
Thus, I use minimum value of buffer_size and BUFFER_LENGTH as parameter.

And also, this patch pass the same variable to g_audio_cb and get_volume_decibel.

Change-Id: I1231f056226415e820b079da3241e5ee82f8793d
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
server/vcd_recorder.c

index bfa8fd35b6ebd289ecbfd77bdc18ac6046eae601..a2d26486bf2e36e8f4549f5b76f7efb764664939 100644 (file)
@@ -777,10 +777,12 @@ Eina_Bool __read_test_func(void *data)
        if (buffer_size != BUFFER_LENGTH)
                SLOG(LOG_DEBUG, TAG_VCD, "[Recorder test] Get data size(%d)", buffer_size);
 
+       buffer_size = MIN(buffer_size, BUFFER_LENGTH);
+
        if (NULL != g_audio_cb && buffer_size != 0)
                g_audio_cb(buffer, buffer_size);
 
-       float vol_db = get_volume_decibel(buffer, BUFFER_LENGTH);
+       float vol_db = get_volume_decibel(buffer, buffer_size);
        if (0 != vcdc_send_set_volume(vcd_client_manager_get_pid(), vol_db))
                SLOG(LOG_ERROR, TAG_VCD, "[Recorder test] Fail to send recording volume(%f)", vol_db);