X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=server%2Fsttd_recorder.c;h=6b19499114fd912f62231483ac64bdf41d993178;hb=931382eed914f816618db156bdde73c0fb3a76f8;hp=5c4687b4ab107cbd6eccf4465db387864b23b2d2;hpb=74b613423ff4a4899e22a7518ff2802cb489caac;p=platform%2Fcore%2Fuifw%2Fstt.git diff --git a/server/sttd_recorder.c b/server/sttd_recorder.c index 5c4687b..6b19499 100644 --- a/server/sttd_recorder.c +++ b/server/sttd_recorder.c @@ -156,7 +156,8 @@ const char* __stt_get_focus_changed_reason_code(sound_stream_focus_change_reason } } -void __recorder_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data) +void __recorder_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, + sound_stream_focus_change_reason_e reason, int sound_behavior, const char *extra_info, void *user_data) { SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Focus state changed cb"); @@ -164,18 +165,9 @@ void __recorder_focus_state_cb(sound_stream_info_h stream_info, sound_stream_foc SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Invalid stream info handle"); return; } + SLOG(LOG_WARN, TAG_STTD, "[Recorder] focus state changed to (%d) with reason(%s)", (int)focus_state, __stt_get_focus_changed_reason_code(reason)); - int ret; - sound_stream_focus_state_e state_for_recording; - ret = sound_manager_get_focus_state(g_stream_info_h, NULL, &state_for_recording); - if (SOUND_MANAGER_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to get focus state"); - return; - } - - SLOG(LOG_WARN, TAG_STTD, "[Recorder] focus state changed to (%d) with reason(%s)", (int)state_for_recording, __stt_get_focus_changed_reason_code(reason)); - - if (STTD_RECORDER_STATE_RECORDING == g_recorder_state && SOUND_STREAM_FOCUS_STATE_RELEASED == state_for_recording) { + if (STTD_RECORDER_STATE_RECORDING == g_recorder_state && SOUND_STREAM_FOCUS_STATE_RELEASED == focus_state) { SLOG(LOG_WARN, TAG_STTD, "[Recorder] Focus released as interrupt"); if (NULL != g_interrupt_cb) { g_interrupt_cb(); @@ -438,7 +430,7 @@ static float get_volume_decibel(char* data, int size, stte_audio_type_e type) if (0 == count) rms = 0.0; else - rms = sqrt(square_sum/count); + rms = sqrt((double)square_sum/count); if (depthByte == 2) db = 20 * log10(rms/MAX_AMPLITUDE_MEAN_16); @@ -517,11 +509,11 @@ int sttd_recorder_start(int uid) return STTD_ERROR_INVALID_PARAMETER; } - ret = sound_manager_acquire_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_RECORDING, NULL); + ret = sound_manager_acquire_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_RECORDING, SOUND_BEHAVIOR_NONE, NULL); if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to acquire focus : %d", ret); } else { - ret = audio_in_set_stream_info(g_recorder->audio_h, g_stream_info_h); + ret = audio_in_set_sound_stream_info(g_recorder->audio_h, g_stream_info_h); if (AUDIO_IO_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to set stream info"); } @@ -595,7 +587,7 @@ int sttd_recorder_stop() g_recorder->uid = -1; - int ret; + int ret = -1; #ifndef TV_BT_MODE ret = audio_in_unprepare(g_recorder->audio_h); if (AUDIO_IO_ERROR_NONE != ret) { @@ -615,18 +607,19 @@ int sttd_recorder_stop() usleep(50000); bt_retry++; } else { + SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] bt_hid_rc_stop_sending_voice(): ret(%d)", ret); break; } } if (false == stopped) { - SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to stop bt audio"); - return STTD_ERROR_OPERATION_FAILED; + SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to stop bt audio(%d)", ret); +// return STTD_ERROR_OPERATION_FAILED; } #endif g_recorder_state = STTD_RECORDER_STATE_READY; - ret = sound_manager_release_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_RECORDING, NULL); + ret = sound_manager_release_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_RECORDING, SOUND_BEHAVIOR_NONE, NULL); if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to release focus :%d", ret); }