From: Jeongmo Yang Date: Wed, 6 Jan 2016 10:14:50 +0000 (+0900) Subject: [Release version 0.2.35] Fix bug - 1. fd leak, 2. does not stop foreach callback... X-Git-Tag: accepted/tizen/mobile/20160107.101154^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46d82b93e8778160a8970c2052e3d5d6443fb956;p=platform%2Fcore%2Fapi%2Fcamera.git [Release version 0.2.35] Fix bug - 1. fd leak, 2. does not stop foreach callback even though callback returns false Change-Id: I9b181a8dc72409eaabb309b8f2f556fbcf0cdf94 Signed-off-by: Jeongmo Yang --- diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index bbe34e4..c7cb1a8 100644 --- a/packaging/capi-media-camera.spec +++ b/packaging/capi-media-camera.spec @@ -3,7 +3,7 @@ Name: capi-media-camera Summary: A Camera API -Version: 0.2.34 +Version: 0.2.35 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/camera.c b/src/camera.c index ea7b6cb..702ec1c 100644 --- a/src/camera.c +++ b/src/camera.c @@ -917,7 +917,11 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus LOGD("SUPPORTED_PREVIEW_RESOLUTION - %d x %d", param1, param2); - ((camera_supported_preview_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]); + if (((camera_supported_preview_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_PREVIEW_RESOLUTION"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION: muse_camera_msg_get(param1, recv_msg); @@ -925,105 +929,165 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus LOGD("SUPPORTED_CAPTURE_RESOLUTION - %d x %d", param1, param2); - ((camera_supported_capture_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]); + if (((camera_supported_capture_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_CAPTURE_RESOLUTION"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_CAPTURE_FORMAT - %d ", param1); - ((camera_supported_capture_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]); + if (((camera_supported_capture_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_CAPTURE_FORMAT"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_PREVIEW_FORMAT - %d ", param1); - ((camera_supported_preview_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]); + if (((camera_supported_preview_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_PREVIEW_FORMAT"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_AF_MODE - %d ", param1); - ((camera_attr_supported_af_mode_cb)cb_info->user_cb[event])((camera_attr_af_mode_e)param1, cb_info->user_data[event]); + if (((camera_attr_supported_af_mode_cb)cb_info->user_cb[event])((camera_attr_af_mode_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_AF_MODE"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_EXPOSURE_MODE - %d ", param1); - ((camera_attr_supported_exposure_mode_cb)cb_info->user_cb[event])((camera_attr_exposure_mode_e)param1, cb_info->user_data[event]); + if (((camera_attr_supported_exposure_mode_cb)cb_info->user_cb[event])((camera_attr_exposure_mode_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_EXPOSURE_MODE"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_ISO - %d ", param1); - ((camera_attr_supported_iso_cb)cb_info->user_cb[event])((camera_attr_iso_e)param1, cb_info->user_data[event]); + if (((camera_attr_supported_iso_cb)cb_info->user_cb[event])((camera_attr_iso_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_ISO"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_WHITEBALANCE - %d ", param1); - ((camera_attr_supported_whitebalance_cb)cb_info->user_cb[event])((camera_attr_whitebalance_e)param1, cb_info->user_data[event]); + if (((camera_attr_supported_whitebalance_cb)cb_info->user_cb[event])((camera_attr_whitebalance_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_WHITEBALANCE"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_EFFECT - %d ", param1); - ((camera_attr_supported_effect_cb)cb_info->user_cb[event])((camera_attr_effect_mode_e)param1, cb_info->user_data[event]); + if (((camera_attr_supported_effect_cb)cb_info->user_cb[event])((camera_attr_effect_mode_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_EFFECT"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_SCENE_MODE - %d ", param1); - ((camera_attr_supported_scene_mode_cb)cb_info->user_cb[event])((camera_attr_scene_mode_e)param1, cb_info->user_data[event]); + if (((camera_attr_supported_scene_mode_cb)cb_info->user_cb[event])((camera_attr_scene_mode_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_SCENE_MODE"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_FLASH_MODE - %d ", param1); - ((camera_attr_supported_flash_mode_cb)cb_info->user_cb[event])((camera_attr_flash_mode_e)param1, cb_info->user_data[event]); + if (((camera_attr_supported_flash_mode_cb)cb_info->user_cb[event])((camera_attr_flash_mode_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_FLASH_MODE"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_FPS - %d ", param1); - ((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]); + if (((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_FPS"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_FPS_BY_RESOLUTION - %d ", param1); - ((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]); + if (((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_FPS_BY_RESOLUTION"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_STREAM_FLIP - %d ", param1); - ((camera_attr_supported_stream_flip_cb)cb_info->user_cb[event])((camera_flip_e)param1, cb_info->user_data[event]); + if (((camera_attr_supported_stream_flip_cb)cb_info->user_cb[event])((camera_flip_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_STREAM_FLIP"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_STREAM_ROTATION - %d ", param1); - ((camera_attr_supported_stream_rotation_cb)cb_info->user_cb[event])((camera_rotation_e)param1, cb_info->user_data[event]); + if (((camera_attr_supported_stream_rotation_cb)cb_info->user_cb[event])((camera_rotation_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_STREAM_ROTATION"); + } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE: muse_camera_msg_get(param1, recv_msg); LOGD("SUPPORTED_THEATER_MODE - %d ", param1); - ((camera_attr_supported_theater_mode_cb)cb_info->user_cb[event])((camera_attr_theater_mode_e)param1, cb_info->user_data[event]); + if (((camera_attr_supported_theater_mode_cb)cb_info->user_cb[event])((camera_attr_theater_mode_e)param1, cb_info->user_data[event]) == false) { + cb_info->user_cb[event] = NULL; + cb_info->user_data[event] = NULL; + LOGD("stop foreach callback for SUPPORTED_THEATER_MODE"); + } break; case MUSE_CAMERA_EVENT_TYPE_CAPTURE: { @@ -1638,6 +1702,11 @@ static void _client_callback_destroy(camera_cb_info_s *cb_info) LOGD("event thread removed"); + if (cb_info->fd > -1) { + muse_core_connection_close(cb_info->fd); + cb_info->fd = -1; + } + if (cb_info->bufmgr) { tbm_bufmgr_deinit(cb_info->bufmgr); cb_info->bufmgr = NULL;