handle->camera_buffers[index].planes[0].bytesused = bytesused;
if (handle->captured_count > 0) {
- g_mutex_lock(&handle->buffer_lock);
if (handle->state != CAMERA_STATE_CAPTURING) {
LOGW("stop continuous capture");
handle->captured_count = handle->capture_count;
- g_mutex_unlock(&handle->buffer_lock);
goto _TRY_NEXT;
}
- g_mutex_unlock(&handle->buffer_lock);
}
if (handle->capture_count > 1) {
goto _TRY_NEXT;
}
- g_mutex_lock(&handle->buffer_lock);
handle->captured_count++;
- g_mutex_unlock(&handle->buffer_lock);
LOGD("capture cb[%p], buffer index[%d],count[%d]",
handle->capture_cb, index, handle->captured_count);
LOGE("qbuf failed for capture[0x%x]", ret);
} while (handle->captured_count < handle->capture_count);
- g_mutex_lock(&handle->buffer_lock);
+ g_mutex_lock(&handle->lock);
if (handle->state == CAMERA_STATE_CAPTURING) {
LOGD("wait for capture stop signal");
- g_cond_wait(&handle->buffer_cond, &handle->buffer_lock);
+ g_cond_wait(&handle->cond, &handle->lock);
LOGD("signal received");
} else {
LOGD("The state is already changed.");
}
- g_mutex_unlock(&handle->buffer_lock);
+ g_mutex_unlock(&handle->lock);
_CAPTURE_DONE:
/* restart stream for preview */
g_mutex_clear(&handle->buffer_lock);
g_mutex_clear(&handle->msg_cb_lock);
g_mutex_clear(&handle->extra_preview_lock);
+ g_cond_clear(&handle->cond);
g_cond_clear(&handle->buffer_cond);
g_cond_clear(&handle->msg_cb_cond);
g_mutex_init(&new_handle->buffer_lock);
g_mutex_init(&new_handle->msg_cb_lock);
g_mutex_init(&new_handle->extra_preview_lock);
+ g_cond_init(&new_handle->cond);
g_cond_init(&new_handle->buffer_cond);
g_cond_init(&new_handle->msg_cb_cond);
return CAMERA_ERROR_INVALID_PARAMETER;
}
+ if (handle->captured_count == 0) {
+ LOGE("No captured image yet.");
+ return CAMERA_ERROR_INTERNAL;
+ }
+
g_mutex_lock(&handle->lock);
if (handle->state != CAMERA_STATE_CAPTURING) {
return CAMERA_ERROR_INVALID_STATE;
}
- g_mutex_lock(&handle->buffer_lock);
-
- if (handle->captured_count == 0) {
- LOGE("No captured image yet.");
- g_mutex_unlock(&handle->buffer_lock);
- g_mutex_unlock(&handle->lock);
- return CAMERA_ERROR_INTERNAL;
- }
+ handle->state = CAMERA_STATE_PREVIEWING;
LOGD("send signal to start preview after capture");
- g_cond_signal(&handle->buffer_cond);
- g_mutex_unlock(&handle->buffer_lock);
-
- handle->state = CAMERA_STATE_PREVIEWING;
+ g_cond_signal(&handle->cond);
g_mutex_unlock(&handle->lock);