From ff3b2e6b89272ae0253c596dd9e650269af5498a Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Thu, 2 Feb 2017 16:34:52 +0900 Subject: [PATCH] Add error handling for disconnection from resource manager [Version] 0.10.106 [Profile] Common [Issue Type] Update [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-3.0-mobile_20170131.2] Change-Id: I710a72b9e3900c49513379f22bd566c5f38444b6 Signed-off-by: Jeongmo Yang --- packaging/libmm-camcorder.spec | 2 +- src/mm_camcorder_resource.c | 29 ++++++++++++++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index fe268f1..2a8b1a2 100644 --- a/packaging/libmm-camcorder.spec +++ b/packaging/libmm-camcorder.spec @@ -1,6 +1,6 @@ Name: libmm-camcorder Summary: Camera and recorder library -Version: 0.10.105 +Version: 0.10.106 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/mm_camcorder_resource.c b/src/mm_camcorder_resource.c index bf4e063..f472296 100644 --- a/src/mm_camcorder_resource.c +++ b/src/mm_camcorder_resource.c @@ -81,16 +81,12 @@ static void __mmcamcorder_resource_state_callback(mrp_res_context_t *context, mr mrp_res_resource_t *resource; mmf_camcorder_t* camcorder = NULL; - if (err != MRP_RES_ERROR_NONE) { - _mmcam_dbg_err(" - error message received from Murphy, err(0x%x)", err); - return; - } - camcorder = (mmf_camcorder_t*)user_data; mmf_return_if_fail((MMHandleType)camcorder); + mmf_return_if_fail(context); - _mmcam_dbg_log("enter"); + _mmcam_dbg_log("enter - state %d", context->state); _MMCAMCORDER_LOCK_RESOURCE(camcorder); @@ -116,16 +112,31 @@ static void __mmcamcorder_resource_state_callback(mrp_res_context_t *context, mr _MMCAMCORDER_RESOURCE_SIGNAL(camcorder); break; case MRP_RES_DISCONNECTED: - _mmcam_dbg_log(" - disconnected from Murphy"); + _mmcam_dbg_err(" - disconnected from Murphy : stop camera"); + if (camcorder->resource_manager.rset) { mrp_res_delete_resource_set(camcorder->resource_manager.rset); camcorder->resource_manager.rset = NULL; } + if (camcorder->resource_manager.context) { mrp_res_destroy(camcorder->resource_manager.context); camcorder->resource_manager.context = NULL; camcorder->resource_manager.is_connected = FALSE; } + + _MMCAMCORDER_LOCK_ASM(camcorder); + + /* set value to inform a status is changed by resource manaer */ + camcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_RM; + + /* Stop the camera */ + __mmcamcorder_force_stop(camcorder); + + /* restore value */ + camcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL; + + _MMCAMCORDER_UNLOCK_ASM(camcorder); break; } @@ -220,11 +231,11 @@ static void __mmcamcorder_resource_release_cb(mrp_res_context_t *cx, const mrp_r return; } + _MMCAMCORDER_LOCK_ASM(camcorder); + /* set value to inform a status is changed by resource manaer */ camcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_RM; - _MMCAMCORDER_LOCK_ASM(camcorder); - if (!mrp_res_equal_resource_set(rs, camcorder->resource_manager.rset)) { _MMCAMCORDER_UNLOCK_ASM(camcorder); _mmcam_dbg_warn("- resource set(%p) is not same as this camcorder handle's(%p)", rs, camcorder->resource_manager.rset); -- 2.7.4