#define KEY_LENGTH 24
#define CAMERA_PRIVILEGE_NAME "http://tizen.org/privilege/camera"
+#define MUSED_KEY_DEVICE_STATE_CHECK "camera_get_device_state_is_called"
+#define MUSED_KEY_DEVICE_STATE_RETURN "camera_get_device_state_return"
+#define MUSED_KEY_FLASH_STATE_CHECK "camera_get_flash_state_is_called"
+#define MUSED_KEY_FLASH_STATE_RETURN "camera_get_flash_state_return"
+#define MUSED_KEY_FLASH_STATE_COUNT "camera_get_flash_state_count"
static int _camera_remove_export_data(muse_module_h module, int key, int remove_all);
{
int ret = CAMERA_ERROR_NONE;
int count = 0;
+ bool is_called = false;
char value_key[KEY_LENGTH] = {'\0',};
camera_h camera = NULL;
camera_device_e device_type = CAMERA_DEVICE_CAMERA0;
return MUSE_CAMERA_ERROR_NONE;
}
- ret = legacy_camera_create(device_type, &camera);
+ muse_core_client_get_value(module, MUSED_KEY_FLASH_STATE_CHECK, (int *)&is_called);
+
+ if (!is_called) {
+ ret = legacy_camera_create(device_type, &camera);
+ if (camera) {
+ legacy_camera_attr_foreach_supported_flash_mode(camera,
+ (camera_attr_supported_flash_mode_cb)_camera_dispatcher_callback_supported_flash_mode2,
+ (void *)&count);
+
+ legacy_camera_destroy(camera);
+ camera = NULL;
+ }
+
+ muse_core_client_set_value(module, MUSED_KEY_FLASH_STATE_RETURN, ret);
+ muse_core_client_set_value(module, MUSED_KEY_FLASH_STATE_COUNT, count);
+ muse_core_client_set_value(module, MUSED_KEY_FLASH_STATE_CHECK, (int)true);
+ } else {
+ muse_core_client_get_value(module, MUSED_KEY_FLASH_STATE_RETURN, &ret);
+ muse_core_client_get_value(module, MUSED_KEY_FLASH_STATE_COUNT, &count);
+ }
+
+ LOGD("is_called %d, ret 0x%x, count %d", is_called, ret, count);
+
if (ret != CAMERA_ERROR_NONE) {
- LOGE("failed to create camera handle 0x%x", ret);
+ LOGE("failed to create or get camera info 0x%x", ret);
muse_camera_msg_return(api, class, ret, module);
return MUSE_CAMERA_ERROR_NONE;
}
- ret = legacy_camera_attr_foreach_supported_flash_mode(camera,
- (camera_attr_supported_flash_mode_cb)_camera_dispatcher_callback_supported_flash_mode2,
- (void *)&count);
-
- legacy_camera_destroy(camera);
- camera = NULL;
-
if (count < 2) {
LOGE("count[%d] of supported flash mode is too small, so return NOT_SUPPORTED", count);
int camera_dispatcher_get_device_state(muse_module_h module)
{
int ret = CAMERA_ERROR_NONE;
+ bool is_called = false;
char value_key[KEY_LENGTH] = {'\0',};
camera_h camera = NULL;
camera_device_e device_type = CAMERA_DEVICE_CAMERA0;
return MUSE_CAMERA_ERROR_NONE;
}
- ret = legacy_camera_create(device_type, &camera);
+ muse_core_client_get_value(module, MUSED_KEY_DEVICE_STATE_CHECK, (int *)&is_called);
+
+ if (!is_called) {
+ ret = legacy_camera_create(device_type, &camera);
+ if (camera) {
+ legacy_camera_destroy(camera);
+ camera = NULL;
+ }
+
+ muse_core_client_set_value(module, MUSED_KEY_DEVICE_STATE_RETURN, ret);
+ muse_core_client_set_value(module, MUSED_KEY_DEVICE_STATE_CHECK, (int)true);
+ } else {
+ muse_core_client_get_value(module, MUSED_KEY_DEVICE_STATE_RETURN, &ret);
+ }
+
+ LOGD("is_called %d, ret 0x%x", is_called, ret);
+
if (ret != CAMERA_ERROR_NONE) {
LOGE("failed to create camera handle 0x%x", ret);
return MUSE_CAMERA_ERROR_NONE;
}
- legacy_camera_destroy(camera);
- camera = NULL;
-
snprintf(value_key, KEY_LENGTH, "device_state_camera%d", device_type);
muse_core_client_get_value(module, value_key, (int *)&get_device_state);
LOGD("device[%d] state : %d", device_type, get_device_state);
muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
- -1, "get_device_state", get_device_state, NULL);
+ -1, "get_device_state", get_device_state, NULL);
return MUSE_CAMERA_ERROR_NONE;
}