From 0ac9108b4c4d35bfb4dda1bec099f6a0fabeba50 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Wed, 23 Nov 2016 09:42:32 +0900 Subject: [PATCH] Add logic for updating volume frequently Change-Id: I228c18ca14b132354ff7477a4f42112704b9b29b Signed-off-by: Wonnam Jang --- client/vc_mgr.c | 36 ++++++++++++++++++++++++++++++++++-- server/vcd_recorder.c | 2 +- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index a78e2b5..ba7f6e5 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -37,12 +37,18 @@ static Ecore_Timer* g_m_connect_timer = NULL; +static Ecore_Timer* g_m_set_volume_timer = NULL; + static vc_h g_vc_m = NULL; static GSList* g_demandable_client_list = NULL; static float g_volume_db = 0; +static float g_prev_volume_db = 0; + +static float g_cur_volume_db = 0; + static int g_daemon_pid = 0; static int g_feature_enabled = -1; @@ -1758,10 +1764,36 @@ int vc_mgr_cancel() return ret; } +static int g_cnt = 0; +static Eina_Bool __vc_mgr_set_volume(void* data) +{ + g_cnt++; + g_volume_db = g_prev_volume_db + (g_cur_volume_db - g_prev_volume_db) / 5 * g_cnt; + + SLOG(LOG_DEBUG, TAG_VCM, "Set volume (%f)(%f)", g_volume_db, g_cur_volume_db); + + if (0 == g_cnt % 5) { + return EINA_FALSE; + } + return EINA_TRUE; +} + int __vc_mgr_cb_set_volume(float volume) { - g_volume_db = volume; - SLOG(LOG_DEBUG, TAG_VCM, "Set volume (%f)", g_volume_db); + g_prev_volume_db = g_volume_db; + g_cur_volume_db = volume; + + g_volume_db = g_prev_volume_db + (g_cur_volume_db - g_prev_volume_db) / 5; + + SLOG(LOG_DEBUG, TAG_VCM, "Set volume (%f)(%f)", g_volume_db, g_cur_volume_db); + + if (NULL != g_m_set_volume_timer) { + SLOG(LOG_DEBUG, TAG_VCM, "Connect Timer is deleted"); + ecore_timer_del(g_m_set_volume_timer); + } + + g_cnt = 1; + g_m_set_volume_timer = ecore_timer_add(50, __vc_mgr_set_volume, NULL); return 0; } diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index 9ffb34c..78134fb 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -160,7 +160,7 @@ static void _bt_hid_audio_data_receive_cb(bt_hid_voice_data_s *voice_data, void } /* Set volume */ - if (0 == g_buffer_count % 30) { + if (0 == g_buffer_count % 15) { float vol_db = get_volume_decibel((char*)voice_data->audio_buf, (unsigned int)voice_data->length); if (0 != vcdc_send_set_volume(vcd_client_manager_get_pid(), vol_db)) { SLOG(LOG_ERROR, TAG_VCD, "[Recorder] Fail to send recording volume(%f)", vol_db); -- 2.7.4