+#ifdef TV_MSF_WIFI_MODE
+static void __msf_wifi_audio_data_receive_cb(msf_wifi_voice_data_s *voice_data, void* user_data)
+{
+ if (VCD_RECORDER_STATE_RECORDING != g_recorder_state) {
+ /*SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Exit audio reading normal func");*/
+ return;
+ }
+
+ 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(%d)", 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)
+{
+ if (VCD_RECORDER_STATE_RECORDING != g_recorder_state) {
+ /*SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Exit audio reading normal func");*/
+ return;
+ }
+
+ 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(%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(NULL, %s, %d)", input_data, sizeof(input_data));
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Extend bt audio recorder");
+ }
+ }
+ g_bt_extend_count++;
+
+ 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
+