From f183b5e0b23f3e3a8631fb69f23f674f846fb6b6 Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Mon, 23 May 2016 13:49:54 +0900 Subject: [PATCH] [Release version 0.10.50] Fix recording commit error when snapshot processing is not done while recording Change-Id: I833bdbbd995c928b3f62bea9bd1043f5497e7d83 Signed-off-by: Jeongmo Yang --- packaging/libmm-camcorder.spec | 2 +- src/include/mm_camcorder_internal.h | 7 ++++++- src/mm_camcorder_internal.c | 3 +++ src/mm_camcorder_stillshot.c | 32 ++++++++++++++++++-------------- src/mm_camcorder_videorec.c | 11 ++++++++++- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index bfa9552..1bcb778 100644 --- a/packaging/libmm-camcorder.spec +++ b/packaging/libmm-camcorder.spec @@ -2,7 +2,7 @@ Name: libmm-camcorder Summary: Camera and recorder library -Version: 0.10.49 +Version: 0.10.50 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/include/mm_camcorder_internal.h b/src/include/mm_camcorder_internal.h index 6e6982b..f542862 100644 --- a/src/include/mm_camcorder_internal.h +++ b/src/include/mm_camcorder_internal.h @@ -330,15 +330,19 @@ extern "C" { #define _MMCAMCORDER_GET_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cond) #define _MMCAMCORDER_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle)) -#define _MMCAMCORDER_WAIT_UNTIL(handle, timeout) g_cond_wait_until(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), &end_time) +#define _MMCAMCORDER_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), end_time) #define _MMCAMCORDER_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_COND(handle)); #define _MMCAMCORDER_BROADCAST(handle) g_cond_broadcast(&_MMCAMCORDER_GET_COND(handle)); /* for command */ #define _MMCAMCORDER_GET_CMD_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock) +#define _MMCAMCORDER_GET_CMD_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_cond) #define _MMCAMCORDER_LOCK_CMD(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle)) #define _MMCAMCORDER_TRYLOCK_CMD(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle)) #define _MMCAMCORDER_UNLOCK_CMD(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle)) +#define _MMCAMCORDER_CMD_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle)) +#define _MMCAMCORDER_CMD_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle), end_time) +#define _MMCAMCORDER_CMD_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_CMD_COND(handle)); /* for ASM */ #define _MMCAMCORDER_GET_ASM_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).asm_lock) @@ -578,6 +582,7 @@ typedef struct { GMutex lock; /**< Mutex (for general use) */ GCond cond; /**< Condition (for general use) */ GMutex cmd_lock; /**< Mutex (for command) */ + GCond cmd_cond; /**< Condition (for command) */ GMutex asm_lock; /**< Mutex (for ASM) */ GMutex state_lock; /**< Mutex (for state change) */ GMutex gst_state_lock; /**< Mutex (for gst pipeline state change) */ diff --git a/src/mm_camcorder_internal.c b/src/mm_camcorder_internal.c index 68bc1fb..895ce61 100644 --- a/src/mm_camcorder_internal.c +++ b/src/mm_camcorder_internal.c @@ -123,6 +123,7 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info) g_mutex_init(&(hcamcorder->mtsafe).lock); g_cond_init(&(hcamcorder->mtsafe).cond); g_mutex_init(&(hcamcorder->mtsafe).cmd_lock); + g_cond_init(&(hcamcorder->mtsafe).cmd_cond); g_mutex_init(&(hcamcorder->mtsafe).asm_lock); g_mutex_init(&(hcamcorder->mtsafe).state_lock); g_mutex_init(&(hcamcorder->mtsafe).gst_state_lock); @@ -545,6 +546,7 @@ _ERR_DEFAULT_VALUE_INIT: g_mutex_clear(&(hcamcorder->mtsafe).lock); g_cond_clear(&(hcamcorder->mtsafe).cond); g_mutex_clear(&(hcamcorder->mtsafe).cmd_lock); + g_cond_clear(&(hcamcorder->mtsafe).cmd_cond); g_mutex_clear(&(hcamcorder->mtsafe).asm_lock); g_mutex_clear(&(hcamcorder->mtsafe).state_lock); g_mutex_clear(&(hcamcorder->mtsafe).gst_state_lock); @@ -740,6 +742,7 @@ int _mmcamcorder_destroy(MMHandleType handle) g_mutex_clear(&(hcamcorder->mtsafe).lock); g_cond_clear(&(hcamcorder->mtsafe).cond); g_mutex_clear(&(hcamcorder->mtsafe).cmd_lock); + g_cond_clear(&(hcamcorder->mtsafe).cmd_cond); g_mutex_clear(&(hcamcorder->mtsafe).asm_lock); g_mutex_clear(&(hcamcorder->mtsafe).state_lock); g_mutex_clear(&(hcamcorder->mtsafe).gst_state_lock); diff --git a/src/mm_camcorder_stillshot.c b/src/mm_camcorder_stillshot.c index 1b7d20b..c713058 100644 --- a/src/mm_camcorder_stillshot.c +++ b/src/mm_camcorder_stillshot.c @@ -1209,20 +1209,6 @@ static void __mmcamcorder_image_capture_cb(GstElement *element, GstSample *sampl } else if (!info->played_capture_sound) { _mmcamcorder_sound_solo_play((MMHandleType)hcamcorder, _MMCAMCORDER_SAMPLE_SOUND_NAME_CAPTURE01, FALSE); } - } else { - /* Handle capture in recording case */ - hcamcorder->capture_in_recording = FALSE; - - g_mutex_lock(&hcamcorder->task_thread_lock); - - if (hcamcorder->task_thread_state == _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING) { - _mmcam_dbg_log("send signal for capture in recording"); - g_cond_signal(&hcamcorder->task_thread_cond); - } else { - _mmcam_dbg_warn("unexpected task thread state : %d", hcamcorder->task_thread_state); - } - - g_mutex_unlock(&hcamcorder->task_thread_lock); } /* init capture data */ @@ -1652,6 +1638,24 @@ error: } } + if (current_state >= MM_CAMCORDER_STATE_RECORDING) { + /* Handle capture in recording case */ + hcamcorder->capture_in_recording = FALSE; + + g_mutex_lock(&hcamcorder->task_thread_lock); + + if (hcamcorder->task_thread_state == _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING) { + _mmcam_dbg_log("send signal for capture in recording"); + g_cond_signal(&hcamcorder->task_thread_cond); + } else { + _mmcam_dbg_warn("unexpected task thread state : %d", hcamcorder->task_thread_state); + } + + g_mutex_unlock(&hcamcorder->task_thread_lock); + + _MMCAMCORDER_CMD_SIGNAL(hcamcorder); + } + _mmcam_dbg_err("END"); return; diff --git a/src/mm_camcorder_videorec.c b/src/mm_camcorder_videorec.c index c70ff38..5bf1f7c 100644 --- a/src/mm_camcorder_videorec.c +++ b/src/mm_camcorder_videorec.c @@ -1033,7 +1033,16 @@ int _mmcamcorder_video_command(MMHandleType handle, int command) } } - usleep(_MMCAMCORDER_FRAME_WAIT_TIME); + if (hcamcorder->capture_in_recording) { + gint64 end_time = g_get_monotonic_time() + (200 * G_TIME_SPAN_MILLISECOND); + if (_MMCAMCORDER_CMD_WAIT_UNTIL(handle, end_time)) { + _mmcam_dbg_warn("signal received"); + } else { + _mmcam_dbg_warn("timeout"); + } + } else { + usleep(_MMCAMCORDER_FRAME_WAIT_TIME); + } } /* block push buffer */ -- 2.7.4