/*-----------------------------------------------------------------------
| LOCAL VARIABLE DEFINITIONS for internal |
-----------------------------------------------------------------------*/
-#define TIME_STRING_MAX_LEN 64
+#define TIME_STRING_MAX_LEN 64
+#define __MMCAMCORDER_CAPTURE_WAIT_TIMEOUT 5
#define FPUTC_CHECK(x_char, x_file)\
{\
_mmcam_dbg_log("_mmcamcorder_video_prepare_record return 0x%x", ret);
hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_NONE;
break;
+ case _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING:
+ {
+ struct timespec timeout;
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ timeout.tv_sec = tv.tv_sec + __MMCAMCORDER_CAPTURE_WAIT_TIMEOUT;
+ timeout.tv_nsec = tv.tv_usec * 1000;
+
+ _mmcam_dbg_warn("wait for capture data in recording. wait signal...");
+
+ if (!pthread_cond_timedwait(&(hcamcorder->task_thread_cond), &(hcamcorder->task_thread_lock), &timeout)) {
+ _mmcam_dbg_warn("signal received");
+ } else {
+ _MMCamcorderMsgItem message;
+
+ memset(&message, 0x0, sizeof(_MMCamcorderMsgItem));
+
+ _mmcam_dbg_err("capture data wait time out, send error message");
+
+ message.id = MM_MESSAGE_CAMCORDER_ERROR;
+ message.param.code = MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT;
+
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &message);
+
+ hcamcorder->capture_in_recording = FALSE;
+ }
+
+ hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_NONE;
+ }
+ break;
default:
_mmcam_dbg_warn("invalid task thread state %d", hcamcorder->task_thread_state);
hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_EXIT;
{
int size = 0;
int fileformat = 0;
+ int count = 0;
int ret = MM_ERROR_NONE;
double motion_rate = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
char *err_name = NULL;
break;
case _MMCamcorder_CMD_PAUSE:
{
- int count = 0;
-
if (info->b_commiting) {
_mmcam_dbg_warn("now on commiting previous file!!(command : %d)", command);
return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME) {
break;
} else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
- _mmcam_dbg_err("Pause fail, frame count %" G_GUINT64_FORMAT "",
+ _mmcam_dbg_err("Pause fail, frame count %llu",
info->video_frame_count);
return MM_ERROR_CAMCORDER_INVALID_CONDITION;
} else {
- _mmcam_dbg_warn("Waiting for enough video frame, retrial[%d], frame %" G_GUINT64_FORMAT "",
+ _mmcam_dbg_warn("Waiting for enough video frame, retrial[%d], frame %llu",
count, info->video_frame_count);
}
if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME && info->audio_frame_count) {
break;
} else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
- _mmcam_dbg_err("Pause fail, frame count VIDEO[%" G_GUINT64_FORMAT "], AUDIO [%" G_GUINT64_FORMAT "]",
+ _mmcam_dbg_err("Pause fail, frame count VIDEO[%llu], AUDIO [%llu]",
info->video_frame_count, info->audio_frame_count);
return MM_ERROR_CAMCORDER_INVALID_CONDITION;
} else {
- _mmcam_dbg_warn("Waiting for enough frames, retrial [%d], VIDEO[%" G_GUINT64_FORMAT "], AUDIO [%" G_GUINT64_FORMAT "]",
+ _mmcam_dbg_warn("Waiting for enough frames, retrial [%d], VIDEO[%llu], AUDIO [%llu]",
count, info->video_frame_count, info->audio_frame_count);
}
return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
}
+ for (count = 0 ; count <= _MMCAMCORDER_RETRIAL_COUNT ; count++) {
+ /* capturing */
+ if (hcamcorder->capture_in_recording == FALSE) {
+ break;
+ } else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
+ _mmcam_dbg_err("Failed to Wait capture data");
+ hcamcorder->capture_in_recording = FALSE;
+ break;
+ } else {
+ _mmcam_dbg_warn("Waiting for capture data - retrial [%d]", count);
+ }
+
+ usleep(_MMCAMCORDER_FRAME_WAIT_TIME);
+ }
+
/* block push buffer */
info->push_encoding_buffer = PUSH_ENCODING_BUFFER_STOP;
info->video_frame_count = 0;
info->audio_frame_count = 0;
info->filesize = 0;
+ hcamcorder->capture_in_recording = FALSE;
break;
}
case _MMCamcorder_CMD_COMMIT:
{
- int count = 0;
-
if (info->b_commiting) {
_mmcam_dbg_err("now on commiting previous file!!(command : %d)", command);
return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
for (count = 0 ; count <= _MMCAMCORDER_RETRIAL_COUNT ; count++) {
if (sc->audio_disable) {
/* check only video frame */
- if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME) {
+ if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME &&
+ hcamcorder->capture_in_recording == FALSE) {
break;
} else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
- _mmcam_dbg_err("Commit fail, frame count is %" G_GUINT64_FORMAT "",
- info->video_frame_count);
- info->b_commiting = FALSE;
- return MM_ERROR_CAMCORDER_INVALID_CONDITION;
+ _mmcam_dbg_err("Commit fail, frame count is %llu, capturing %d",
+ info->video_frame_count, hcamcorder->capture_in_recording);
+
+ if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME) {
+ _mmcam_dbg_warn("video frames are enough. keep going...");
+ } else {
+ info->b_commiting = FALSE;
+ return MM_ERROR_CAMCORDER_INVALID_CONDITION;
+ }
} else {
- _mmcam_dbg_warn("Waiting for enough video frame, retrial [%d], frame %" G_GUINT64_FORMAT "",
- count, info->video_frame_count);
+ _mmcam_dbg_warn("Waiting for enough video frame, retrial [%d], frame %llu, capturing %d",
+ count, info->video_frame_count, hcamcorder->capture_in_recording);
}
-
- usleep(_MMCAMCORDER_FRAME_WAIT_TIME);
} else {
/* check both of video and audio frame */
- if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME && info->audio_frame_count) {
+ if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME &&
+ info->audio_frame_count &&
+ hcamcorder->capture_in_recording == FALSE) {
break;
} else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
- _mmcam_dbg_err("Commit fail, VIDEO[%" G_GUINT64_FORMAT "], AUDIO [%" G_GUINT64_FORMAT "]",
- info->video_frame_count, info->audio_frame_count);
+ _mmcam_dbg_err("Commit fail, VIDEO[%llu], AUDIO [%llu], capturing %d",
+ info->video_frame_count, info->audio_frame_count, hcamcorder->capture_in_recording);
+
+ if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME && info->audio_frame_count) {
+ _mmcam_dbg_warn("video/audio frames are enough. keep going...");
+ } else {
+ info->b_commiting = FALSE;
+ return MM_ERROR_CAMCORDER_INVALID_CONDITION;
+ }
- info->b_commiting = FALSE;
return MM_ERROR_CAMCORDER_INVALID_CONDITION;
} else {
- _mmcam_dbg_warn("Waiting for enough frames, retrial [%d], VIDEO[%" G_GUINT64_FORMAT "], AUDIO [%" G_GUINT64_FORMAT "]",
- count, info->video_frame_count, info->audio_frame_count);
+ _mmcam_dbg_warn("Waiting for enough frames, retrial [%d], VIDEO[%llu], AUDIO [%llu], capturing %d",
+ count, info->video_frame_count, info->audio_frame_count, hcamcorder->capture_in_recording);
}
-
- usleep(_MMCAMCORDER_FRAME_WAIT_TIME);
}
+
+ usleep(_MMCAMCORDER_FRAME_WAIT_TIME);
}
/* block push buffer */
info->b_commiting = FALSE;
goto _ERR_CAMCORDER_VIDEO_COMMAND;
}
+
+ /* reset flag */
+ hcamcorder->capture_in_recording = FALSE;
}
break;
default: