Enable FFV on TV and Use 2nd channel data in ffv audio callback 00/283700/2
authorsooyeon <sooyeon.kim@samsung.com>
Wed, 2 Nov 2022 02:41:56 +0000 (11:41 +0900)
committersooyeon <sooyeon.kim@samsung.com>
Wed, 2 Nov 2022 04:42:08 +0000 (13:42 +0900)
Change-Id: Idd2514eda85a1896ebd8870a7e5b7e4ab1c77acb
Signed-off-by: sooyeon <sooyeon.kim@samsung.com>
server/sttd_recorder.c

index e57d5e8..321e5d6 100644 (file)
@@ -13,7 +13,7 @@
 
 #ifdef TV_PRODUCT
 #define TV_BT_MODE
-//#define TV_FFV_MODE
+#define TV_FFV_MODE
 #endif
 
 #include <audio_io.h>
@@ -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);
                }