const int FRAME_LENGTH = 160;
const int BUFFER_LENGTH = FRAME_LENGTH * 2;
- if (g_is_recording) {
- unsigned char buffer[BUFFER_LENGTH];
- memset(buffer, '\0', BUFFER_LENGTH);
+ if (!g_is_recording) {
+ VCAM_LOGD("[DEBUG] Recording is finished");
+ return ECORE_CALLBACK_DONE;
+ }
- int read_bytes = audio_in_read(g_audio_h, buffer, BUFFER_LENGTH);
- if (0 > read_bytes) {
- VCAM_LOGW("Fail to read audio : %d", read_bytes);
- return ECORE_CALLBACK_DONE;
- }
+ unsigned char buffer[BUFFER_LENGTH];
+ memset(buffer, '\0', BUFFER_LENGTH);
- // TODO: check return value?
- if (nullptr != g_feed_audio_data) {
- g_feed_audio_data(buffer, read_bytes);
- }
- } else {
- VCAM_LOGD("[DEBUG] Recording is finished");
+ int read_bytes = audio_in_read(g_audio_h, buffer, BUFFER_LENGTH);
+ if (0 > read_bytes) {
+ VCAM_LOGW("Fail to read audio : %d", read_bytes);
return ECORE_CALLBACK_DONE;
}
+ if (nullptr != g_feed_audio_data) {
+ int ret = g_feed_audio_data(buffer, read_bytes);
+ if (VCE_ERROR_NONE != ret) {
+ VCAM_LOGW("[WARN] Fail to feed audio data (%d)", ret);
+ }
+ }
+
return ECORE_CALLBACK_RENEW;
}
if (AUDIO_IO_ERROR_NONE != ret) {
VCAM_LOGE("[ERROR] Fail to set stream info : %d", ret);
audio_in_destroy(g_audio_h);
+ g_audio_h = nullptr;
return VCE_ERROR_OPERATION_FAILED;
}
g_audio_rate = 0;
g_audio_channel = 0;
- return ret;
+ return VCE_ERROR_NONE;
}
int vcd_dependency_set_audio_info(sound_stream_info_h stream_info_h, const char* audio_source_type, vce_audio_type_e type, int rate, int channel)
return VCE_ERROR_INVALID_STATE;
}
+ VCAM_LOGI("[INFO] Set streaming mode (%d)", mode);
g_streaming_mode = mode;
return VCE_ERROR_NONE;
int vcd_dependency_start_recording(void)
{
VCAM_LOGI("");
- int ret = 0;
-
if (nullptr == g_audio_h) {
VCAM_LOGE("[ERROR] Audio in handle is not valid.");
return VCE_ERROR_INVALID_STATE;
}
- ret = audio_in_prepare(g_audio_h);
+ int ret = audio_in_prepare(g_audio_h);
if (AUDIO_IO_ERROR_NONE != ret) {
if (AUDIO_IO_ERROR_SOUND_POLICY == ret) {
VCAM_LOGE("[ERROR] Audio is busy.");
- } else {
- VCAM_LOGE("[ERROR] Fail to start audio : %d", ret);
}
- return ret;
+ VCAM_LOGE("[ERROR] Fail to start audio : %d", ret);
+ return VCE_ERROR_OPERATION_FAILED;
}
g_is_recording = true;
/* Add ecore timer to read audio data */
ecore_main_loop_thread_safe_call_async([](void* data)->void
- {
- ecore_timer_add(0, __recorder_timer_func, NULL);
- }, NULL);
+ {
+ ecore_timer_add(0, __recorder_timer_func, NULL);
+ },
+ NULL);
- return ret;
+ VCAM_LOGI("");
+ return VCE_ERROR_NONE;
}
int vcd_dependency_stop_recording(void)
return VCE_ERROR_OPERATION_FAILED;
}
+ VCAM_LOGI("");
return VCE_ERROR_NONE;
}
\ No newline at end of file