AC_SUBST(MM_COMMON_CFLAGS)
AC_SUBST(MM_COMMON_LIBS)
-AC_ARG_ENABLE(murphy, AC_HELP_STRING([--enable-murphy], [enable murphy]),
+AC_ARG_ENABLE(mm-resource-manager, AC_HELP_STRING([--enable-mm-resource-manager], [enable mm-resource-manager]),
[
case "${enableval}" in
- yes) MURPHY_SUPPORT=yes ;;
- no) MURPHY_SUPPORT=no ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-murphy) ;;
+ yes) MM_RESOURCE_MANAGER_SUPPORT=yes ;;
+ no) MM_RESOURCE_MANAGER_SUPPORT=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-mm-resource-manager) ;;
esac
-],[MURPHY_SUPPORT=no])
-if test "x$MURPHY_SUPPORT" = "xyes"; then
-PKG_CHECK_MODULES(MURPHY_RESOURCE, murphy-resource)
-AC_SUBST(MURPHY_RESOURCE_CFLAGS)
-AC_SUBST(MURPHY_RESOURCE_LIBS)
-PKG_CHECK_MODULES(MURPHY_GLIB, murphy-glib)
-AC_SUBST(MURPHY_GLIB_CFLAGS)
-AC_SUBST(MURPHY_GLIB_LIBS)
+],[MM_RESOURCE_MANAGER_SUPPORT=no])
+if test "x$MM_RESOURCE_MANAGER_SUPPORT" = "xyes"; then
+PKG_CHECK_MODULES(MM_RESOURCE_MANAGER, mm-resource-manager)
+AC_SUBST(MM_RESOURCE_MANAGER_CFLAGS)
+AC_SUBST(MM_RESOURCE_MANAGER_LIBS)
fi
-AM_CONDITIONAL([MURPHY_SUPPORT], [test "x$MURPHY_SUPPORT" = "xyes"])
+AM_CONDITIONAL([MM_RESOURCE_MANAGER_SUPPORT], [test "x$MM_RESOURCE_MANAGER_SUPPORT" = "xyes"])
PKG_CHECK_MODULES(MM_SOUND, mm-sound)
AC_SUBST(MM_SOUND_CFLAGS)
Name: libmm-camcorder
Summary: Camera and recorder library
-Version: 0.10.143
+Version: 0.10.144
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0
BuildRequires: pkgconfig(libtbm)
BuildRequires: pkgconfig(storage)
%if "%{TIZEN_PRODUCT_TV}" != "1"
-BuildRequires: pkgconfig(murphy-resource)
-BuildRequires: pkgconfig(murphy-glib)
+BuildRequires: pkgconfig(mm-resource-manager)
%else
BuildRequires: pkgconfig(tv-resource-manager)
BuildRequires: pkgconfig(aul)
./autogen.sh
%configure \
%if "%{TIZEN_PRODUCT_TV}" != "1"
- --enable-murphy \
+ --enable-mm-resource-manager \
%else
--enable-rm \
--enable-product-tv \
include/mm_camcorder_util.h \
include/mm_camcorder_exifinfo.h \
include/mm_camcorder_exifdef.h \
- include/mm_camcorder_sound.h \
- include/mm_camcorder_resource.h
+ include/mm_camcorder_sound.h
libmmfcamcorder_la_SOURCES = mm_camcorder.c \
mm_camcorder_internal.c \
libmmfcamcorder_la_LDFLAGS = -Wl,--gc-sections
libmmfcamcorder_la_LIBADD += $(SYSTEMINFO_LIBS)
-if MURPHY_SUPPORT
-libmmfcamcorder_la_SOURCES += mm_camcorder_resource.c
-libmmfcamcorder_la_CFLAGS += $(MURPHY_RESOURCE_CFLAGS) $(MURPHY_GLIB_CFLAGS) -D_MMCAMCORDER_MURPHY_SUPPORT
-libmmfcamcorder_la_LIBADD += $(MURPHY_RESOURCE_LIBS) $(MURPHY_GLIB_LIBS)
+if MM_RESOURCE_MANAGER_SUPPORT
+libmmfcamcorder_la_CFLAGS += $(MM_RESOURCE_MANAGER_CFLAGS) -D_MMCAMCORDER_MM_RM_SUPPORT
+libmmfcamcorder_la_LIBADD += $(MM_RESOURCE_MANAGER_LIBS)
endif
if RM_SUPPORT
#include "mm_camcorder.h"
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
-#include "mm_camcorder_resource.h"
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+#include <mm_resource_manager.h>
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
/* camcorder sub module */
#include "mm_camcorder_attribute.h"
#define _MMCAMCORDER_TRYLOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
#define _MMCAMCORDER_UNLOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
/* for resource conflict */
#define _MMCAMCORDER_GET_RESOURCE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_lock)
-#define _MMCAMCORDER_GET_RESOURCE_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_cond)
#define _MMCAMCORDER_LOCK_RESOURCE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
-#define _MMCAMCORDER_TRYLOCK_RESOURCE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
#define _MMCAMCORDER_UNLOCK_RESOURCE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
-#define _MMCAMCORDER_RESOURCE_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_RESOURCE_COND(handle), &_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
-#define _MMCAMCORDER_RESOURCE_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_RESOURCE_COND(handle), &_MMCAMCORDER_GET_RESOURCE_LOCK(handle), end_time)
-#define _MMCAMCORDER_RESOURCE_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_RESOURCE_COND(handle));
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
/**
* Caster of main handle (camcorder)
GMutex vstream_cb_lock; /**< Mutex (for video stream callback) */
GMutex astream_cb_lock; /**< Mutex (for audio stream callback) */
GMutex mstream_cb_lock; /**< Mutex (for muxed stream callback) */
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- GCond resource_cond; /**< Condition (for resource check) */
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
GMutex resource_lock; /**< Mutex (for resource check) */
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
} _MMCamcorderMTSafe;
/**
GCond task_thread_cond; /**< cond for task thread */
_MMCamcorderTaskThreadState task_thread_state; /**< state of task thread */
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
/* resource manager for H/W resources */
- MMCamcorderResourceManager resource_manager;
- MMCamcorderResourceManager resource_manager_sub;
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+ mm_resource_manager_h resource_manager;
+ mm_resource_manager_res_h camera_resource;
+ mm_resource_manager_res_h video_overlay_resource;
+ mm_resource_manager_res_h video_encoder_resource;
+ gboolean is_release_cb_calling;
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
/* gdbus */
GDBusConnection *gdbus_conn; /**< gdbus connection */
+++ /dev/null
-/*
- * libmm-camcorder
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Heechul Jeon <heechul.jeon@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_CAMCORDER_RESOURCE_H__
-#define __MM_CAMCORDER_RESOURCE_H__
-
-#include <murphy/plugins/resource-native/libmurphy-resource/resource-api.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define __MMCAMCORDER_RESOURCE_WAIT_TIME 3
-
-typedef enum {
- MM_CAMCORDER_RESOURCE_TYPE_CAMERA,
- MM_CAMCORDER_RESOURCE_TYPE_VIDEO_OVERLAY,
- MM_CAMCORDER_RESOURCE_TYPE_VIDEO_ENCODER,
- MM_CAMCORDER_RESOURCE_MAX
-} MMCamcorderResourceType;
-
-typedef enum {
- MM_CAMCORDER_RESOURCE_ID_MAIN,
- MM_CAMCORDER_RESOURCE_ID_SUB
-} MMCamcorderResourceID;
-
-typedef struct {
- MMCamcorderResourceID id;
- mrp_mainloop_t *mloop;
- mrp_res_context_t *context;
- mrp_res_resource_set_t *rset;
- gboolean is_connected;
- gboolean is_release_cb_calling;
- int acquire_count;
- int acquire_remain;
- void *hcamcorder;
-} MMCamcorderResourceManager;
-
-int _mmcamcorder_resource_manager_init(MMCamcorderResourceManager *resource_manager);
-int _mmcamcorder_resource_wait_for_connection(MMCamcorderResourceManager *resource_manager);
-int _mmcamcorder_resource_check_connection(MMCamcorderResourceManager *resource_manager);
-int _mmcamcorder_resource_create_resource_set(MMCamcorderResourceManager *resource_manager);
-int _mmcamcorder_resource_manager_prepare(MMCamcorderResourceManager *resource_manager, MMCamcorderResourceType resource_type);
-int _mmcamcorder_resource_manager_acquire(MMCamcorderResourceManager *resource_manager);
-int _mmcamcorder_resource_manager_release(MMCamcorderResourceManager *resource_manager);
-int _mmcamcorder_resource_manager_deinit(MMCamcorderResourceManager *resource_manager);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MM_PLAYER_RESOURCE_H__ */
#include <system_info.h>
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
-#include <murphy/common/glib-glue.h>
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
-
#ifdef _MMCAMCORDER_RM_SUPPORT
#include <aul.h>
#endif /* _MMCAMCORDER_RM_SUPPORT */
static gboolean __mmcamcorder_handle_gst_warning(MMHandleType handle, GstMessage *message, GError *error);
static int __mmcamcorder_simulate_asm_conflict_table(int session_type, int pid);
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+static int __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
+ mm_resource_manager_res_h res, void *user_data);
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
+
#ifdef _MMCAMCORDER_RM_SUPPORT
rm_cb_result _mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
rm_device_request_s *info, void *cb_data);
g_mutex_init(&(hcamcorder->mtsafe).vstream_cb_lock);
g_mutex_init(&(hcamcorder->mtsafe).astream_cb_lock);
g_mutex_init(&(hcamcorder->mtsafe).mstream_cb_lock);
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- g_cond_init(&(hcamcorder->mtsafe).resource_cond);
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
g_mutex_init(&(hcamcorder->mtsafe).resource_lock);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
g_mutex_init(&hcamcorder->restart_preview_lock);
_mmcam_dbg_log("DPM camera changed cb id %d", hcamcorder->dpm_camera_cb_id);
}
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- /* set camcorder handle */
- hcamcorder->resource_manager.id = MM_CAMCORDER_RESOURCE_ID_MAIN;
- hcamcorder->resource_manager.hcamcorder = hcamcorder;
- hcamcorder->resource_manager_sub.id = MM_CAMCORDER_RESOURCE_ID_SUB;
- hcamcorder->resource_manager_sub.hcamcorder = hcamcorder;
-
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
/* initialize resource manager */
- ret = _mmcamcorder_resource_manager_init(&hcamcorder->resource_manager);
- if (ret != MM_ERROR_NONE) {
+ ret = mm_resource_manager_create(MM_RESOURCE_MANAGER_APP_CLASS_MEDIA,
+ __mmcamcorder_resource_release_cb, hcamcorder,
+ &hcamcorder->resource_manager);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
_mmcam_dbg_err("failed to initialize resource manager");
ret = MM_ERROR_CAMCORDER_INTERNAL;
goto _ERR_DEFAULT_VALUE_INIT;
}
-#ifdef _MMCAMCORDER_INIT_RESOURCE_MANAGER_SUB
- ret = _mmcamcorder_resource_manager_init(&hcamcorder->resource_manager_sub);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to initialize resource manager sub");
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
-#endif
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
} else {
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
_mmcam_dbg_warn("software version [%s], ret 0x%x",
hcamcorder->software_version ? hcamcorder->software_version : "NULL", sys_info_ret);
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- if (info->videodev_type != MM_VIDEO_DEVICE_NONE) {
- ret = _mmcamcorder_resource_wait_for_connection(&hcamcorder->resource_manager);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to connect resource manager");
- goto _ERR_DEFAULT_VALUE_INIT;
- }
-#ifdef _MMCAMCORDER_INIT_RESOURCE_MANAGER_SUB
- ret = _mmcamcorder_resource_wait_for_connection(&hcamcorder->resource_manager_sub);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to connect resource manager");
- goto _ERR_DEFAULT_VALUE_INIT;
- }
-#endif
- }
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
-
/* Set initial state */
_mmcamcorder_set_state((MMHandleType)hcamcorder, MM_CAMCORDER_STATE_NULL);
return MM_ERROR_NONE;
_ERR_DEFAULT_VALUE_INIT:
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
/* de-initialize resource manager */
-#ifdef _MMCAMCORDER_INIT_RESOURCE_MANAGER_SUB
- _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager_sub);
-#endif
- _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+ if (hcamcorder->resource_manager != NULL)
+ mm_resource_manager_destroy(hcamcorder->resource_manager);
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
/* release DPM related handle */
if (hcamcorder->dpm_handle) {
g_mutex_clear(&(hcamcorder->mtsafe).vstream_cb_lock);
g_mutex_clear(&(hcamcorder->mtsafe).astream_cb_lock);
g_mutex_clear(&(hcamcorder->mtsafe).mstream_cb_lock);
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- g_cond_clear(&(hcamcorder->mtsafe).resource_cond);
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
g_mutex_clear(&(hcamcorder->mtsafe).resource_lock);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
g_mutex_clear(&hcamcorder->snd_info.open_mutex);
g_cond_clear(&hcamcorder->snd_info.open_cond);
hcamcorder->sub_context = NULL;
}
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
/* de-initialize resource manager */
_MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
- ret = _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager);
- if (ret != MM_ERROR_NONE)
- _mmcam_dbg_err("failed to de-initialize resource manager 0x%x", ret);
-
- ret = _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager_sub);
- if (ret != MM_ERROR_NONE)
- _mmcam_dbg_err("failed to de-initialize resource manager sub 0x%x", ret);
+ if (hcamcorder->resource_manager != NULL) {
+ ret = mm_resource_manager_destroy(hcamcorder->resource_manager);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE)
+ _mmcam_dbg_err("failed to de-initialize resource manager 0x%x", ret);
+ }
_MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
/* Remove idle function which is not called yet */
if (hcamcorder->setting_event_id) {
g_mutex_clear(&(hcamcorder->mtsafe).vstream_cb_lock);
g_mutex_clear(&(hcamcorder->mtsafe).astream_cb_lock);
g_mutex_clear(&(hcamcorder->mtsafe).mstream_cb_lock);
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- g_cond_clear(&(hcamcorder->mtsafe).resource_cond);
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
g_mutex_clear(&(hcamcorder->mtsafe).resource_lock);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
g_mutex_clear(&hcamcorder->snd_info.open_mutex);
g_cond_clear(&hcamcorder->snd_info.open_cond);
_mmcam_dbg_warn("NULL dpm_handle");
}
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- /* check connection */
- ret = _mmcamcorder_resource_check_connection(&hcamcorder->resource_manager);
- if (ret != MM_ERROR_NONE)
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
-
- /* create resource set */
- ret = _mmcamcorder_resource_create_resource_set(&hcamcorder->resource_manager);
- if (ret != MM_ERROR_NONE)
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
-
- hcamcorder->resource_manager.acquire_count = 0;
-
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
/* prepare resource manager for camera */
- ret = _mmcamcorder_resource_manager_prepare(&hcamcorder->resource_manager, MM_CAMCORDER_RESOURCE_TYPE_CAMERA);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("could not prepare for camera resource");
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ if (hcamcorder->camera_resource == NULL) {
+ ret = mm_resource_manager_mark_for_acquire(hcamcorder->resource_manager,
+ MM_RESOURCE_MANAGER_RES_TYPE_CAMERA,
+ MM_RESOURCE_MANAGER_RES_VOLUME_FULL,
+ &hcamcorder->camera_resource);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ _mmcam_dbg_err("could not prepare for camera resource");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+ } else {
+ _mmcam_dbg_log("camera already acquired");
}
/* prepare resource manager for "video_overlay only if display surface is X" */
if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
- ret = _mmcamcorder_resource_manager_prepare(&hcamcorder->resource_manager, MM_CAMCORDER_RESOURCE_TYPE_VIDEO_OVERLAY);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("could not prepare for video overlay resource");
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ if (hcamcorder->video_overlay_resource == NULL) {
+ ret = mm_resource_manager_mark_for_acquire(hcamcorder->resource_manager,
+ MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_OVERLAY,
+ MM_RESOURCE_MANAGER_RES_VOLUME_FULL,
+ &hcamcorder->video_overlay_resource);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ _mmcam_dbg_err("could not prepare for overlay resource");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+ } else {
+ _mmcam_dbg_log("overlay already acquired");
}
}
/* acquire resources */
- _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-
- ret = _mmcamcorder_resource_manager_acquire(&hcamcorder->resource_manager);
- if (ret != MM_ERROR_NONE) {
+ ret = mm_resource_manager_commit(hcamcorder->resource_manager);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
_MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
_mmcam_dbg_err("could not acquire resources");
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
-
- if (hcamcorder->resource_manager.acquire_remain > 0) {
- gint64 end_time = 0;
-
- _mmcam_dbg_warn("wait for resource state change");
-
- /* wait for resource state change */
- end_time = g_get_monotonic_time() + (__MMCAMCORDER_RESOURCE_WAIT_TIME * G_TIME_SPAN_SECOND);
-
- if (_MMCAMCORDER_RESOURCE_WAIT_UNTIL(hcamcorder, end_time)) {
- _mmcam_dbg_warn("signal received");
- } else {
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
- _mmcam_dbg_err("timeout");
- ret = MM_ERROR_RESOURCE_INTERNAL;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
- } else {
- _mmcam_dbg_log("already all acquired");
- }
-
_MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
#ifdef _MMCAMCORDER_RM_SUPPORT
mm_camcorder_get_attributes(handle, NULL,
return MM_ERROR_NONE;
_ERR_CAMCORDER_CMD:
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
/* release hw resources */
- if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE)
- _mmcamcorder_resource_manager_release(&hcamcorder->resource_manager);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+ if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
+ if (hcamcorder->camera_resource != NULL) {
+ mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
+ hcamcorder->camera_resource);
+ hcamcorder->camera_resource = NULL;
+ }
+ if (hcamcorder->video_overlay_resource != NULL) {
+ mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
+ hcamcorder->video_overlay_resource);
+ hcamcorder->video_overlay_resource = NULL;
+ }
+ mm_resource_manager_commit(hcamcorder->resource_manager);
+ }
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
#ifdef _MMCAMCORDER_RM_SUPPORT
if (hcamcorder->rm_handle) {
if (hcamcorder->returned_devices.allocated_num > 0) {
hcamcorder->sub_context = NULL;
}
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- _mmcam_dbg_warn("lock resource - cb calling %d", hcamcorder->resource_manager.is_release_cb_calling);
-
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
_MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+ _mmcam_dbg_warn("lock resource - cb calling %d", hcamcorder->is_release_cb_calling);
if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE &&
hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_RM &&
- hcamcorder->resource_manager.is_release_cb_calling == FALSE) {
- gint64 end_time = 0;
+ hcamcorder->is_release_cb_calling == FALSE) {
/* release resource */
- ret = _mmcamcorder_resource_manager_release(&hcamcorder->resource_manager);
- if (ret == MM_ERROR_RESOURCE_INVALID_STATE) {
- _mmcam_dbg_warn("it could be in the middle of resource callback or there's no acquired resource");
- ret = MM_ERROR_NONE;
- } else if (ret != MM_ERROR_NONE) {
+ if (hcamcorder->camera_resource != NULL) {
+ ret = mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
+ hcamcorder->camera_resource);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ _mmcam_dbg_err("could not mark camera resource for release");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+ _mmcam_dbg_log("unlock resource");
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+ }
+
+ if (hcamcorder->video_overlay_resource != NULL) {
+ ret = mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
+ hcamcorder->video_overlay_resource);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ _mmcam_dbg_err("could not mark overlay resource for release");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+ _mmcam_dbg_log("unlock resource");
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+ }
+
+ ret = mm_resource_manager_commit(hcamcorder->resource_manager);
+
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
_mmcam_dbg_err("failed to release resource, ret(0x%x)", ret);
ret = MM_ERROR_CAMCORDER_INTERNAL;
_mmcam_dbg_log("unlock resource");
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
-
- if (hcamcorder->resource_manager.acquire_remain < hcamcorder->resource_manager.acquire_count) {
- /* wait for resource release */
- _mmcam_dbg_log("resource is not released all. wait for signal...");
-
- end_time = g_get_monotonic_time() + (__MMCAMCORDER_RESOURCE_WAIT_TIME * G_TIME_SPAN_SECOND);
-
- _MMCAMCORDER_RESOURCE_WAIT_UNTIL(hcamcorder, end_time);
+ } else {
+ if (hcamcorder->camera_resource != NULL)
+ hcamcorder->camera_resource = NULL;
+ if (hcamcorder->video_overlay_resource != NULL)
+ hcamcorder->video_overlay_resource = NULL;
}
}
_MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
_mmcam_dbg_warn("unlock resource");
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
#ifdef _MMCAMCORDER_RM_SUPPORT
if (hcamcorder->rm_handle && (hcamcorder->returned_devices.allocated_num > 0)) {
}
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+static int __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
+ mm_resource_manager_res_h res, void *user_data)
+{
+ mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *) user_data;
+
+ mmf_return_val_if_fail(hcamcorder, FALSE);
+
+ _mmcam_dbg_warn("enter");
+
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+
+ /* set flag for resource release callback */
+ hcamcorder->is_release_cb_calling = TRUE;
+
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+
+ _MMCAMCORDER_LOCK_ASM(hcamcorder);
+
+ if (res == hcamcorder->video_encoder_resource) {
+ /* Stop video recording */
+ if (_mmcamcorder_commit((MMHandleType)hcamcorder) != MM_ERROR_NONE) {
+ _mmcam_dbg_err("commit failed, cancel it");
+ _mmcamcorder_cancel((MMHandleType)hcamcorder);
+ }
+ } else {
+ /* Stop camera */
+ __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_RM);
+ }
+
+ _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+
+ if (res == hcamcorder->camera_resource)
+ hcamcorder->camera_resource = NULL;
+ else if (res == hcamcorder->video_overlay_resource)
+ hcamcorder->video_overlay_resource = NULL;
+ else if (res == hcamcorder->video_encoder_resource)
+ hcamcorder->video_encoder_resource = NULL;
+
+ /* restore flag for resource release callback */
+ hcamcorder->is_release_cb_calling = FALSE;
+
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+
+ _mmcam_dbg_warn("leave");
+
+ return FALSE;
+}
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
+
+
#ifdef _MMCAMCORDER_RM_SUPPORT
rm_cb_result _mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
rm_device_request_s *info, void* cb_data)
+++ /dev/null
-/*
- * libmm-camcorder
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "mm_camcorder_internal.h"
-#include "mm_camcorder_resource.h"
-#include <murphy/common/glib-glue.h>
-
-#define MRP_APP_CLASS_FOR_CAMCORDER "media"
-#define MRP_RESOURCE_TYPE_MANDATORY TRUE
-#define MRP_RESOURCE_TYPE_EXCLUSIVE FALSE
-
-const char* mm_camcorder_resource_str[MM_CAMCORDER_RESOURCE_MAX] = {
- "camera",
- "video_overlay",
- "video_encoder"
-};
-
-#define MMCAMCORDER_CHECK_RESOURCE_MANAGER_INSTANCE(x_camcorder_resource_manager) \
-do { \
- if (!x_camcorder_resource_manager) { \
- _mmcam_dbg_err("no resource manager instance"); \
- return MM_ERROR_INVALID_ARGUMENT; \
- } \
-} while (0);
-
-#define MMCAMCORDER_CHECK_CONNECTION_RESOURCE_MANAGER(x_camcorder_resource_manager) \
-do { \
- if (!x_camcorder_resource_manager) { \
- _mmcam_dbg_err("no resource manager instance"); \
- return MM_ERROR_INVALID_ARGUMENT; \
- } else { \
- if (!x_camcorder_resource_manager->is_connected) { \
- _mmcam_dbg_err("not connected to resource server yet"); \
- return MM_ERROR_RESOURCE_NOT_INITIALIZED; \
- } \
- } \
-} while (0);
-
-#define RESOURCE_LOG_INFO(fmt, args...) \
-do { \
- _mmcam_dbg_log("[%p][ID:%d] "fmt, resource_manager, resource_manager->id, ##args); \
-} while (0);
-
-#define RESOURCE_LOG_WARN(fmt, args...) \
-do { \
- _mmcam_dbg_warn("[%p][ID:%d] "fmt, resource_manager, resource_manager->id, ##args); \
-} while (0);
-
-#define RESOURCE_LOG_ERR(fmt, args...) \
-do { \
- _mmcam_dbg_err("[%p][ID:%d] "fmt, resource_manager, resource_manager->id, ##args); \
-} while (0);
-
-static char *__mmcamcorder_resource_state_to_str(mrp_res_resource_state_t st)
-{
- char *state = "unknown";
- switch (st) {
- case MRP_RES_RESOURCE_ACQUIRED:
- state = "acquired";
- break;
- case MRP_RES_RESOURCE_LOST:
- state = "lost";
- break;
- case MRP_RES_RESOURCE_AVAILABLE:
- state = "available";
- break;
- case MRP_RES_RESOURCE_PENDING:
- state = "pending";
- break;
- case MRP_RES_RESOURCE_ABOUT_TO_LOOSE:
- state = "about to loose";
- break;
- }
- return state;
-}
-
-static void __mmcamcorder_resource_state_callback(mrp_res_context_t *context, mrp_res_error_t err, void *user_data)
-{
- int i = 0;
- const mrp_res_resource_set_t *rset;
- mrp_res_resource_t *resource;
- mmf_camcorder_t *hcamcorder = NULL;
- MMCamcorderResourceManager *resource_manager = (MMCamcorderResourceManager *)user_data;
-
- mmf_return_if_fail(context);
- mmf_return_if_fail(resource_manager);
-
- hcamcorder = (mmf_camcorder_t *)resource_manager->hcamcorder;
-
- mmf_return_if_fail(hcamcorder);
-
- RESOURCE_LOG_WARN("enter - state %d", context->state);
-
- _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-
- switch (context->state) {
- case MRP_RES_CONNECTED:
- RESOURCE_LOG_WARN(" - connected to Murphy");
- if ((rset = mrp_res_list_resources(context)) != NULL) {
- mrp_res_string_array_t *resource_names;
- resource_names = mrp_res_list_resource_names(rset);
- if (!resource_names) {
- RESOURCE_LOG_ERR(" - no resources available");
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
- return;
- }
- for (i = 0; i < resource_names->num_strings; i++) {
- resource = mrp_res_get_resource_by_name(rset, resource_names->strings[i]);
- if (resource)
- RESOURCE_LOG_WARN(" - available resource: %s", resource->name);
- }
- mrp_res_free_string_array(resource_names);
- }
- resource_manager->is_connected = TRUE;
- _MMCAMCORDER_RESOURCE_SIGNAL(hcamcorder);
- break;
- case MRP_RES_DISCONNECTED:
- RESOURCE_LOG_ERR(" - disconnected from Murphy : stop camcorder");
-
- if (resource_manager->rset) {
- mrp_res_delete_resource_set(resource_manager->rset);
- resource_manager->rset = NULL;
- }
-
- if (resource_manager->context) {
- mrp_res_destroy(resource_manager->context);
- resource_manager->context = NULL;
- resource_manager->is_connected = FALSE;
- }
-
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-
- _MMCAMCORDER_LOCK_ASM(hcamcorder);
-
- /* Stop the camera */
- __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_RM);
-
- _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
-
- _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
- break;
- }
-
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-
- RESOURCE_LOG_WARN("leave");
-
- return;
-}
-
-
-static void __mmcamcorder_resource_set_state_callback(mrp_res_context_t *cx, const mrp_res_resource_set_t *rs, void *user_data)
-{
- int i = 0;
- mmf_camcorder_t *hcamcorder = NULL;
- MMCamcorderResourceManager *resource_manager = (MMCamcorderResourceManager *)user_data;
- mrp_res_resource_t *res = NULL;
-
- mmf_return_if_fail(resource_manager && resource_manager->hcamcorder);
-
- hcamcorder = (mmf_camcorder_t *)resource_manager->hcamcorder;
-
- RESOURCE_LOG_WARN("start");
-
- _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-
- if (!mrp_res_equal_resource_set(rs, resource_manager->rset)) {
- RESOURCE_LOG_WARN("- resource set(%p) is not same as this handle's(%p)", rs, resource_manager->rset);
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
- return;
- }
-
- RESOURCE_LOG_INFO(" - resource set state is changed to [%s]", __mmcamcorder_resource_state_to_str(rs->state));
-
- for (i = 0; i < MM_CAMCORDER_RESOURCE_MAX; i++) {
- res = mrp_res_get_resource_by_name(rs, mm_camcorder_resource_str[i]);
- if (res == NULL) {
- RESOURCE_LOG_WARN(" -- %s not present in resource set", mm_camcorder_resource_str[i]);
- } else {
- RESOURCE_LOG_WARN(" -- resource name [%s] -> [%s]",
- res->name, __mmcamcorder_resource_state_to_str(res->state));
-
- if (res->state == MRP_RES_RESOURCE_ACQUIRED) {
- resource_manager->acquire_remain--;
-
- if (resource_manager->acquire_remain <= 0) {
- RESOURCE_LOG_WARN("send signal - resource acquire done");
- _MMCAMCORDER_RESOURCE_SIGNAL(hcamcorder);
- } else {
- RESOURCE_LOG_WARN("remained acquire count %d",
- resource_manager->acquire_remain);
- }
- } else if (res->state == MRP_RES_RESOURCE_LOST) {
- resource_manager->acquire_remain++;
-
- if (resource_manager->acquire_remain >= resource_manager->acquire_count) {
- RESOURCE_LOG_WARN("resource release done");
-
- if (hcamcorder->state > MM_CAMCORDER_STATE_NULL) {
- RESOURCE_LOG_WARN("send resource signal");
- _MMCAMCORDER_RESOURCE_SIGNAL(hcamcorder);
- } else {
- RESOURCE_LOG_WARN("skip resource signal - state %d", hcamcorder->state);
- }
- } else {
- RESOURCE_LOG_WARN("acquired %d, lost %d",
- resource_manager->acquire_count, resource_manager->acquire_remain);
- }
- }
- }
- }
-
- mrp_res_delete_resource_set(resource_manager->rset);
- resource_manager->rset = mrp_res_copy_resource_set(rs);
-
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-
- RESOURCE_LOG_WARN("done");
-
- return;
-}
-
-
-static void __mmcamcorder_resource_release_cb(mrp_res_context_t *cx, const mrp_res_resource_set_t *rs, void *user_data)
-{
- int i = 0;
- int current_state = MM_CAMCORDER_STATE_NONE;
- mmf_camcorder_t *hcamcorder = NULL;
- MMCamcorderResourceManager *resource_manager = (MMCamcorderResourceManager *)user_data;
- mrp_res_resource_t *res = NULL;
-
- mmf_return_if_fail(resource_manager && resource_manager->hcamcorder);
-
- hcamcorder = (mmf_camcorder_t *)resource_manager->hcamcorder;
-
- current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
- if (current_state <= MM_CAMCORDER_STATE_NONE ||
- current_state >= MM_CAMCORDER_STATE_NUM) {
- RESOURCE_LOG_ERR("Abnormal state %d", current_state);
- return;
- }
-
- RESOURCE_LOG_WARN("enter");
-
- _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-
- if (!mrp_res_equal_resource_set(rs, resource_manager->rset)) {
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
- RESOURCE_LOG_WARN("- resource set(%p) is not same as this handle's(%p)", rs, resource_manager->rset);
- return;
- }
-
- /* set flag for resource release callback */
- resource_manager->is_release_cb_calling = TRUE;
-
- RESOURCE_LOG_INFO(" - resource set state is changed to [%s]", __mmcamcorder_resource_state_to_str(rs->state));
-
- for (i = 0; i < MM_CAMCORDER_RESOURCE_MAX; i++) {
- res = mrp_res_get_resource_by_name(rs, mm_camcorder_resource_str[i]);
- if (res) {
- RESOURCE_LOG_WARN(" -- resource name [%s] -> [%s]",
- res->name, __mmcamcorder_resource_state_to_str(res->state));
- } else {
- RESOURCE_LOG_WARN(" -- %s not present in resource set", mm_camcorder_resource_str[i]);
- }
- }
-
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-
- _MMCAMCORDER_LOCK_ASM(hcamcorder);
-
- if (resource_manager->id == MM_CAMCORDER_RESOURCE_ID_MAIN) {
- /* Stop camera */
- __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_RM);
- } else {
- /* Stop video recording */
- if (_mmcamcorder_commit((MMHandleType)hcamcorder) != MM_ERROR_NONE) {
- RESOURCE_LOG_ERR("commit failed, cancel it");
- _mmcamcorder_cancel((MMHandleType)hcamcorder);
- }
- }
-
- _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
-
- _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-
- /* restore flag for resource release callback */
- resource_manager->is_release_cb_calling = FALSE;
-
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-
- RESOURCE_LOG_WARN("leave");
-
- return;
-}
-
-int _mmcamcorder_resource_create_resource_set(MMCamcorderResourceManager *resource_manager)
-{
- if (resource_manager->rset) {
- RESOURCE_LOG_WARN(" - resource set was already created, delete it");
- mrp_res_delete_resource_set(resource_manager->rset);
- resource_manager->rset = NULL;
- }
-
- resource_manager->rset = mrp_res_create_resource_set(resource_manager->context,
- MRP_APP_CLASS_FOR_CAMCORDER, __mmcamcorder_resource_set_state_callback, (void *)resource_manager);
-
- if (resource_manager->rset == NULL) {
- RESOURCE_LOG_ERR(" - could not create resource set");
- return MM_ERROR_RESOURCE_INTERNAL;
- }
-
- if (!mrp_res_set_autorelease(TRUE, resource_manager->rset))
- RESOURCE_LOG_WARN(" - could not set autorelease flag!");
-
- RESOURCE_LOG_INFO("done");
-
- return MM_ERROR_NONE;
-}
-
-static int __mmcamcorder_resource_include_resource(MMCamcorderResourceManager *resource_manager, const char *resource_name)
-{
- mrp_res_resource_t *resource = NULL;
- resource = mrp_res_create_resource(resource_manager->rset,
- resource_name,
- MRP_RESOURCE_TYPE_MANDATORY,
- MRP_RESOURCE_TYPE_EXCLUSIVE);
- if (resource == NULL) {
- RESOURCE_LOG_ERR(" - could not include resource[%s]", resource_name);
- return MM_ERROR_RESOURCE_INTERNAL;
- }
-
- resource_manager->acquire_count++;
- resource_manager->acquire_remain = resource_manager->acquire_count;
-
- RESOURCE_LOG_INFO(" - count[%d] include resource[%s]",
- resource_manager->acquire_count, resource_name);
-
- return MM_ERROR_NONE;
-}
-
-static int __mmcamcorder_resource_set_release_cb(MMCamcorderResourceManager *resource_manager)
-{
- int ret = MM_ERROR_NONE;
- bool mrp_ret = FALSE;
-
- if (resource_manager->rset) {
- mrp_ret = mrp_res_set_release_callback(resource_manager->rset, __mmcamcorder_resource_release_cb, (void *)resource_manager);
- if (!mrp_ret) {
- RESOURCE_LOG_ERR(" - could not set release callback");
- ret = MM_ERROR_RESOURCE_INTERNAL;
- }
- } else {
- RESOURCE_LOG_ERR(" - resource set is null");
- ret = MM_ERROR_RESOURCE_INVALID_STATE;
- }
-
- return ret;
-}
-
-int _mmcamcorder_resource_manager_init(MMCamcorderResourceManager *resource_manager)
-{
- GMainContext *mrp_ctx = NULL;
- GMainLoop *mrp_loop = NULL;
-
- MMCAMCORDER_CHECK_RESOURCE_MANAGER_INSTANCE(resource_manager);
-
- RESOURCE_LOG_WARN("start");
-
- mrp_ctx = g_main_context_new();
- if (!mrp_ctx) {
- RESOURCE_LOG_ERR("failed to get create glib context for mrp");
- return MM_ERROR_RESOURCE_INTERNAL;
- }
-
- mrp_loop = g_main_loop_new(mrp_ctx, TRUE);
-
- g_main_context_unref(mrp_ctx);
- mrp_ctx = NULL;
-
- if (!mrp_loop) {
- RESOURCE_LOG_ERR("failed to get create glib loop for mrp");
- return MM_ERROR_RESOURCE_INTERNAL;
- }
-
- resource_manager->mloop = mrp_mainloop_glib_get(mrp_loop);
-
- g_main_loop_unref(mrp_loop);
- mrp_loop = NULL;
-
- if (!resource_manager->mloop) {
- RESOURCE_LOG_ERR("failed to get mainloop for mrp");
- return MM_ERROR_RESOURCE_INTERNAL;
- }
-
- RESOURCE_LOG_WARN("mloop %p", resource_manager->mloop);
-
- resource_manager->context = mrp_res_create(resource_manager->mloop, __mmcamcorder_resource_state_callback, (void *)resource_manager);
- if (!resource_manager->context) {
- RESOURCE_LOG_ERR("could not get context for mrp");
-
- mrp_mainloop_destroy(resource_manager->mloop);
- resource_manager->mloop = NULL;
-
- return MM_ERROR_RESOURCE_INTERNAL;
- }
-
- RESOURCE_LOG_INFO("done");
-
- return MM_ERROR_NONE;
-}
-
-
-int _mmcamcorder_resource_wait_for_connection(MMCamcorderResourceManager *resource_manager)
-{
- int ret = MM_ERROR_NONE;
- void *hcamcorder = NULL;
-
- mmf_return_val_if_fail(resource_manager && resource_manager->hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
-
- hcamcorder = resource_manager->hcamcorder;
-
- _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-
- if (resource_manager->is_connected == FALSE) {
- gint64 end_time = 0;
-
- /* wait for resource manager connected */
- RESOURCE_LOG_WARN("not connected. wait for signal...");
-
- end_time = g_get_monotonic_time() + (__MMCAMCORDER_RESOURCE_WAIT_TIME * G_TIME_SPAN_SECOND);
-
- if (_MMCAMCORDER_RESOURCE_WAIT_UNTIL(hcamcorder, end_time)) {
- RESOURCE_LOG_WARN("signal received");
- ret = MM_ERROR_NONE;
- } else {
- RESOURCE_LOG_ERR("connection timeout");
- ret = MM_ERROR_RESOURCE_INTERNAL;
- }
- } else {
- RESOURCE_LOG_WARN("already connected");
- }
-
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-
- return ret;
-}
-
-
-int _mmcamcorder_resource_check_connection(MMCamcorderResourceManager *resource_manager)
-{
- int ret = MM_ERROR_NONE;
-
- mmf_return_val_if_fail(resource_manager, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
-
- if (resource_manager->is_connected == FALSE) {
- RESOURCE_LOG_WARN("resource manager disconnected before, try to reconnect");
-
- /* release remained resource */
- _mmcamcorder_resource_manager_deinit(resource_manager);
-
- /* init resource manager and wait for connection */
- ret = _mmcamcorder_resource_manager_init(resource_manager);
- if (ret != MM_ERROR_NONE) {
- RESOURCE_LOG_ERR("failed to initialize resource manager");
- return ret;
- }
-
- ret = _mmcamcorder_resource_wait_for_connection(resource_manager);
- if (ret != MM_ERROR_NONE) {
- RESOURCE_LOG_ERR("failed to connect resource manager");
- return ret;
- }
- }
-
- RESOURCE_LOG_WARN("done");
-
- return ret;
-}
-
-
-int _mmcamcorder_resource_manager_prepare(MMCamcorderResourceManager *resource_manager, MMCamcorderResourceType resource_type)
-{
- MMCAMCORDER_CHECK_RESOURCE_MANAGER_INSTANCE(resource_manager);
- MMCAMCORDER_CHECK_CONNECTION_RESOURCE_MANAGER(resource_manager);
-
- return __mmcamcorder_resource_include_resource(resource_manager, mm_camcorder_resource_str[resource_type]);
-}
-
-int _mmcamcorder_resource_manager_acquire(MMCamcorderResourceManager *resource_manager)
-{
- int ret = MM_ERROR_NONE;
- MMCAMCORDER_CHECK_RESOURCE_MANAGER_INSTANCE(resource_manager);
- MMCAMCORDER_CHECK_CONNECTION_RESOURCE_MANAGER(resource_manager);
-
- if (resource_manager->rset == NULL) {
- RESOURCE_LOG_ERR("- could not acquire resource, resource set is null");
- ret = MM_ERROR_RESOURCE_INVALID_STATE;
- } else {
- ret = __mmcamcorder_resource_set_release_cb(resource_manager);
- if (ret) {
- RESOURCE_LOG_ERR("- could not set resource release cb, ret(%d)", ret);
- ret = MM_ERROR_RESOURCE_INTERNAL;
- } else {
- ret = mrp_res_acquire_resource_set(resource_manager->rset);
- if (ret) {
- RESOURCE_LOG_ERR("- could not acquire resource, ret(%d)", ret);
- ret = MM_ERROR_RESOURCE_INTERNAL;
- }
- }
- }
-
- return ret;
-}
-
-int _mmcamcorder_resource_manager_release(MMCamcorderResourceManager *resource_manager)
-{
- int ret = MM_ERROR_NONE;
- MMCAMCORDER_CHECK_RESOURCE_MANAGER_INSTANCE(resource_manager);
- MMCAMCORDER_CHECK_CONNECTION_RESOURCE_MANAGER(resource_manager);
-
- if (resource_manager->rset == NULL) {
- RESOURCE_LOG_ERR("- could not release resource, resource set is null");
- ret = MM_ERROR_RESOURCE_INVALID_STATE;
- } else {
- if (resource_manager->rset->state != MRP_RES_RESOURCE_ACQUIRED) {
- RESOURCE_LOG_ERR("- could not release resource, resource set state is [%s]",
- __mmcamcorder_resource_state_to_str(resource_manager->rset->state));
- ret = MM_ERROR_RESOURCE_INVALID_STATE;
- } else {
- ret = mrp_res_release_resource_set(resource_manager->rset);
- if (ret) {
- RESOURCE_LOG_ERR("- could not release resource, ret(%d)", ret);
- ret = MM_ERROR_RESOURCE_INTERNAL;
- } else {
- RESOURCE_LOG_INFO("resource release done");
- }
- }
- }
-
- return ret;
-}
-
-
-int _mmcamcorder_resource_manager_deinit(MMCamcorderResourceManager *resource_manager)
-{
- MMCAMCORDER_CHECK_RESOURCE_MANAGER_INSTANCE(resource_manager);
-
- RESOURCE_LOG_WARN("rset %p, context %p, mloop %p",
- resource_manager->rset, resource_manager->context, resource_manager->mloop);
-
- if (resource_manager->rset) {
- if (resource_manager->rset->state == MRP_RES_RESOURCE_ACQUIRED) {
- RESOURCE_LOG_WARN("resource is still acquired. release...");
- if (mrp_res_release_resource_set(resource_manager->rset))
- RESOURCE_LOG_ERR("- could not release resource");
- }
-
- RESOURCE_LOG_WARN("delete resource set");
-
- mrp_res_delete_resource_set(resource_manager->rset);
- resource_manager->rset = NULL;
- }
-
- if (resource_manager->context) {
- RESOURCE_LOG_WARN("destroy resource context");
-
- mrp_res_destroy(resource_manager->context);
- resource_manager->context = NULL;
- }
-
- if (resource_manager->mloop) {
- RESOURCE_LOG_WARN("destroy resource mainloop");
-
- mrp_mainloop_quit(resource_manager->mloop, 0);
- mrp_mainloop_destroy(resource_manager->mloop);
- resource_manager->mloop = NULL;
- }
-
- RESOURCE_LOG_WARN("done");
-
- return MM_ERROR_NONE;
-}
GstPad *reqpad = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
int ret = MM_ERROR_NONE;
- MMCamcorderResourceManager *resource_manager = NULL;
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
_mmcam_dbg_warn("Encoder pipeline removed");
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- resource_manager = &hcamcorder->resource_manager_sub;
-
- _mmcam_dbg_warn("lock resource - cb calling %d", resource_manager->is_release_cb_calling);
-
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
_MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
- if (resource_manager->is_release_cb_calling == FALSE) {
+ _mmcam_dbg_warn("lock resource - cb calling %d", hcamcorder->is_release_cb_calling);
+
+ if (hcamcorder->is_release_cb_calling == FALSE) {
/* release resource */
- ret = _mmcamcorder_resource_manager_release(resource_manager);
+ ret = mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
+ hcamcorder->video_encoder_resource);
+ if (ret == MM_RESOURCE_MANAGER_ERROR_NONE)
+ hcamcorder->video_encoder_resource = NULL;
- _mmcam_dbg_warn("release resource 0x%x", ret);
+ _mmcam_dbg_warn("mark resource for release 0x%x", ret);
- if (resource_manager->acquire_remain < resource_manager->acquire_count) {
- /* wait for resource release */
- gint64 end_time = g_get_monotonic_time() + (__MMCAMCORDER_RESOURCE_WAIT_TIME * G_TIME_SPAN_SECOND);
- _mmcam_dbg_log("resource is not released all. wait for signal...");
- _MMCAMCORDER_RESOURCE_WAIT_UNTIL(hcamcorder, end_time);
- }
+ ret = mm_resource_manager_commit(hcamcorder->resource_manager);
+
+ _mmcam_dbg_warn("commit resource release 0x%x", ret);
}
_MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
_mmcam_dbg_warn("unlock resource");
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
}
return MM_ERROR_NONE;
/* Recording */
_mmcam_dbg_log("Record Start - dual stream %d", info->support_dual_stream);
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- /* check connection */
- ret = _mmcamcorder_resource_check_connection(&hcamcorder->resource_manager_sub);
- if (ret != MM_ERROR_NONE)
- goto _ERR_CAMCORDER_VIDEO_COMMAND;
-
- /* create resource set */
- ret = _mmcamcorder_resource_create_resource_set(&hcamcorder->resource_manager_sub);
- if (ret != MM_ERROR_NONE)
- goto _ERR_CAMCORDER_VIDEO_COMMAND;
-
- hcamcorder->resource_manager_sub.acquire_count = 0;
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
/* prepare resource manager for H/W encoder */
- ret = _mmcamcorder_resource_manager_prepare(&hcamcorder->resource_manager_sub, MM_CAMCORDER_RESOURCE_TYPE_VIDEO_ENCODER);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("could not prepare for video_encoder resource");
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_CAMCORDER_VIDEO_COMMAND;
+ if (hcamcorder->video_encoder_resource == NULL) {
+ ret = mm_resource_manager_mark_for_acquire(hcamcorder->resource_manager,
+ MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_ENCODER,
+ MM_RESOURCE_MANAGER_RES_VOLUME_FULL,
+ &hcamcorder->video_encoder_resource);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ _mmcam_dbg_err("could not prepare for encoder resource");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+ goto _ERR_CAMCORDER_VIDEO_COMMAND;
+ }
+ } else {
+ _mmcam_dbg_log("encoder already acquired");
}
/* acquire resources */
- _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-
- ret = _mmcamcorder_resource_manager_acquire(&hcamcorder->resource_manager_sub);
- if (ret != MM_ERROR_NONE) {
+ ret = mm_resource_manager_commit(hcamcorder->resource_manager);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
_MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
- _mmcam_dbg_err("could not acquire resource");
- goto _ERR_CAMCORDER_VIDEO_COMMAND;
- }
- if (hcamcorder->resource_manager_sub.acquire_remain > 0) {
- gint64 end_time = 0;
+ _mmcam_dbg_err("could not acquire resources");
- _mmcam_dbg_warn("wait for resource state change");
-
- /* wait for resource state change */
- end_time = g_get_monotonic_time() + (__MMCAMCORDER_RESOURCE_WAIT_TIME * G_TIME_SPAN_SECOND);
-
- if (_MMCAMCORDER_RESOURCE_WAIT_UNTIL(hcamcorder, end_time)) {
- _mmcam_dbg_warn("signal received");
- } else {
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
- _mmcam_dbg_err("timeout");
- ret = MM_ERROR_RESOURCE_INTERNAL;
- goto _ERR_CAMCORDER_VIDEO_COMMAND;
- }
- } else {
- _mmcam_dbg_log("already acquired");
+ goto _ERR_CAMCORDER_VIDEO_COMMAND;
}
_MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
/* init record_dual_stream */
info->record_dual_stream = FALSE;