Request to extend audio feeding time from BT 87/287787/2
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 6 Feb 2023 06:11:56 +0000 (15:11 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Mon, 6 Feb 2023 07:04:35 +0000 (16:04 +0900)
- Issue:
Recording from BT is blocked 15 sec. after recording begins.

- Solution:
By the policy of BT mic, the recording is blocked 15 sec. after begins.
It is because to save the battery of BT remote controller.
To resolve this issue, this patch adds API invocation to request extend
BT audio feeding. Every invocation, this API extends the recording time
by 5 sec. Through this change, BT mic will send the voice until
recording stop.

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

index fcf688be63b4df95b921d063df98c8d8e9baf4fa..288c5002b082a6927821417b5daf46ea0b16dea2 100644 (file)
@@ -48,6 +48,8 @@ static pthread_mutex_t sttd_audio_in_handle_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 #ifndef TV_BT_MODE
 static Ecore_Timer* g_audio_timer = NULL;
+#else
+static Ecore_Timer* g_extend_sending_voice_timer = NULL;
 #endif
 
 typedef enum {
@@ -237,7 +239,7 @@ const char* __stt_get_focus_changed_reason_code(sound_stream_focus_change_reason
        }
 }
 
-void __recorder_focus_state_watch_cb(int id, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, 
+void __recorder_focus_state_watch_cb(int id, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state,
                                                sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data)
 {
        SLOG(LOG_WARN, TAG_STTD, "[Recorder] focus_state_watch_cb is called, focus_state(%d), reason(%s)", (int)focus_state, __stt_get_focus_changed_reason_code(reason));
@@ -600,6 +602,21 @@ Eina_Bool __read_audio_func(void *data)
 }
 #endif
 
+#ifdef TV_BT_MODE
+static Eina_Bool extend_sending_voice_by_ecore_timer(void *user_data)
+{
+       if (STTD_RECORDER_STATE_RECORDING != g_recorder_state) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder] Current state is not recording");
+               g_extend_sending_voice_timer = NULL;
+               return EINA_FALSE;
+       }
+
+       bt_hid_rc_extend_sending_voice(NULL);
+       SLOG(LOG_INFO, TAG_STTD, "[Recorder] Extend sending voice every 5 Sec");
+       return EINA_TRUE;
+}
+#endif
+
 int sttd_recorder_start(int uid)
 {
        if (STTD_RECORDER_STATE_RECORDING == g_recorder_state)
@@ -635,6 +652,8 @@ int sttd_recorder_start(int uid)
                SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Fail to create timer of read_audio");
                return STTD_ERROR_OPERATION_FAILED;
        }
+#else
+       g_extend_sending_voice_timer = ecore_timer_add(5.0, extend_sending_voice_by_ecore_timer, NULL);
 #endif
 
        g_recorder_state = STTD_RECORDER_STATE_RECORDING;
@@ -675,6 +694,16 @@ int sttd_recorder_start(int uid)
        return 0;
 }
 
+#ifdef TV_BT_MODE
+static void delete_extend_sending_voice_timer_in_main_loop(void *data)
+{
+       if (NULL != g_extend_sending_voice_timer) {
+               ecore_timer_del(g_extend_sending_voice_timer);
+               g_extend_sending_voice_timer = NULL;
+       }
+}
+#endif
+
 int sttd_recorder_stop()
 {
        if (STTD_RECORDER_STATE_READY == g_recorder_state)
@@ -708,6 +737,8 @@ int sttd_recorder_stop()
                SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to unprepare audioin : %d", ret);
        }
 #else
+       ecore_main_loop_thread_safe_call_async(delete_extend_sending_voice_timer_in_main_loop, NULL);
+
        int bt_retry = 0;
        bool stopped = false;
        while (5 > bt_retry) {