From 1b73d7b7fae71fbc1b36665b8b7cb8352c13858c Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 2 Nov 2022 11:41:56 +0900 Subject: [PATCH] Enable FFV on TV and Use 2nd channel data in ffv audio callback Change-Id: Idd2514eda85a1896ebd8870a7e5b7e4ab1c77acb Signed-off-by: sooyeon --- server/sttd_recorder.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/server/sttd_recorder.c b/server/sttd_recorder.c index e57d5e8..321e5d6 100644 --- a/server/sttd_recorder.c +++ b/server/sttd_recorder.c @@ -13,7 +13,7 @@ #ifdef TV_PRODUCT #define TV_BT_MODE -//#define TV_FFV_MODE +#define TV_FFV_MODE #endif #include @@ -207,7 +207,15 @@ static void _ffv_audio_function_cb(void* data, unsigned int length, void* user_d g_buffer_count++; if (NULL != g_audio_cb) { - if (0 != g_audio_cb(data, length)) { + unsigned int mono_length = length / 2; + char mono_data[mono_length]; + char* char_data = (char*)data; + int cnt = 0; + while (cnt < mono_length) { + mono_data[cnt] = char_data[cnt * 2 + 1]; // 2nd channel + cnt++; + } + if (0 != g_audio_cb(mono_data, mono_length)) { SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to read audio"); sttd_recorder_stop(); } @@ -217,7 +225,7 @@ static void _ffv_audio_function_cb(void* data, unsigned int length, void* user_d return; } - float vol_db = get_volume_decibel((char*)data, (int)length, g_recorder->audio_type); + float vol_db = get_volume_decibel((char*)mono_data, (int)mono_length, g_recorder->audio_type); if (0 != sttdc_send_set_volume(g_recorder->uid, vol_db)) { SLOG(LOG_ERROR, TAG_STTD, "[Recorder] Fail to send recording volume(%f)", vol_db); } -- 2.7.4