- switch (code) {
- case SOUND_SESSION_INTERRUPTED_COMPLETED: return "SOUND_SESSION_INTERRUPTED_COMPLETED";
- case SOUND_SESSION_INTERRUPTED_BY_MEDIA: return "SOUND_SESSION_INTERRUPTED_BY_MEDIA";
- case SOUND_SESSION_INTERRUPTED_BY_CALL: return "SOUND_SESSION_INTERRUPTED_BY_CALL";
- case SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG: return "SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG";
- case SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT: return "SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT";
- case SOUND_SESSION_INTERRUPTED_BY_ALARM: return "SOUND_SESSION_INTERRUPTED_BY_ALARM";
- case SOUND_SESSION_INTERRUPTED_BY_EMERGENCY: return "SOUND_SESSION_INTERRUPTED_BY_EMERGENCY";
- case SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION: return "SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION";
- default:
- return "Undefined error code";
+ SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Bluetooth Event [%d] Received address [%s]", result, remote_address);
+}
+
+static void _bt_hid_audio_data_receive_cb(bt_hid_voice_data_s *voice_data, void *user_data)
+{
+ if (STTD_RECORDER_STATE_RECORDING != g_recorder_state) {
+ /* SLOG(LOG_DEBUG, TAG_STTD, "[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_STTD, "[Recorder ERROR] Fail to read audio");
+ sttd_recorder_stop();
+ }
+
+ if (NULL == g_recorder) {
+ return;
+ }
+
+ float vol_db = get_volume_decibel((char*)voice_data->audio_buf, (int)voice_data->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);
+ }