From fedaa38dc3b6b11eef712fac7d420fa33fd5816e Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 9 Jul 2020 14:33:34 +0900 Subject: [PATCH] Remove code only for TV device Change-Id: I0fa7dfbe48c72015d6a14bacea0bccc71bd4edde Signed-off-by: Suyeon Hwang --- CMakeLists.txt | 7 - audio-manager/src/vc_audio_manager.cpp | 36 ++- packaging/voice-control.spec | 12 - server/vcd_recorder.c | 383 ++----------------------- 4 files changed, 56 insertions(+), 382 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 091ba64..b9fabd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,17 +45,10 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") ## Dependent packages ## INCLUDE(FindPkgConfig) -IF("${_TV_PRODUCT}" STREQUAL "TRUE") -pkg_check_modules(pkgs REQUIRED - aul buxton2 capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wl2 - capi-network-bluetooth capi-network-bluetooth-tv capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf msfapi farfield-voice-api gmock -) -ELSE() pkg_check_modules(pkgs REQUIRED aul buxton2 capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wl2 capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf gmock ) -ENDIF() ## API ## diff --git a/audio-manager/src/vc_audio_manager.cpp b/audio-manager/src/vc_audio_manager.cpp index 32631f3..e1253ae 100644 --- a/audio-manager/src/vc_audio_manager.cpp +++ b/audio-manager/src/vc_audio_manager.cpp @@ -49,14 +49,30 @@ static bool __convert_audio_channel(int channel, audio_channel_e* output) audio_channel_e audio_ch = AUDIO_CHANNEL_MONO; switch (channel) { - case 1: audio_ch = AUDIO_CHANNEL_MONO; break; - case 2: audio_ch = AUDIO_CHANNEL_STEREO; break; - case 3: audio_ch = AUDIO_CHANNEL_MULTI_3; break; - case 4: audio_ch = AUDIO_CHANNEL_MULTI_4; break; - case 5: audio_ch = AUDIO_CHANNEL_MULTI_5; break; - case 6: audio_ch = AUDIO_CHANNEL_MULTI_6; break; - case 7: audio_ch = AUDIO_CHANNEL_MULTI_7; break; - case 8: audio_ch = AUDIO_CHANNEL_MULTI_8; break; + case 1: + audio_ch = AUDIO_CHANNEL_MONO; + break; + case 2: + audio_ch = AUDIO_CHANNEL_STEREO; + break; + case 3: + audio_ch = AUDIO_CHANNEL_MULTI_3; + break; + case 4: + audio_ch = AUDIO_CHANNEL_MULTI_4; + break; + case 5: + audio_ch = AUDIO_CHANNEL_MULTI_5; + break; + case 6: + audio_ch = AUDIO_CHANNEL_MULTI_6; + break; + case 7: + audio_ch = AUDIO_CHANNEL_MULTI_7; + break; + case 8: + audio_ch = AUDIO_CHANNEL_MULTI_8; + break; default: VCAM_LOGE("[ERROR] Input channel is not supported. [channel(%d)]", channel); return false; @@ -97,7 +113,7 @@ static Eina_Bool __recorder_timer_func(void *data) int read_bytes = audio_in_read(g_audio_h, buffer, BUFFER_LENGTH); if (0 > read_bytes) { - VCAM_LOGW("[WARNING] Fail to read audio : %d", read_bytes); + VCAM_LOGW("Fail to read audio : %d", read_bytes); return ECORE_CALLBACK_DONE; } @@ -230,7 +246,6 @@ int vcd_dependency_set_audio_info(sound_stream_info_h stream_info_h, const char* g_audio_rate = rate; g_audio_channel = channel; - VCAM_LOGI(""); return VCE_ERROR_NONE; } @@ -246,7 +261,6 @@ int vcd_dependency_get_audio_source_type(char** audio_source_type) return VCE_ERROR_NONE; } - int vcd_dependency_start_recording(void) { VCAM_LOGI(""); diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 8c36205..b4c4acc 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -33,12 +33,6 @@ BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(pkgmgr-installer) -%if "%{tizen_profile_name}" == "tv" -BuildRequires: pkgconfig(capi-network-bluetooth) -BuildRequires: pkgconfig(capi-network-bluetooth-tv) -BuildRequires: pkgconfig(msfapi) -BuildRequires: pkgconfig(farfield-voice-api) -%endif BuildRequires: pkgconfig(vconf) BuildRequires: cmake BuildRequires: pkgconfig(gmock) @@ -126,14 +120,8 @@ export FFLAGS="$FFLAGS -fprofile-arcs -ftest-coverage" export LDFLAGS="$LDFLAGS -lgcov" %endif -%if "%{tizen_profile_name}" == "tv" -export CFLAGS="$CFLAGS -DTV_PRODUCT" -cmake . -DCMAKE_INSTALL_PREFIX=/usr -DLIBDIR=%{_libdir} -DBINDIR=%{_bindir} -DINCLUDEDIR=%{_includedir} \ - -DTZ_SYS_RO_SHARE=%TZ_SYS_RO_SHARE -D_TV_PRODUCT=TRUE -DTZ_SYS_BIN=%TZ_SYS_BIN -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP -%else cmake . -DCMAKE_INSTALL_PREFIX=/usr -DLIBDIR=%{_libdir} -DBINDIR=%{_bindir} -DINCLUDEDIR=%{_includedir} \ -DTZ_SYS_RO_SHARE=%TZ_SYS_RO_SHARE -DTZ_SYS_BIN=%TZ_SYS_BIN -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP -%endif make %{?jobs:-j%jobs} %if 0%{?gcov:1} diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index 0b75741..74875e8 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -14,27 +14,10 @@ * limitations under the License. */ -#ifdef TV_PRODUCT -#define TV_BT_MODE -#define TV_MSF_WIFI_MODE -#define TV_FFV_MODE -#endif - #include #include #include #include -#ifdef TV_PRODUCT -#ifdef TV_BT_MODE -#include -#endif -#ifdef TV_MSF_WIFI_MODE -#include -#endif -#ifdef TV_FFV_MODE -#include -#endif -#endif #include "vcd_client_data.h" #include "vcd_config.h" @@ -62,20 +45,13 @@ static sound_stream_info_h g_stream_info_h = NULL; static sound_stream_info_h g_stream_for_volume_h = NULL; static virtual_sound_stream_h g_virtual_sound_stream_h = NULL; -static bool g_is_valid_audio_in = false; -static bool g_is_valid_bt_in = false; -static char* g_current_audio_type = NULL; static int g_buffer_count = 0; static int g_device_id = -1; static char* g_pcm_path = NULL; static FILE* g_pcm_fp = NULL; -#ifdef TV_FFV_MODE -farfield_voice_h g_farfieldvoice_h = NULL; -#endif - /* Sound buf save */ #if 0 @@ -87,165 +63,40 @@ static FILE* g_normal_file = NULL; static int g_count = 1; #endif -static float get_volume_decibel(const char* data, const unsigned int size); - -#ifdef TV_MSF_WIFI_MODE -static void __msf_wifi_audio_data_receive_cb(msf_wifi_voice_data_s *voice_data, void* user_data) -{ - if (0 != strncmp(g_current_audio_type, VCE_AUDIO_ID_WIFI, sizeof(VCE_AUDIO_ID_WIFI))) { - vcd_state_e state = vcd_config_get_service_state(); - if (VCD_STATE_READY == state) { - vcd_recorder_set(VCE_AUDIO_ID_WIFI, VCE_AUDIO_TYPE_PCM_S16_LE, 16000, 1); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] current audio type is (%s)", g_current_audio_type); - return; - } - } - - if (VCD_RECORDER_STATE_RECORDING != g_recorder_state) { - SLOG(LOG_WARN, TAG_VCD, "[Recorder] Not start yet, but send audio data vi Wi-Fi"); - vcd_recorder_start(); - } - - if (NULL != g_audio_cb) { - if (0 != g_audio_cb((void*)voice_data->audio_buf, (unsigned int)voice_data->length)) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to read audio"); - vcd_recorder_stop(); - } - } - - /* Set volume */ - if (0 == g_buffer_count % 30) { - 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); - } - } - if (0 == g_buffer_count || 0 == g_buffer_count % 50) { - SLOG(LOG_WARN, TAG_VCD, "[Recorder][%d] Recording... : read_size(%ld)", g_buffer_count, voice_data->length); - - if (100000 == g_buffer_count) - g_buffer_count = 0; - } - - g_buffer_count++; - -#ifdef BUF_SAVE_MODE - /* write pcm buffer */ - fwrite(voice_data->audio_buf, 1, voice_data->length, g_normal_file); -#endif - return; -} - -#endif - - -#ifdef TV_BT_MODE -static int g_bt_extend_count; - -#define SMART_CONTROL_EXTEND_CMD 0x03 -#define SMART_CONTROL_START_CMD 0x04 - -static void _bt_cb_hid_state_changed(int result, bool connected, const char *remote_address, void *user_data) -{ - SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Bluetooth Event [%d] Received address [%s]", result, remote_address); - return; -} - -static void _bt_hid_audio_data_receive_cb(bt_hid_voice_data_s *voice_data, void *user_data) +// TODO: make common function? +static float get_volume_decibel(const char* data, const unsigned int size) { - if (0 != strncmp(g_current_audio_type, VCE_AUDIO_ID_BLUETOOTH, sizeof(VCE_AUDIO_ID_BLUETOOTH))) { - vcd_state_e state = vcd_config_get_service_state(); - if (VCD_STATE_READY == state) { - vcd_recorder_set(VCE_AUDIO_ID_BLUETOOTH, VCE_AUDIO_TYPE_PCM_S16_LE, 16000, 1); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] current audio type is (%s)", g_current_audio_type); - return; - } - } - - if (VCD_RECORDER_STATE_RECORDING != g_recorder_state) { - SLOG(LOG_WARN, TAG_VCD, "[Recorder] Not start yet, but send audio data vi Bluetooth"); - // vcd_recorder_start(); - } - - if (NULL != g_audio_cb) { - if (0 != g_audio_cb((void*)voice_data->audio_buf, (unsigned int)voice_data->length)) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to read audio"); - vcd_recorder_stop(); - } - } - - /* Set volume */ - 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); - } - } - - if (0 == g_buffer_count || 0 == g_buffer_count % 50) { - SLOG(LOG_WARN, TAG_VCD, "[Recorder][%d] Recording... : read_size(%d)", g_buffer_count, voice_data->length); - - if (0 == g_bt_extend_count % 5 && 0 != g_buffer_count) { - const unsigned char input_data[2] = {SMART_CONTROL_EXTEND_CMD, 0x10 }; - if (BT_ERROR_NONE != bt_hid_send_rc_command(NULL, input_data, sizeof(input_data))) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail bt_hid_send_rc_command"); - } else { - SLOG(LOG_INFO, TAG_VCD, "[Recorder] Extend bt audio recorder"); - } - } - g_bt_extend_count++; - - if (100000 == g_buffer_count) { - g_buffer_count = 0; - } - } + const int MAX_AMPLITUDE_MEAN_16 = 32768; - g_buffer_count++; + int i, depthByte; + int count = 0; -#ifdef BUF_SAVE_MODE - /* write pcm buffer */ - fwrite(voice_data->audio_buf, 1, voice_data->length, g_normal_file); -#endif - return; -} -#endif + float db = 0.0; + float rms = 0.0; + unsigned long long square_sum = 0; + short pcm16 = 0; -#ifdef TV_FFV_MODE -static void _ffv_audio_function_cb(void* data, unsigned int length, void* user_data) -{ - if (0 == g_buffer_count || 0 == g_buffer_count % 50) { - SLOG(LOG_INFO, TAG_VCD, "[Recorder INFO] farfield audio function callback is invoked"); + depthByte = 2; - if (100000 == g_buffer_count) { - g_buffer_count = 0; - } + for (i = 0; i < size; i += (depthByte<<1)) { + pcm16 = 0; + memcpy(&pcm16, data + i, sizeof(short)); + square_sum += pcm16 * pcm16; + count++; } - g_buffer_count++; - - if (0 != strncmp(g_current_audio_type, VCE_AUDIO_ID_FFV, sizeof(VCE_AUDIO_ID_FFV))) { - vcd_state_e state = vcd_config_get_service_state(); - if (VCD_STATE_READY == state) { - vcd_recorder_set(VCE_AUDIO_ID_FFV, VCE_AUDIO_TYPE_PCM_S16_LE, 16000, 1); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] current audio type is (%s)", g_current_audio_type); - return; - } + if (0 == count || 0 == square_sum) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] No data"); + rms = 1.0; + } else { + rms = sqrt((float)square_sum/count); } - if (NULL != g_audio_cb) { - if (0 != g_audio_cb(data, length)) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to read audio"); - vcd_recorder_stop(); - } - } + db = 20 * log10(rms/MAX_AMPLITUDE_MEAN_16); + return db; } -#endif -#if 1 static const char* __get_focus_changed_reason_code(sound_stream_focus_change_reason_e reason) { switch (reason) { @@ -283,7 +134,6 @@ static void __recorder_focus_state_cb(sound_stream_info_h stream_info, sound_str } } } -#endif static int __apply_device_for_stream_routing() { @@ -423,13 +273,7 @@ int vcd_recorder_create(vcd_recoder_audio_cb audio_cb, vcd_recorder_interrupt_cb } } - int ret = 0; - - /* set init value */ - g_is_valid_audio_in = false; - g_is_valid_bt_in = false; - - ret = sound_manager_add_device_connection_changed_cb(SOUND_DEVICE_IO_DIRECTION_IN_MASK, __device_connection_changed_cb, NULL, &g_device_id); + int ret = sound_manager_add_device_connection_changed_cb(SOUND_DEVICE_IO_DIRECTION_IN_MASK, __device_connection_changed_cb, NULL, &g_device_id); if (0 != ret) SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to add device connection changed callback"); @@ -441,74 +285,14 @@ int vcd_recorder_create(vcd_recoder_audio_cb audio_cb, vcd_recorder_interrupt_cb if (0 != dependency_audio_manager_initialize(g_stream_info_h, __feed_audio_data_cb)) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize dependency audio manager"); - g_is_valid_audio_in = false; - } else { - g_is_valid_audio_in = true; + return VCD_ERROR_OPERATION_FAILED; } g_audio_cb = audio_cb; g_interrupt_cb = interrupt_cb; g_recorder_state = VCD_RECORDER_STATE_READY; -#ifdef TV_FFV_MODE - g_farfieldvoice_h = farfield_voice_init(); - if (NULL == g_farfieldvoice_h) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to init farfield_voice_init"); - } -#endif - -#ifdef TV_BT_MODE - bool is_bt_failed = false; - - if (false == is_bt_failed && BT_ERROR_NONE != bt_product_init()) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to init bt"); - is_bt_failed = true; - } - - if (false == is_bt_failed && BT_ERROR_NONE != bt_hid_host_initialize(_bt_cb_hid_state_changed, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail bt_hid_host_initialize()"); - is_bt_failed = true; - } - - if (false == is_bt_failed) { - SLOG(LOG_INFO, TAG_VCD, "[Recorder] Bluetooth is available"); - g_is_valid_bt_in = true; - } -#endif - - /* Select default audio type */ - if (true == g_is_valid_audio_in) { - g_current_audio_type = strdup(VCE_AUDIO_ID_NONE); - } else { - if (true == g_is_valid_bt_in) { - g_current_audio_type = strdup(VCE_AUDIO_ID_BLUETOOTH); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] No valid audio"); - return -1; - } - } - - SLOG(LOG_INFO, TAG_VCD, "[Recorder] Audio type : %s", g_current_audio_type); - - /* Set audio feed callback */ -#ifdef TV_BT_MODE - if (BT_ERROR_NONE != bt_hid_set_audio_data_receive_cb(_bt_hid_audio_data_receive_cb, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail bt_hid_set_audio_data_receive_cb()"); - } -#endif -#ifdef TV_FFV_MODE - if (g_farfieldvoice_h) { - SLOG(LOG_INFO, TAG_VCD, "[Recorder INFO] Register farfield voice audio callback"); - farfield_voice_register_audio_cb(g_farfieldvoice_h, _ffv_audio_function_cb, NULL); - } -#endif -#ifdef TV_MSF_WIFI_MODE - if (MSFResult_OK != RegisterMSFAudioCallback(__msf_wifi_audio_data_receive_cb, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to start Wi-Fi audio"); - } -#endif - - return 0; + return ret; } int vcd_recorder_destroy() @@ -534,32 +318,8 @@ int vcd_recorder_destroy() SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to audio in destroy, ret(%d)", ret); } - -#ifdef TV_MSF_WIFI_MODE - UnRegisterMSFAudioCallback(); -#endif - -#ifdef TV_FFV_MODE - if (NULL != g_farfieldvoice_h) { - SLOG(LOG_INFO, TAG_VCD, "[Recorder INFO] Unregister farfield voice"); - farfield_voice_final(g_farfieldvoice_h); - g_farfieldvoice_h = NULL; - } -#endif - -#ifdef TV_BT_MODE - bt_hid_unset_audio_data_receive_cb(); - bt_hid_host_deinitialize(); - bt_product_deinit(); -#endif - g_audio_cb = NULL; - if (NULL != g_current_audio_type) { - free(g_current_audio_type); - g_current_audio_type = NULL; - } - if (NULL != g_pcm_path) { free(g_pcm_path); g_pcm_path = NULL; @@ -573,68 +333,23 @@ int vcd_recorder_destroy() return VCD_ERROR_NONE; } -static int __set_audio_source_type(const char* audio_source_type) +int vcd_recorder_set(const char* audio_type, vce_audio_type_e type, int rate, int channel) { - if (NULL == audio_source_type) { - SLOG(LOG_INFO, TAG_VCD, "[Recorder] Audio source type is NULL"); + if (NULL == audio_type) { + SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] audio_type is NULL"); return VCD_ERROR_INVALID_PARAMETER; } - if (NULL != g_current_audio_type) { - if (0 == strncmp(g_current_audio_type, audio_source_type, strlen(g_current_audio_type))) { - SLOG(LOG_INFO, TAG_VCD, "[Recorder] Current audio type is already set : %s", audio_source_type); - return VCD_ERROR_NONE; - } - } else { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Recorder is NOT created"); - return VCD_ERROR_INVALID_STATE; - } - - SLOG(LOG_INFO, TAG_VCD, "[Recorder] set audio type (%s)", audio_source_type); - vcd_engine_set_audio_type(audio_source_type); - - // Set new audio source type - if (NULL != g_current_audio_type) { - free(g_current_audio_type); - g_current_audio_type = NULL; - } - - g_current_audio_type = strdup(audio_source_type); + SLOG(LOG_INFO, TAG_VCD, "[Recorder] set audio type (%s)", audio_type); + vcd_engine_set_audio_type(audio_type); - return VCD_ERROR_NONE; -} - -int vcd_recorder_set(const char* audio_type, vce_audio_type_e type, int rate, int channel) -{ int ret = -1; - ret = __set_audio_source_type(audio_type); - if (0 != ret) { - return ret; - } - - /* Check BT audio */ - if (0 == strncmp(VCE_AUDIO_ID_BLUETOOTH, audio_type, strlen(VCE_AUDIO_ID_BLUETOOTH))) { - if (false == g_is_valid_bt_in) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder] BT audio is NOT valid"); - return VCD_ERROR_OPERATION_REJECTED; - } - } else if (0 == strncmp(VCE_AUDIO_ID_WIFI, audio_type, strlen(VCE_AUDIO_ID_WIFI))) { - } else if (0 == strncmp(VCE_AUDIO_ID_FFV, audio_type, strlen(VCE_AUDIO_ID_FFV))) { - } else { - if (false == g_is_valid_audio_in) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Audio-in is NOT valid"); - return VCD_ERROR_OPERATION_REJECTED; - } - } - ret = dependency_audio_manager_set_audio_info(g_stream_info_h, audio_type, type, rate, channel); if (0 != ret) { - g_is_valid_audio_in = false; SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to set audio information"); + return VCD_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, TAG_VCD, "[Recorder] Current audio type is changed : %s", g_current_audio_type); - return VCD_ERROR_NONE; } @@ -653,39 +368,6 @@ int vcd_recorder_get(char** audio_type) return VCD_ERROR_NONE; } -// TODO: make common function? -static float get_volume_decibel(const char* data, const unsigned int size) -{ - const int MAX_AMPLITUDE_MEAN_16 = 32768; - - int i, depthByte; - int count = 0; - - float db = 0.0; - float rms = 0.0; - unsigned long long square_sum = 0; - short pcm16 = 0; - - depthByte = 2; - - for (i = 0; i < size; i += (depthByte<<1)) { - pcm16 = 0; - memcpy(&pcm16, data + i, sizeof(short)); - square_sum += pcm16 * pcm16; - count++; - } - - if (0 == count || 0 == square_sum) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] No data"); - rms = 1.0; - } else { - rms = sqrt((float)square_sum/count); - } - - db = 20 * log10(rms/MAX_AMPLITUDE_MEAN_16); - return db; -} - Eina_Bool __read_test_func(void *data) { if (VCD_RECORDER_STATE_RECORDING != g_recorder_state) { @@ -894,9 +576,6 @@ int vcd_recorder_start() } g_buffer_count = 0; -#ifdef TV_BT_MODE - g_bt_extend_count = 0; -#endif SLOG(LOG_INFO, TAG_VCD, "[Recorder] Enter, recorder state(%d)", g_recorder_state); if (VCD_RECORDER_STATE_RECORDING == g_recorder_state) { -- 2.34.1