Link device control port to RoSE 77/214677/16
authorGilbok Lee <gilbok.lee@samsung.com>
Thu, 26 Sep 2019 09:10:40 +0000 (18:10 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Wed, 2 Oct 2019 08:38:14 +0000 (17:38 +0900)
- apply tizen coding rule

Change-Id: Ia7653435c68b6a2595186ef8a8f2efdd6d6c668b

19 files changed:
CMakeLists.txt
device_control/rose_tizen_device_ctl_interface.c [new file with mode: 0644]
device_control/rose_tizen_device_ctl_interface.h [new file with mode: 0644]
include/rose_tizen.h
include/rose_tizen_ctlinfo_parse.h
include/rose_tizen_device_ctl.h [new file with mode: 0644]
include/rose_tizen_mplayer.h [new file with mode: 0644]
include/rose_tizen_parse_xml.h
include/rose_tizen_priv.h
include/rose_tizen_sem_parse.h
media_player/rose_tizen_mplayer.h [deleted file]
media_player/rose_tizen_mplayer_interface.c
media_player/rose_tizen_mplayer_interface.h
packaging/capi-media-rose-tizen.spec
src/rose_tizen.c
src/rose_tizen_ctlinfo_parse.c
src/rose_tizen_parse_xml.c
src/rose_tizen_sem_parse.c
test/rose_tizen_test.c

index 150263eb9efa3fd3e931321597e132374fa81536..20753bb3ec995342ef2e11c4272560f6b9f96871 100644 (file)
@@ -9,7 +9,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
 SET(INC_DIR include)
 
-INCLUDE_DIRECTORIES(${INC_DIR} media_player)
+INCLUDE_DIRECTORIES(${INC_DIR} media_player device_control)
 SET(dependents "dlog glib-2.0 storage capi-system-info libxml-2.0")
 SET(pc_dependents "storage capi-system-info libxml-2.0")
 
@@ -33,6 +33,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
 
 aux_source_directory(src SOURCES)
 aux_source_directory(media_player SOURCES)
+aux_source_directory(device_control SOURCES)
 ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
 
 TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
@@ -49,6 +50,10 @@ INSTALL(
         DIRECTORY ${INC_DIR}/ DESTINATION include/media
         FILES_MATCHING
         PATTERN "${INC_DIR}/rose_tizen.h"
+        PATTERN "${INC_DIR}/rose_tizen_sem_parse.h"
+        PATTERN "${INC_DIR}/rose_tizen_ctlinfo_parse.h"
+        PATTERN "${INC_DIR}/rose_tizen_device_ctl.h"
+        PATTERN "${INC_DIR}/rose_tizen_mplayer.h"
         )
 
 SET(PC_NAME ${fw_name})
diff --git a/device_control/rose_tizen_device_ctl_interface.c b/device_control/rose_tizen_device_ctl_interface.c
new file mode 100644 (file)
index 0000000..9de8289
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+* Copyright (c) 2019 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 <dlfcn.h>
+#include <glib.h>
+#include <dlog.h>
+
+#include "rose_tizen_device_ctl_interface.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif /* LOG_TAG */
+
+#define LOG_TAG "ROSE_DEVICE_CTL_INTF"
+
+#define LIB_TIZEN_DEVICE_CTL PATH_LIBDIR"/librose-tizen-device-control.so"
+
+#define DEVOCE_CTL_INTF_CHECK_ARG(x_handle) \
+do { \
+       if (!x_handle) { \
+               LOGE("%s argument is NULL", #x_handle); \
+               return DEVICE_CTL_ERROR_INVALID_PARAMETER; \
+       } \
+} while (0)
+
+int _rose_device_ctl_create(device_ctl_interface **handle)
+{
+       device_ctl_interface *h = NULL;
+       int ret = DEVICE_CTL_ERROR_NONE;
+
+       h = (device_ctl_interface *)g_new0(device_ctl_interface, 1);
+       h->dl_handle = dlopen(LIB_TIZEN_DEVICE_CTL, RTLD_NOW);
+       if (!h->dl_handle) {
+               SECURE_LOGE("Failed to open device control library (%s)",
+                                       LIB_TIZEN_DEVICE_CTL);
+               g_free(h);
+               return DEVICE_CTL_ERROR_INVALID_OPERATION;
+       }
+
+       h->fp.create = dlsym(h->dl_handle, "device_ctl_create");
+       h->fp.destroy = dlsym(h->dl_handle, "device_ctl_destroy");
+       h->fp.prepare = dlsym(h->dl_handle, "device_ctl_prepare");
+       h->fp.unprepare = dlsym(h->dl_handle, "device_ctl_unprepare");
+       h->fp.set_ctl_info = dlsym(h->dl_handle, "device_ctl_set_ctl_info");
+       h->fp.activate = dlsym(h->dl_handle, "device_ctl_activate");
+
+       if (h->fp.create == NULL || h->fp.destroy == NULL) {
+               LOGE("could not get mandatory funtion");
+               ret = DEVICE_CTL_ERROR_INVALID_OPERATION;
+               goto FAIL;
+       }
+
+       ret = h->fp.create(&h->dc_handle);
+       if (ret != DEVICE_CTL_ERROR_NONE) {
+               LOGE("Failed to create device control handle");
+               goto FAIL;
+       }
+
+       *handle = h;
+       LOGD("device control interface handle = %p", *handle);
+
+       return ret;
+FAIL:
+       if (h) {
+               if (h->dl_handle)
+                       dlclose(h->dl_handle);
+               g_free(h);
+       }
+       return ret;
+
+}
+
+int _rose_device_ctl_destroy(device_ctl_interface *handle)
+{
+       int ret = DEVICE_CTL_ERROR_NONE;
+       DEVOCE_CTL_INTF_CHECK_ARG(handle);
+       DEVOCE_CTL_INTF_CHECK_ARG(handle->dc_handle);
+       DEVOCE_CTL_INTF_CHECK_ARG(handle->dl_handle);
+
+       ret = handle->fp.destroy(handle->dc_handle);
+       if (ret != DEVICE_CTL_ERROR_NONE)
+               LOGW("Failed to destory device control handle");
+       handle->dc_handle = NULL;
+
+       dlclose(handle->dl_handle);
+       LOGD("close device control interface");
+       handle->dl_handle = NULL;
+
+       g_free(handle);
+       handle = NULL;
+
+       return DEVICE_CTL_ERROR_NONE;
+}
+
+int _rose_device_ctl_prepare(device_ctl_interface *handle)
+{
+       int ret = DEVICE_CTL_ERROR_NONE;
+       DEVOCE_CTL_INTF_CHECK_ARG(handle);
+       DEVOCE_CTL_INTF_CHECK_ARG(handle->dc_handle);
+
+       ret = handle->fp.prepare(handle->dc_handle);
+       if (ret != DEVICE_CTL_ERROR_NONE)
+               LOGW("Failed to prepare device control handle");
+
+       LOGD("prepare device control interface");
+
+       return DEVICE_CTL_ERROR_NONE;
+}
+
+int _rose_device_ctl_unprepare(device_ctl_interface *handle)
+{
+       int ret = DEVICE_CTL_ERROR_NONE;
+       DEVOCE_CTL_INTF_CHECK_ARG(handle);
+       DEVOCE_CTL_INTF_CHECK_ARG(handle->dc_handle);
+
+       ret = handle->fp.unprepare(handle->dc_handle);
+       if (ret != DEVICE_CTL_ERROR_NONE)
+               LOGW("Failed to unprepare device control handle");
+
+       LOGD("unprepare device control interface");
+
+       return DEVICE_CTL_ERROR_NONE;
+}
+
+int _rose_device_ctl_set_info(device_ctl_interface *handle, rose_control_info *ctl_info)
+{
+       int ret = DEVICE_CTL_ERROR_NONE;
+       DEVOCE_CTL_INTF_CHECK_ARG(handle);
+       DEVOCE_CTL_INTF_CHECK_ARG(ctl_info);
+       DEVOCE_CTL_INTF_CHECK_ARG(handle->dc_handle);
+
+       ret = handle->fp.set_ctl_info(handle->dc_handle, ctl_info);
+       if (ret != DEVICE_CTL_ERROR_NONE)
+               LOGW("Failed to set device control info");
+
+       LOGD("set device control info");
+
+       return DEVICE_CTL_ERROR_NONE;
+}
+int _rose_device_ctl_activate(device_ctl_interface *handle, rose_sem_effect_elements *effect)
+{
+       int ret = DEVICE_CTL_ERROR_NONE;
+       DEVOCE_CTL_INTF_CHECK_ARG(handle);
+       DEVOCE_CTL_INTF_CHECK_ARG(handle->dc_handle);
+
+       if (!handle->fp.activate) {
+               LOGW("Not found activate function");
+               return DEVICE_CTL_ERROR_INVALID_OPERATION;
+       }
+
+       ret = handle->fp.activate(handle->dc_handle, effect);
+       if (ret != DEVICE_CTL_ERROR_NONE)
+               LOGE("Failed to activate");
+
+       return ret;
+}
\ No newline at end of file
diff --git a/device_control/rose_tizen_device_ctl_interface.h b/device_control/rose_tizen_device_ctl_interface.h
new file mode 100644 (file)
index 0000000..9efcbaa
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2019 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.
+*/
+
+#ifndef __TIZEN_MEDIA_ROSE_TIZEN_DEVICE_CTL_INTF_H__
+#define __TIZEN_MEDIA_ROSE_TIZEN_DEVICE_CTL_INTF_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "rose_tizen_sem_parse.h"
+#include "rose_tizen_ctlinfo_parse.h"
+#include "rose_tizen_device_ctl.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* media player interface */
+typedef struct _device_ctl_interface {
+       void *dl_handle;
+       void *dc_handle;
+       device_ctl_fp_t fp;
+} device_ctl_interface;
+
+int _rose_device_ctl_create(device_ctl_interface **handle);
+int _rose_device_ctl_destroy(device_ctl_interface *handle);
+int _rose_device_ctl_prepare(device_ctl_interface *handle);
+int _rose_device_ctl_unprepare(device_ctl_interface *handle);
+int _rose_device_ctl_set_info(device_ctl_interface *handle, rose_control_info *ctl_info);
+int _rose_device_ctl_activate(device_ctl_interface *handle, rose_sem_effect_elements *effect);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_ROSE_TIZEN_DEVICE_CTL_INTF_H__ */
index 4b9d13e541c8b0b981fbeb73284567fbbb6562c3..78c9cd72f3eddf13a7c5facf2887864485f5bb32 100644 (file)
@@ -54,7 +54,7 @@ typedef enum {
        ROSE_DISPLAY_TYPE_NONE = 4,
 } rose_display_type_e;
 
-int rose_create(rose_h * rose);
+int rose_create(rose_h *rose);
 int rose_destroy(rose_h rose);
 
 int rose_prepare(rose_h rose);
index 2508112902c1dd1fc0e11c91d25bc06029b76933..74ba567e51b158bf7b94955949177083ccc63d47 100644 (file)
@@ -114,11 +114,11 @@ struct _rose_control_info {
        GList *sdc_elements;
 };
 
-int rose_ctl_info_parse(xmlNode * a_node, rose_control_info ** ctl_info);
-void rose_ctl_info_free(rose_control_info * ctl_info);
+int rose_ctl_info_parse(xmlNode *a_node, rose_control_info **ctl_info);
+void rose_ctl_info_free(rose_control_info *ctl_info);
 
 /* The number of devices and information of the device are needed. */
-guint rose_ctl_get_total_delay_time(rose_control_info * ctl_info, rose_sdc_type_e type);
+guint rose_ctl_get_total_delay_time(rose_control_info *ctl_info, rose_sdc_type_e type);
 
 #ifdef __cplusplus
 }
diff --git a/include/rose_tizen_device_ctl.h b/include/rose_tizen_device_ctl.h
new file mode 100644 (file)
index 0000000..9276b87
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2019 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.
+ *
+ */
+
+#ifndef __TIZEN_MEDIA_ROSE_TIZEN_DEVICE_CTL_H__
+#define __TIZEN_MEDIA_ROSE_TIZEN_DEVICE_CTL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+typedef enum device_ctl_error {
+       DEVICE_CTL_ERROR_NONE, //
+       DEVICE_CTL_ERROR_OUT_OF_MEMORY, //
+       DEVICE_CTL_ERROR_INVALID_PARAMETER, //
+       DEVICE_CTL_ERROR_INVALID_OPERATION,
+} device_ctl_error_t;
+
+typedef struct device_ctl_fp {
+       /* create & destroy */
+       device_ctl_error_t (*create)(void **device_ctl_handle);
+       device_ctl_error_t (*destroy)(void *device_ctl_handle);
+       device_ctl_error_t (*prepare)(void *device_ctl_handle);
+       device_ctl_error_t (*unprepare)(void *device_ctl_handle);
+       device_ctl_error_t (*set_ctl_info)(void *device_ctl_handle, void *ctl_info);
+       device_ctl_error_t (*activate)(void *device_ctl_handle, void *effect_element);
+} device_ctl_fp_t;
+
+device_ctl_error_t device_ctl_create(void **device_ctl_handle);
+device_ctl_error_t device_ctl_destroy(void *device_ctl_handle);
+device_ctl_error_t device_ctl_prepare(void *device_ctl_handle);
+device_ctl_error_t device_ctl_unprepare(void *device_ctl_handle);
+device_ctl_error_t device_ctl_set_ctl_info(void *device_ctl_handle, void *ctl_info);
+device_ctl_error_t device_ctl_activate(void *device_ctl_handle, void *effect_element);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_ROSE_TIZEN_DEVICE_CTL_H__ */
diff --git a/include/rose_tizen_mplayer.h b/include/rose_tizen_mplayer.h
new file mode 100644 (file)
index 0000000..2b3eed0
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2019 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.
+*/
+
+#ifndef __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_H__
+#define __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+typedef enum mplayer_error {
+       MPLAYER_ERROR_NONE,
+       MPLAYER_ERROR_OUT_OF_MEMORY,
+       MPLAYER_ERROR_INVALID_PARAMETER,
+       MPLAYER_ERROR_NO_SUCH_FILE,
+       MPLAYER_ERROR_INVALID_OPERATION,
+       MPLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE,
+       MPLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE,
+       MPLAYER_ERROR_SEEK_FAILED,
+       MPLAYER_ERROR_INVALID_STATE,
+       MPLAYER_ERROR_NOT_SUPPORTED_FILE,
+       MPLAYER_ERROR_INVALID_URI,
+       MPLAYER_ERROR_SOUND_POLICY,
+       MPLAYER_ERROR_CONNECTION_FAILED,
+       MPLAYER_ERROR_VIDEO_CAPTURE_FAILED,
+       MPLAYER_ERROR_DRM_EXPIRED,
+       MPLAYER_ERROR_DRM_NO_LICENSE,
+       MPLAYER_ERROR_DRM_FUTURE_USE,
+       MPLAYER_ERROR_DRM_NOT_PERMITTED,
+       MPLAYER_ERROR_RESOURCE_LIMIT,
+       MPLAYER_ERROR_PERMISSION_DENIED,
+       MPLAYER_ERROR_SERVICE_DISCONNECTED,
+       MPLAYER_ERROR_BUFFER_SPACE,
+       MPLAYER_ERROR_NOT_SUPPORTED_AUDIO_CODEC,
+       MPLAYER_ERROR_NOT_SUPPORTED_VIDEO_CODEC,
+       MPLAYER_ERROR_NOT_SUPPORTED_SUBTITLE,
+       MPLAYER_ERROR_NOT_SUPPORTED_FORMAT,
+} mplayer_error_t;
+
+typedef enum {
+       MPLAYER_DISPLAY_TYPE_OVERLAY = 0,        /**< Overlay surface display */
+       MPLAYER_DISPLAY_TYPE_EVAS = 3,           /**< Evas image object surface display (Since 4.0) */
+       MPLAYER_DISPLAY_TYPE_NONE = 4,           /**< This disposes of buffers (Since 4.0) */
+} mplayer_display_type_e;
+
+typedef struct mplayer_fp {
+       /* create & destroy */
+       mplayer_error_t (*create)(void **mplayer_handle);
+       mplayer_error_t (*destroy)(void *mplayer_handle);
+       mplayer_error_t (*set_uri)(void *mplayer_handle, const char *uri);
+       mplayer_error_t (*set_display)(void *mplayer_handle, int type, void *display);
+       mplayer_error_t (*prepare)(void *mplayer_handle);
+       mplayer_error_t (*unprepare)(void *mplayer_handle);
+       mplayer_error_t (*start)(void *mplayer_handle);
+       mplayer_error_t (*stop)(void *mplayer_handle);
+       mplayer_error_t (*pause)(void *mplayer_handle);
+       mplayer_error_t (*set_play_position)(void *mplayer_handle, int msec, bool accurate);
+       mplayer_error_t (*get_play_position)(void *mplayer_handle, int *msec);
+} mplayer_fp_t;
+
+mplayer_error_t mplayer_create(void **mplayer_handle);
+mplayer_error_t mplayer_destroy(void *mplayer_handle);
+mplayer_error_t mplayer_set_uri(void *mplayer_handle, const char *uri);
+mplayer_error_t mplayer_set_display(void *mplayer_handle, int type, void *display);
+mplayer_error_t mplayer_prepare(void *mplayer_handle);
+mplayer_error_t mplayer_unprepare(void *mplayer_handle);
+mplayer_error_t mplayer_start(void *mplayer_handle);
+mplayer_error_t mplayer_stop(void *mplayer_handle);
+mplayer_error_t mplayer_pause(void *mplayer_handle);
+mplayer_error_t mplayer_set_play_position(void *mplayer_handle, int msec, bool accurate);
+mplayer_error_t mplayer_get_play_position(void *mplayer_handle, int *msec);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_H__ */
index 1ca380b99146b36113427e041d3110cb718e914d..8b258495caf517bd1f528e6ac706fc79e3e9947c 100644 (file)
@@ -25,11 +25,11 @@ extern "C" {
 #endif
 
 /* Property parsing */
-gboolean _get_xml_prop_string(xmlNode * node, const gchar * prop_name, gchar ** prop_value);
-gboolean _get_xml_prop_boolean(xmlNode * node, const gchar * prop_name, gboolean * prop_value);
-gboolean _get_xml_prop_signed_integer(xmlNode * node, const gchar * prop_name, gint * prop_value);
-gboolean _get_xml_prop_unsigned_integer(xmlNode * node, const gchar * prop_name, guint * prop_value);
-gboolean _get_xml_prop_float(xmlNode * node, const gchar * prop_name, gfloat * prop_value);
+gboolean _get_xml_prop_string(xmlNode *node, const gchar *prop_name, gchar **prop_value);
+gboolean _get_xml_prop_boolean(xmlNode *node, const gchar *prop_name, gboolean *prop_value);
+gboolean _get_xml_prop_signed_integer(xmlNode *node, const gchar *prop_name, gint *prop_value);
+gboolean _get_xml_prop_unsigned_integer(xmlNode *node, const gchar *prop_name, guint *prop_value);
+gboolean _get_xml_prop_float(xmlNode *node, const gchar *prop_name, gfloat *prop_value);
 
 #ifdef __cplusplus
 }
index fe902d05e058e7939230383fc698049882011aa3..f8715f091be7aa8e859fdc27a573b5d8755834b1 100644 (file)
@@ -24,6 +24,7 @@
 #include "rose_tizen_sem_parse.h"
 #include "rose_tizen_ctlinfo_parse.h"
 #include "rose_tizen_mplayer_interface.h"
+#include "rose_tizen_device_ctl_interface.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -157,6 +158,7 @@ typedef struct _rose_s {
        rose_sem *sem;
        rose_control_info *ctl_info;
        mplayer_interface *mplayer_intf;
+       device_ctl_interface *device_ctl_intf;
        rose_render *renderer;
 } rose_s;
 
index 0ea41ff5bd40fe123082707576144b71834e4258..92512d1827200abd1887aaff4f39fbe29057bf03 100644 (file)
@@ -116,8 +116,8 @@ struct _rose_sem_effect_elements {
 };
 
 
-int rose_sem_parse(xmlNode * a_node, rose_sem ** sem);
-void rose_sem_free(rose_sem * sem);
+int rose_sem_parse(xmlNode *a_node, rose_sem **sem);
+void rose_sem_free(rose_sem *sem);
 
 guint _rose_sem_get_pts(rose_sem_effect_elements *effect, guint time_scale);
 gint64 _rose_sem_get_render_time(rose_sem_effect_elements *effect, guint time_scale);
diff --git a/media_player/rose_tizen_mplayer.h b/media_player/rose_tizen_mplayer.h
deleted file mode 100644 (file)
index 60d7db3..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-* Copyright (c) 2019 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.
-*/
-
-#ifndef __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_H__
-#define __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-typedef enum mplayer_error {
-       MPLAYER_ERROR_NONE,
-       MPLAYER_ERROR_OUT_OF_MEMORY,
-       MPLAYER_ERROR_INVALID_PARAMETER,
-       MPLAYER_ERROR_NO_SUCH_FILE,
-       MPLAYER_ERROR_INVALID_OPERATION,
-       MPLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE,
-       MPLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE,
-       MPLAYER_ERROR_SEEK_FAILED,
-       MPLAYER_ERROR_INVALID_STATE,
-       MPLAYER_ERROR_NOT_SUPPORTED_FILE,
-       MPLAYER_ERROR_INVALID_URI,
-       MPLAYER_ERROR_SOUND_POLICY,
-       MPLAYER_ERROR_CONNECTION_FAILED,
-       MPLAYER_ERROR_VIDEO_CAPTURE_FAILED,
-       MPLAYER_ERROR_DRM_EXPIRED,
-       MPLAYER_ERROR_DRM_NO_LICENSE,
-       MPLAYER_ERROR_DRM_FUTURE_USE,
-       MPLAYER_ERROR_DRM_NOT_PERMITTED,
-       MPLAYER_ERROR_RESOURCE_LIMIT,
-       MPLAYER_ERROR_PERMISSION_DENIED,
-       MPLAYER_ERROR_SERVICE_DISCONNECTED,
-       MPLAYER_ERROR_BUFFER_SPACE,
-       MPLAYER_ERROR_NOT_SUPPORTED_AUDIO_CODEC,
-       MPLAYER_ERROR_NOT_SUPPORTED_VIDEO_CODEC,
-       MPLAYER_ERROR_NOT_SUPPORTED_SUBTITLE,
-       MPLAYER_ERROR_NOT_SUPPORTED_FORMAT,
-} mplayer_error_t;
-
-typedef enum {
-       MPLAYER_DISPLAY_TYPE_OVERLAY = 0,        /**< Overlay surface display */
-       MPLAYER_DISPLAY_TYPE_EVAS = 3,           /**< Evas image object surface display (Since 4.0) */
-       MPLAYER_DISPLAY_TYPE_NONE = 4,           /**< This disposes of buffers (Since 4.0) */
-} mplayer_display_type_e;
-
-typedef struct mplayer_fp {
-       /* create & destroy */
-       mplayer_error_t (*create)(void **mplayer_handle);
-       mplayer_error_t (*destroy)(void *mplayer_handle);
-       mplayer_error_t (*set_uri)(void *mplayer_handle, const char *uri);
-       mplayer_error_t (*set_display)(void *mplayer_handle, int type, void *display);
-       mplayer_error_t (*prepare)(void *mplayer_handle);
-       mplayer_error_t (*unprepare)(void *mplayer_handle);
-       mplayer_error_t (*start)(void *mplayer_handle);
-       mplayer_error_t (*stop)(void *mplayer_handle);
-       mplayer_error_t (*pause)(void *mplayer_handle);
-       mplayer_error_t (*set_play_position)(void *mplayer_handle, int msec, bool accurate);
-       mplayer_error_t (*get_play_position)(void *mplayer_handle, int *msec);
-} mplayer_fp_t;
-
-mplayer_error_t mplayer_create(void **mplayer_handle);
-mplayer_error_t mplayer_destroy(void *mplayer_handle);
-mplayer_error_t mplayer_set_uri(void *mplayer_handle, const char *uri);
-mplayer_error_t mplayer_set_display(void *mplayer_handle, int type, void *display);
-mplayer_error_t mplayer_prepare(void *mplayer_handle);
-mplayer_error_t mplayer_unprepare(void *mplayer_handle);
-mplayer_error_t mplayer_start(void *mplayer_handle);
-mplayer_error_t mplayer_stop(void *mplayer_handle);
-mplayer_error_t mplayer_pause(void *mplayer_handle);
-mplayer_error_t mplayer_set_play_position(void *mplayer_handle, int msec, bool accurate);
-mplayer_error_t mplayer_get_play_position(void *mplayer_handle, int *msec);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_H__ */
\ No newline at end of file
index c68b10b48334eb25b84d9fbedc53e5dad66cad87..e72d1a11a0fe1152adbd6967323a7e7eab8e4dc2 100644 (file)
 
 #define LIB_TIZEN_PLAYER PATH_LIBDIR"/librose-tizen-mplayer.so"
 
-#define MPLAYER_INTF_CHECK_ARG(x_handle)                                       \
-do {                                                                                           \
-       if (!x_handle) {                                                                        \
-               LOGE("%s argument is NULL", #x_handle);                 \
-               return MPLAYER_ERROR_INVALID_PARAMETER; \
-       }                                                                                               \
+#define MPLAYER_INTF_CHECK_ARG(x_handle) \
+do { \
+       if (!x_handle) { \
+               LOGE("%s argument is NULL", #x_handle); \
+               return MPLAYER_ERROR_INVALID_PARAMETER; \
+       } \
 } while (0)
 
 int _rose_mplayer_create(mplayer_interface **handle)
@@ -272,4 +272,4 @@ int _rose_mplayer_get_position(mplayer_interface *handle, int *msec)
        *msec = get_msec;
 
        return ret;
-}
\ No newline at end of file
+}
index 49f9964946c93e54d8a8e2a6af07906496d22bff..6b7cfa97920a84fd799f9bf7169068915725224a 100644 (file)
@@ -14,7 +14,6 @@
 * limitations under the License.
 */
 
-
 #ifndef __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_INTERFACE_H__
 #define __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_INTERFACE_H__
 
@@ -49,4 +48,4 @@ int _rose_mplayer_get_position(mplayer_interface *handle, int *msec);
 }
 #endif /* __cplusplus */
 
-#endif /* __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_INTERFACE_H__ */
\ No newline at end of file
+#endif /* __TIZEN_MEDIA_ROSE_TIZEN_MPLAYER_INTERFACE_H__ */
index 9cca1c23323efd813d65cf36c400e836df24d3db..cda1417c4d942b10819d6bb7082ce197574c9a86 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-rose-tizen
 Summary:    For RoSE(Representation Of Sensory Effect) APIs
-Version:    0.0.6
+Version:    0.0.7
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index de4f0db6339eeb21724b8abc63433e98043fad7d..dd5bbdab7e3e58038419be2207530a941bf7dd5e 100644 (file)
@@ -18,7 +18,7 @@
 #include <stdlib.h>
 #include "rose_tizen_priv.h"
 
-static gpointer _rose_render_thread (gpointer data);
+static gpointer _rose_render_thread(gpointer data);
 static gint _wait_to_render(gpointer data);
 static gboolean _create_render_thread(rose_s *handle);
 static void _destroy_render_thread(rose_s *handle);
@@ -27,7 +27,7 @@ static void _rose_apply_delay(rose_s *handle);
 static void _start_mplayer(rose_s *handle);
 static guint _calc_wait_time(gint64 next_pts, gint64 cur_pts);
 
-int rose_create(rose_h * rose)
+int rose_create(rose_h *rose)
 {
        int ret = ROSE_ERROR_NONE;
        rose_s *handle;
@@ -38,7 +38,7 @@ int rose_create(rose_h * rose)
                return ROSE_ERROR_INVALID_OPERATION;
        }
 
-       handle = (rose_s *) g_new0(rose_s, 1);
+       handle = (rose_s *)g_new0(rose_s, 1);
        ret = _rose_mplayer_create(&handle->mplayer_intf);
        if (ret) {
                LOGE("Failed to create mplayer handle %d", ret);
@@ -46,11 +46,24 @@ int rose_create(rose_h * rose)
                return ROSE_ERROR_INVALID_OPERATION;
        }
 
+       ret = _rose_device_ctl_create(&handle->device_ctl_intf);
+       if (ret) {
+               LOGE("Failed to create device ctl handle %d", ret);
+               goto ERROR;
+       }
+
        ROSE_SET_STATE(handle, ROSE_STATE_IDLE);
 
-       *rose = (rose_h) handle;
+       *rose = (rose_h)handle;
 
        return ret;
+
+ERROR:
+       if (handle->mplayer_intf)
+               _rose_mplayer_destroy(handle->mplayer_intf);
+
+       ROSE_G_FREE_IF(handle);
+       return ROSE_ERROR_INVALID_OPERATION;
 }
 
 int rose_destroy(rose_h rose)
@@ -60,7 +73,7 @@ int rose_destroy(rose_h rose)
 
        ROSE_CHECK_INSTANCE(rose);
 
-       handle = (rose_s *) rose;
+       handle = (rose_s *)rose;
        if (handle->sem) {
                rose_sem_free(handle->sem);
                handle->sem = NULL;
@@ -71,8 +84,12 @@ int rose_destroy(rose_h rose)
                handle->ctl_info = NULL;
        }
 
+       ret = _rose_device_ctl_destroy(handle->device_ctl_intf);
+       if (ret)
+               LOGE("Failed to destroy device control handle %d", ret);
+
        ret = _rose_mplayer_destroy(handle->mplayer_intf);
-       if (ret) // need to check error handling
+       if (ret)
                LOGE("Failed to destroy mplayer handle %d", ret);
 
        ROSE_G_FREE_IF(handle->sem_path);
@@ -86,7 +103,7 @@ int rose_destroy(rose_h rose)
 int rose_set_sem_path(rose_h rose, const char *path)
 {
        int ret = ROSE_ERROR_NONE;
-       rose_s *handle = (rose_s *) rose;
+       rose_s *handle = (rose_s *)rose;
        xmlDocPtr doc = NULL;
        xmlNodePtr root_element = NULL;
 
@@ -116,7 +133,7 @@ int rose_set_sem_path(rose_h rose, const char *path)
        }
 
        if (root_element->type != XML_ELEMENT_NODE
-               || xmlStrstr(root_element->name, (xmlChar *) "SEM") == NULL) {
+               || xmlStrstr(root_element->name, (xmlChar *)"SEM") == NULL) {
                LOGE("can not find the root element SEM, failed to parse the SEM file");
                ret = ROSE_ERROR_INVALID_OPERATION;
                goto ERROR;
@@ -135,7 +152,7 @@ ERROR:
 int rose_set_control_info_path(rose_h rose, const char *path)
 {
        int ret = ROSE_ERROR_NONE;
-       rose_s *handle = (rose_s *) rose;
+       rose_s *handle = (rose_s *)rose;
        xmlDocPtr doc = NULL;
        xmlNodePtr root_element = NULL;
 
@@ -165,7 +182,7 @@ int rose_set_control_info_path(rose_h rose, const char *path)
        }
 
        if (root_element->type != XML_ELEMENT_NODE
-               || xmlStrstr(root_element->name, (xmlChar *) "ControlInfo") == NULL) {
+               || xmlStrstr(root_element->name, (xmlChar *)"ControlInfo") == NULL) {
                LOGE("can not find the root element ControlInfo, failed to parse the ControlInfo file");
                ret = ROSE_ERROR_INVALID_OPERATION;
                goto ERROR;
@@ -238,6 +255,20 @@ int rose_prepare(rose_h rose)
 
        _rose_apply_delay(handle);
 
+       if (handle->ctl_info) {
+               ret = _rose_device_ctl_set_info(handle->device_ctl_intf, handle->ctl_info);
+               if (ret) {
+                       LOGE("Failed to set device ctl info %d", ret);
+                       goto ERROR;
+               }
+       }
+
+       ret = _rose_device_ctl_prepare(handle->device_ctl_intf);
+       if (ret) {
+               LOGE("Failed to prepare device ctl %d", ret);
+               goto ERROR;
+       }
+
        ret = _rose_mplayer_prepare(handle->mplayer_intf);
        if (ret) {
                LOGE("Failed to prepare player %d", ret);
@@ -250,6 +281,7 @@ int rose_prepare(rose_h rose)
 
 ERROR:
        _rose_mplayer_unprepare(handle->mplayer_intf);
+       _rose_device_ctl_unprepare(handle->device_ctl_intf);
        _destroy_render_thread(handle);
        ROSE_G_FREE_IF(handle->renderer);
        return ret;
@@ -264,6 +296,10 @@ int rose_unprepare(rose_h rose)
        ROSE_CHECK_INSTANCE(handle->mplayer_intf);
        ROSE_CHECK_STATE(handle, ROSE_STATE_READY);
 
+       ret = _rose_device_ctl_unprepare(handle->device_ctl_intf);
+       if (ret)
+               LOGE("Failed to unprepare device ctl %d", ret);
+
        ret = _rose_mplayer_unprepare(handle->mplayer_intf);
        if (ret)
                LOGE("Failed to unprepare player %d", ret);
@@ -306,7 +342,7 @@ int rose_stop(rose_h rose)
        ROSE_CHECK_INSTANCE(handle->renderer);
        ROSE_CHECK_STATE(handle, ROSE_STATE_PLAYING);
 
-       /* pause render thread*/
+       /* pause render thread */
        renderer = ROSE_GET_RENDERER(handle);
        renderer->thread_pause = TRUE;
        if (renderer->wait_timer != 0) {
@@ -341,7 +377,7 @@ int rose_pause(rose_h rose)
        ROSE_CHECK_INSTANCE(handle->renderer);
        ROSE_CHECK_STATE(handle, ROSE_STATE_PLAYING);
 
-       /* pause render thread*/
+       /* pause render thread */
        renderer = ROSE_GET_RENDERER(handle);
        renderer->thread_pause = TRUE;
        if (renderer->wait_timer != 0) {
@@ -392,7 +428,7 @@ static void _resync_base_time(rose_s *handle)
 
        if (renderer->base_clock == 0) {
                _RENDER_CLOCK_MUTEX_LOCK(renderer);
-               renderer->base_clock = g_get_monotonic_time() + renderer->time_offset * G_GINT64_CONSTANT (1000);
+               renderer->base_clock = g_get_monotonic_time() + renderer->time_offset * G_GINT64_CONSTANT(1000);
                _RENDER_CLOCK_MUTEX_UNLOCK(renderer);
                return;
        }
@@ -408,13 +444,14 @@ static void _resync_base_time(rose_s *handle)
 
        _RENDER_CLOCK_MUTEX_LOCK(renderer);
        renderer->base_clock = g_get_monotonic_time()
-                                                       + renderer->time_offset * G_GINT64_CONSTANT (1000)
-                                                       - (gint64)(get_msec * G_GINT64_CONSTANT (1000));
+               + renderer->time_offset * G_GINT64_CONSTANT(1000)
+               - (gint64)(get_msec * G_GINT64_CONSTANT(1000));
        _RENDER_CLOCK_MUTEX_UNLOCK(renderer);
 }
 
-static gpointer _rose_render_thread (gpointer data)
+static gpointer _rose_render_thread(gpointer data)
 {
+       int ret = ROSE_ERROR_NONE;
        rose_s *handle = (rose_s *)data;
        rose_render *renderer = NULL;
        rose_sem *sem = NULL;
@@ -472,8 +509,7 @@ static gpointer _rose_render_thread (gpointer data)
                        wait_time = _calc_wait_time(0, cur_pts);
                        LOGD("Need to mplayer start");
                        LOGD("add wait timer %u ms", wait_time);
-                       renderer->wait_timer = g_timeout_add((guint)wait_time,
-                                                                       (GSourceFunc)_wait_to_render, handle);
+                       renderer->wait_timer = g_timeout_add(wait_time, (GSourceFunc)_wait_to_render, handle);
                        _RENDER_COND_WAIT(renderer);
                        _start_mplayer(handle);
                        cur_pts = 0;
@@ -484,8 +520,7 @@ static gpointer _rose_render_thread (gpointer data)
                wait_time = _calc_wait_time(next_pts, cur_pts);
                LOGD("add wait timer %u ms", wait_time);
                renderer->cur_sem_list = next_list;
-               renderer->wait_timer = g_timeout_add((guint)wait_time,
-                                                               (GSourceFunc)_wait_to_render, handle);
+               renderer->wait_timer = g_timeout_add(wait_time, (GSourceFunc)_wait_to_render, handle);
                _RENDER_COND_WAIT(renderer);
                if (renderer->thread_pause || renderer->thread_exit)
                        continue;
@@ -496,6 +531,9 @@ static gpointer _rose_render_thread (gpointer data)
                if (renderer->thread_exit)
                        break;
 
+               ret = _rose_device_ctl_activate(handle->device_ctl_intf, cur_list->data);
+               if (ret)
+                       LOGW("Error activate device control");
                cur_list = cur_list->next;
        }
 
@@ -523,7 +561,6 @@ static gint _wait_to_render(gpointer data)
 
        LOGD("Called wait_render timer");
        g_usleep(1000);
-       //_resync_base_time(handle);
 
        if (!renderer->mplayer_is_started)
                render_time = 0;
@@ -534,7 +571,7 @@ static gint _wait_to_render(gpointer data)
                running_time = _get_running_time(renderer);
                if (running_time >= render_time)
                        break;
-               g_usleep((render_time - running_time) * G_GINT64_CONSTANT (1000));
+               g_usleep((render_time - running_time) * G_GINT64_CONSTANT(1000));
        }
 
 ERROR:
@@ -548,7 +585,7 @@ static gint64 _get_running_time(rose_render *renderer)
        gint64 running_time = -1;
        ROSE_CHECK_CONDITION(renderer, -1, "Renderer is NULL");
        _RENDER_CLOCK_MUTEX_LOCK(renderer);
-       running_time = (g_get_monotonic_time() - renderer->base_clock ) / G_GINT64_CONSTANT (1000);
+       running_time = (g_get_monotonic_time() - renderer->base_clock) / G_GINT64_CONSTANT(1000);
        _RENDER_CLOCK_MUTEX_UNLOCK(renderer);
        return running_time;
 }
@@ -565,8 +602,7 @@ static gboolean _create_render_thread(rose_s *handle)
        _RENDER_COND_INIT(handle->renderer);
        _RENDER_PAUSE_COND_INIT(handle->renderer);
 
-       handle->renderer->thread = g_thread_new ("thread",
-                                                                       (GThreadFunc)_rose_render_thread, handle);
+       handle->renderer->thread = g_thread_new("Render thread", (GThreadFunc)_rose_render_thread, handle);
        if (handle->renderer->thread == NULL) {
                LOGE("Failed to create render thread");
                return FALSE;
@@ -586,7 +622,7 @@ static void _destroy_render_thread(rose_s *handle)
 
        renderer->thread_exit = TRUE;
        renderer->thread_pause = FALSE;
-       if (renderer->wait_timer > 0) {
+       if (renderer->wait_timer != 0) {
                g_source_remove(renderer->wait_timer);
                renderer->wait_timer = 0;
        }
@@ -618,7 +654,7 @@ static void _rose_apply_delay(rose_s *handle)
 
        for (; sem_node; sem_node = sem_node->next) {
                sem_element = (rose_sem_effect_elements *)sem_node->data;
-               delay = rose_ctl_get_total_delay_time(ctl_info, (int) sem_element->type);
+               delay = rose_ctl_get_total_delay_time(ctl_info, (int)sem_element->type);
                if (delay != G_MAXUINT)
                        sem_element->delay_time = delay;
        }
@@ -634,7 +670,6 @@ static void _rose_apply_delay(rose_s *handle)
                handle->renderer->time_offset = time_offset;
 
        LOGD("Time offset = [%" G_GINT64_FORMAT "]", time_offset);
-
 }
 
 static void _start_mplayer(rose_s *handle)
@@ -666,4 +701,4 @@ static guint _calc_wait_time(gint64 next_pts, gint64 cur_pts)
                wait_time = next_pts - cur_pts - DEFAULT_CHECK_TIME_MS;
 
        return wait_time;
-}
\ No newline at end of file
+}
index 420563cf9cac446a242082ee1256a6d011da4989..bcdec56afa9f165c2a9b6262cd0ace068ae9da69 100644 (file)
 #include "rose_tizen_priv.h"
 #include "rose_tizen_parse_xml.h"
 
-static gboolean _parse_namespace(xmlNode * node, rose_control_info *ctl_info);
-static void _free_namespace(rose_sdc_namespace * namespace);
-static gboolean _get_xml_prop_sdc_type(xmlNode * node,
-       const gchar * property_name, rose_sdc_type_e * property_value);
-
-static gboolean _parse_sdc_element(xmlNode * node, rose_control_info *ctl_info);
-static gboolean _parse_sdc_list(xmlNode * node, rose_control_info *ctl_info);
-static gboolean _parse_sdc_light_type(xmlNode * node, rose_sdc_light **light);
-static gboolean _parse_sdc_flash_type(xmlNode * node, rose_sdc_flash **flash);
-static gboolean _parse_sdc_wind_type(xmlNode * node, rose_sdc_wind **wind);
-static gboolean _parse_sdc_vibration_type(xmlNode * node, rose_sdc_vibration **vibration);
-
-static void _free_sdc_element(rose_sdc_element * sdc_element);
+static gboolean _parse_namespace(xmlNode *node, rose_control_info *ctl_info);
+static void _free_namespace(rose_sdc_namespace *namespace);
+static gboolean _get_xml_prop_sdc_type(xmlNode *node,
+       const gchar *property_name, rose_sdc_type_e *property_value);
+
+static gboolean _parse_sdc_element(xmlNode *node, rose_control_info *ctl_info);
+static gboolean _parse_sdc_list(xmlNode *node, rose_control_info *ctl_info);
+static gboolean _parse_sdc_light_type(xmlNode *node, rose_sdc_light **light);
+static gboolean _parse_sdc_flash_type(xmlNode *node, rose_sdc_flash **flash);
+static gboolean _parse_sdc_wind_type(xmlNode *node, rose_sdc_wind **wind);
+static gboolean _parse_sdc_vibration_type(xmlNode *node, rose_sdc_vibration **vibration);
+
+static void _free_sdc_element(rose_sdc_element *sdc_element);
 static void _free_sdc_light_type(rose_sdc_light *light);
 static void _free_sdc_flash_type(rose_sdc_flash *flash);
 static void _free_sdc_wind_type(rose_sdc_wind *wind);
 static void _free_sdc_vibration_type(rose_sdc_vibration *vibration);
 
-static gboolean _parse_namespace(xmlNode * node, rose_control_info *ctl_info)
+static gboolean _parse_namespace(xmlNode *node, rose_control_info *ctl_info)
 {
        xmlNs *curr_ns;
        gboolean exist = FALSE;
@@ -60,7 +60,7 @@ static gboolean _parse_namespace(xmlNode * node, rose_control_info *ctl_info)
        return exist;
 }
 
-static void _free_namespace(rose_sdc_namespace * namespace)
+static void _free_namespace(rose_sdc_namespace *namespace)
 {
        if (!namespace)
                return;
@@ -73,17 +73,15 @@ static void _free_namespace(rose_sdc_namespace * namespace)
        g_slice_free(rose_sdc_namespace, namespace);
 }
 
-int rose_ctl_info_parse(xmlNode * node, rose_control_info ** ctl_info)
+int rose_ctl_info_parse(xmlNode *node, rose_control_info **ctl_info)
 {
        xmlNode *cur_node;
-       rose_control_info * new_ctl_info;
+       rose_control_info *new_ctl_info;
        int ret = ROSE_ERROR_NONE;
        gboolean exist = FALSE;
 
        ROSE_CHECK_INSTANCE(ctl_info);
 
-       rose_ctl_info_free(*ctl_info);
-
        new_ctl_info = g_slice_new0(rose_control_info);
 
        LOGD("namespaces of root ControlInfo node:");
@@ -109,12 +107,13 @@ int rose_ctl_info_parse(xmlNode * node, rose_control_info ** ctl_info)
                ret = ROSE_ERROR_INVALID_OPERATION;
        }
 
+       rose_ctl_info_free(*ctl_info);
        *ctl_info = new_ctl_info;
 
        return ret;
 }
 
-static gboolean _parse_sdc_list(xmlNode * node, rose_control_info *ctl_info)
+static gboolean _parse_sdc_list(xmlNode *node, rose_control_info *ctl_info)
 {
        gboolean exist = FALSE;
        xmlNode *cur_node;
@@ -134,7 +133,7 @@ static gboolean _parse_sdc_list(xmlNode * node, rose_control_info *ctl_info)
        return exist;
 }
 
-static gboolean _parse_sdc_element(xmlNode * node, rose_control_info *ctl_info)
+static gboolean _parse_sdc_element(xmlNode *node, rose_control_info *ctl_info)
 {
        rose_sdc_element *new_sdc_element = NULL;
        gboolean exist = FALSE;
@@ -180,10 +179,10 @@ static gboolean _parse_sdc_element(xmlNode * node, rose_control_info *ctl_info)
 
        ctl_info->sdc_elements = g_list_append(ctl_info->sdc_elements, new_sdc_element);
 
-       return exist;
+       return TRUE;
 }
 
-static gboolean _get_xml_prop_sdc_type(xmlNode * node, const gchar * property_name, rose_sdc_type_e * property_value)
+static gboolean _get_xml_prop_sdc_type(xmlNode *node, const gchar *property_name, rose_sdc_type_e *property_value)
 {
        xmlChar *prop_string;
        gboolean exists = TRUE;
@@ -217,11 +216,10 @@ static gboolean _get_xml_prop_sdc_type(xmlNode * node, const gchar * property_na
        return exists;
 }
 
-static gboolean _parse_sdc_light_type(xmlNode * node, rose_sdc_light **light)
+static gboolean _parse_sdc_light_type(xmlNode *node, rose_sdc_light **light)
 {
        rose_sdc_light *new_light = NULL;
        gboolean exist = FALSE;
-       // xmlNode *cur_node;
 
        ROSE_CHECK_NULL_FALSE(light);
 
@@ -237,16 +235,7 @@ static gboolean _parse_sdc_light_type(xmlNode * node, rose_sdc_light **light)
        exist |= new_light->num_of_light_levels_flag
                        = _get_xml_prop_unsigned_integer(node, "numOfLightLevels",
                                        &new_light->num_of_light_levels);
-#if 0
-/* need to check color element */
-       for (cur_node = node->children; cur_node; cur_node = cur_node->next) {
-               if (cur_node->type != XML_ELEMENT_NODE)
-                       continue;
-               if (xmlStrstr(cur_node->name, (xmlChar *) "Color")) {
-                       gchar *color = NULL;
-               }
-       }
-#endif
+
        if (!exist) {
                g_slice_free(rose_sdc_light, new_light);
                new_light = NULL;
@@ -259,7 +248,7 @@ static gboolean _parse_sdc_light_type(xmlNode * node, rose_sdc_light **light)
        return TRUE;
 }
 
-static gboolean _parse_sdc_flash_type(xmlNode * node, rose_sdc_flash **flash)
+static gboolean _parse_sdc_flash_type(xmlNode *node, rose_sdc_flash **flash)
 {
        rose_sdc_flash *new_flash = NULL;
        gboolean exist = FALSE;
@@ -289,7 +278,7 @@ static gboolean _parse_sdc_flash_type(xmlNode * node, rose_sdc_flash **flash)
        return TRUE;
 }
 
-static gboolean _parse_sdc_wind_type(xmlNode * node, rose_sdc_wind **wind)
+static gboolean _parse_sdc_wind_type(xmlNode *node, rose_sdc_wind **wind)
 {
        rose_sdc_wind *new_wind = NULL;
        gboolean exist = FALSE;
@@ -321,7 +310,7 @@ static gboolean _parse_sdc_wind_type(xmlNode * node, rose_sdc_wind **wind)
        return TRUE;
 }
 
-static gboolean _parse_sdc_vibration_type(xmlNode * node, rose_sdc_vibration **vibration)
+static gboolean _parse_sdc_vibration_type(xmlNode *node, rose_sdc_vibration **vibration)
 {
        rose_sdc_vibration *new_vibration = NULL;
        gboolean exist = FALSE;
@@ -355,42 +344,42 @@ static gboolean _parse_sdc_vibration_type(xmlNode * node, rose_sdc_vibration **v
 
 static void _free_sdc_light_type(rose_sdc_light *light)
 {
-       if (!light)
-               return;
+       ROSE_CHECK_NULL_VOID(light);
+
        g_list_free_full(light->color, g_free);
-       g_free(light->unit);
+       ROSE_G_FREE_IF(light->unit);
        g_slice_free(rose_sdc_light, light);
 }
 
 static void _free_sdc_flash_type(rose_sdc_flash *flash)
 {
-       if (!flash)
-               return;
+       ROSE_CHECK_NULL_VOID(flash);
+
        _free_sdc_light_type(flash->light);
        g_slice_free(rose_sdc_flash, flash);
 }
 
 static void _free_sdc_wind_type(rose_sdc_wind *wind)
 {
-       if (!wind)
-               return;
-       g_free(wind->unit);
+       ROSE_CHECK_NULL_VOID(wind);
+
+       ROSE_G_FREE_IF(wind->unit);
        g_slice_free(rose_sdc_wind, wind);
 }
 
 static void _free_sdc_vibration_type(rose_sdc_vibration *vibration)
 {
-       if (!vibration)
-               return;
-       g_free(vibration->unit);
+       ROSE_CHECK_NULL_VOID(vibration);
+
+       ROSE_G_FREE_IF(vibration->unit);
        g_slice_free(rose_sdc_vibration, vibration);
 }
 
-static void _free_sdc_element(rose_sdc_element * sdc_element)
+static void _free_sdc_element(rose_sdc_element *sdc_element)
 {
-       if (!sdc_element)
-               return;
-       g_free (sdc_element->id);
+       ROSE_CHECK_NULL_VOID(sdc_element);
+
+       ROSE_G_FREE_IF(sdc_element->id);
        _free_sdc_light_type(sdc_element->light);
        _free_sdc_flash_type(sdc_element->flash);
        _free_sdc_wind_type(sdc_element->wind);
@@ -399,13 +388,12 @@ static void _free_sdc_element(rose_sdc_element * sdc_element)
        g_slice_free(rose_sdc_element, sdc_element);
 }
 
-void rose_ctl_info_free(rose_control_info * ctl_info)
+void rose_ctl_info_free(rose_control_info *ctl_info)
 {
-       if (!ctl_info)
-               return;
+       ROSE_CHECK_NULL_VOID(ctl_info);
 
-       g_list_free_full(ctl_info->namespace, (GDestroyNotify) _free_namespace);
-       g_list_free_full(ctl_info->sdc_elements, (GDestroyNotify) _free_sdc_element);
+       g_list_free_full(ctl_info->namespace, (GDestroyNotify)_free_namespace);
+       g_list_free_full(ctl_info->sdc_elements, (GDestroyNotify)_free_sdc_element);
 
        g_slice_free(rose_control_info, ctl_info);
 }
@@ -427,7 +415,7 @@ guint rose_ctl_get_total_delay_time(rose_control_info * ctl_info, rose_sdc_type_
        guint delay_time = G_MAXUINT;
        ROSE_CHECK_CONDITION(ctl_info, G_MAXUINT, "ctl_info is NULL");
 
-       r_list = g_list_find_custom (ctl_info->sdc_elements, &type, (GCompareFunc) _compare_type);
+       r_list = g_list_find_custom(ctl_info->sdc_elements, &type, (GCompareFunc)_compare_type);
        if (!r_list) {
                LOGW("[%d] type is not on the list", type);
                return delay_time;
@@ -435,6 +423,5 @@ guint rose_ctl_get_total_delay_time(rose_control_info * ctl_info, rose_sdc_type_
 
        sdc_elem = (rose_sdc_element *)r_list->data;
        delay_time = sdc_elem->firstorderdelaytime + sdc_elem->zerothorderdelaytime;
-       LOGD("[%d type] delay time is [%u]", type, delay_time);
        return delay_time;
-}
\ No newline at end of file
+}
index e8e5afd9f2069ef5977709d78b06014c4090c983..899b0f4f50c98772ef6da4d5ed7b96e21e4d89af 100644 (file)
@@ -17,7 +17,7 @@
 #include "rose_tizen_priv.h"
 #include "rose_tizen_parse_xml.h"
 
-gboolean _get_xml_prop_string(xmlNode * node, const gchar * prop_name, gchar ** prop_value)
+gboolean _get_xml_prop_string(xmlNode *node, const gchar *prop_name, gchar **prop_value)
 {
        xmlChar *prop_string;
 
@@ -25,13 +25,13 @@ gboolean _get_xml_prop_string(xmlNode * node, const gchar * prop_name, gchar **
        if (!prop_string)
                return FALSE;
 
-       *prop_value = (gchar *) prop_string;
+       *prop_value = (gchar *)prop_string;
        LOGD(" - %s: %s", prop_name, prop_string);
 
        return TRUE;
 }
 
-gboolean _get_xml_prop_boolean(xmlNode * node, const gchar * prop_name, gboolean * prop_value)
+gboolean _get_xml_prop_boolean(xmlNode *node, const gchar *prop_name, gboolean *prop_value)
 {
        xmlChar *prop_string;
        gboolean exists = TRUE;
@@ -40,10 +40,10 @@ gboolean _get_xml_prop_boolean(xmlNode * node, const gchar * prop_name, gboolean
        if (!prop_string)
                return FALSE;
 
-       if (xmlStrstr(prop_string, (xmlChar *) "false")) {
+       if (xmlStrstr(prop_string, (xmlChar *)"false")) {
                *prop_value = FALSE;
                LOGD(" - %s: false", prop_name);
-       } else if (xmlStrstr(prop_string, (xmlChar *) "true")) {
+       } else if (xmlStrstr(prop_string, (xmlChar *)"true")) {
                *prop_value = TRUE;
                LOGD(" - %s: true", prop_name);
        } else {
@@ -56,7 +56,7 @@ gboolean _get_xml_prop_boolean(xmlNode * node, const gchar * prop_name, gboolean
        return exists;
 }
 
-gboolean _get_xml_prop_signed_integer(xmlNode * node, const gchar * prop_name, gint * prop_value)
+gboolean _get_xml_prop_signed_integer(xmlNode *node, const gchar *prop_name, gint *prop_value)
 {
        xmlChar *prop_string;
        gboolean exists = TRUE;
@@ -65,12 +65,11 @@ gboolean _get_xml_prop_signed_integer(xmlNode * node, const gchar * prop_name, g
        if (!prop_string)
                return FALSE;
 
-       if (sscanf((gchar *) prop_string, "%d", prop_value) == 1 && strstr((gchar *) prop_string, "-") == NULL) {
+       if (sscanf((gchar *)prop_string, "%d", prop_value) == 1 && strstr((gchar *)prop_string, "-") == NULL) {
                LOGD(" - %s: %u", prop_name, *prop_value);
        } else {
                exists = FALSE;
                LOGW("failed to parse signed integer property %s from xml string %s", prop_name, prop_string);
-               /* sscanf might have written to *prop_value. Restore to default */
        }
 
        xmlFree(prop_string);
@@ -78,7 +77,7 @@ gboolean _get_xml_prop_signed_integer(xmlNode * node, const gchar * prop_name, g
        return exists;
 }
 
-gboolean _get_xml_prop_unsigned_integer(xmlNode * node, const gchar * prop_name, guint * prop_value)
+gboolean _get_xml_prop_unsigned_integer(xmlNode *node, const gchar *prop_name, guint *prop_value)
 {
        xmlChar *prop_string;
        gboolean exists = TRUE;
@@ -87,12 +86,11 @@ gboolean _get_xml_prop_unsigned_integer(xmlNode * node, const gchar * prop_name,
        if (!prop_string)
                return FALSE;
 
-       if (sscanf((gchar *) prop_string, "%u", prop_value) == 1 && strstr((gchar *) prop_string, "-") == NULL) {
+       if (sscanf((gchar *)prop_string, "%u", prop_value) == 1 && strstr((gchar *)prop_string, "-") == NULL) {
                LOGD(" - %s: %u", prop_name, *prop_value);
        } else {
                exists = FALSE;
                LOGW("failed to parse unsigned integer property %s from xml string %s", prop_name, prop_string);
-               /* sscanf might have written to *prop_value. Restore to default */
        }
 
        xmlFree(prop_string);
@@ -100,7 +98,7 @@ gboolean _get_xml_prop_unsigned_integer(xmlNode * node, const gchar * prop_name,
        return exists;
 }
 
-gboolean _get_xml_prop_float(xmlNode * node, const gchar * prop_name, gfloat * prop_value)
+gboolean _get_xml_prop_float(xmlNode *node, const gchar *prop_name, gfloat *prop_value)
 {
        xmlChar *prop_string;
        gboolean exists = TRUE;
@@ -109,7 +107,7 @@ gboolean _get_xml_prop_float(xmlNode * node, const gchar * prop_name, gfloat * p
        if (!prop_string)
                return FALSE;
 
-       if (sscanf((gchar *) prop_string, "%f", prop_value) == 1) {
+       if (sscanf((gchar *)prop_string, "%f", prop_value) == 1) {
                LOGD(" - %s: %f", prop_name, *prop_value);
        } else {
                exists = FALSE;
index 66f32248aa93c752448ba5135cf13475ede736ac..485b66e11c1d0a3d2313ed3671fd80097d7b42d3 100644 (file)
 #include "rose_tizen_parse_xml.h"
 
 /* node parsing */
-static gboolean _parse_namespace(xmlNode * node, rose_sem * sem);
-static gboolean _parse_declarations(xmlNode * node, rose_sem * sem);
-static gboolean _parse_group_effect(xmlNode * node, rose_sem * sem);
-static gboolean _parse_effect(xmlNode * node, rose_sem * sem, rose_sem_base_attr *base_attr, rose_sem_si_attr *si_attr);
+static gboolean _parse_namespace(xmlNode *node, rose_sem *sem);
+static gboolean _parse_declarations(xmlNode *node, rose_sem *sem);
+static gboolean _parse_group_effect(xmlNode *node, rose_sem *sem);
+static gboolean _parse_effect(xmlNode *node, rose_sem *sem, rose_sem_base_attr *base_attr, rose_sem_si_attr *si_attr);
 
-static gboolean _parse_si_attr(xmlNode * node, rose_sem_si_attr ** si_attr);
-static gboolean _parse_effect_base_attr(xmlNode * node, rose_sem_base_attr ** attr);
+static gboolean _parse_si_attr(xmlNode *node, rose_sem_si_attr **si_attr);
+static gboolean _parse_effect_base_attr(xmlNode *node, rose_sem_base_attr **attr);
 
-static void _free_namespace(rose_sem_namespace * namespace);
+static void _free_namespace(rose_sem_namespace *namespace);
 static void _free_effect_elements(rose_sem_effect_elements *elements);
-static void _free_si_attr(rose_sem_si_attr * si_attr);
-static void _free_effect_base_attr(rose_sem_base_attr * attr);
+static void _free_si_attr(rose_sem_si_attr *si_attr);
+static void _free_effect_base_attr(rose_sem_base_attr *attr);
 
-static void _save_effect_base_attr(rose_sem_effect_elements *effect, rose_sem_base_attr * attr);
-static void _save_si_attr(rose_sem_effect_elements * effect, rose_sem_si_attr * attr);
+static void _save_effect_base_attr(rose_sem_effect_elements *effect, rose_sem_base_attr *attr);
+static void _save_si_attr(rose_sem_effect_elements *effect, rose_sem_si_attr *attr);
 
-static gboolean _get_xml_prop_effect_type(xmlNode * node, const gchar * property_name, rose_sem_effect_type_e * property_value)
+static gboolean _get_xml_prop_effect_type(xmlNode *node, const gchar *property_name, rose_sem_effect_type_e *property_value)
 {
        xmlChar *prop_string;
        gboolean exists = TRUE;
@@ -47,19 +47,19 @@ static gboolean _get_xml_prop_effect_type(xmlNode * node, const gchar * property
        if (!prop_string)
                return FALSE;
 
-       if (xmlStrstr(prop_string, (xmlChar *) "LightType")) {
+       if (xmlStrstr(prop_string, (xmlChar *)"LightType")) {
                *property_value = SEM_EFFECT_LIGHT;
                LOGD(" - %s: LightType", property_name);
-       } else if (xmlStrstr(prop_string, (xmlChar *) "FlashType")) {
+       } else if (xmlStrstr(prop_string, (xmlChar *)"FlashType")) {
                *property_value = SEM_EFFECT_FLASH;
                LOGD(" - %s: FlashType", property_name);
-       } else if (xmlStrstr(prop_string, (xmlChar *) "TemperatureType")) {
+       } else if (xmlStrstr(prop_string, (xmlChar *)"TemperatureType")) {
                *property_value = SEM_EFFECT_TEMPERATURE;
                LOGD(" - %s: TemperatureType", property_name);
-       } else if (xmlStrstr(prop_string, (xmlChar *) "WindType")) {
+       } else if (xmlStrstr(prop_string, (xmlChar *)"WindType")) {
                *property_value = SEM_EFFECT_WIND;
                LOGD(" - %s: WindType", property_name);
-       } else if (xmlStrstr(prop_string, (xmlChar *) "VibrationType")) {
+       } else if (xmlStrstr(prop_string, (xmlChar *)"VibrationType")) {
                *property_value = SEM_EFFECT_VIBRATION;
                LOGD(" - %s: VibrationType", property_name);
        } else {
@@ -72,7 +72,7 @@ static gboolean _get_xml_prop_effect_type(xmlNode * node, const gchar * property
        return exists;
 }
 
-static gboolean _get_xml_prop_intensity_range(xmlNode * node, const gchar * property_name, gfloat * min_intensity, gfloat * max_intensity)
+static gboolean _get_xml_prop_intensity_range(xmlNode *node, const gchar *property_name, gfloat *min_intensity, gfloat *max_intensity)
 {
        xmlChar *prop_string;
        gboolean exists = TRUE;
@@ -81,7 +81,7 @@ static gboolean _get_xml_prop_intensity_range(xmlNode * node, const gchar * prop
        if (!prop_string)
                return FALSE;
 
-       if (sscanf((gchar *) prop_string, "%f %f", min_intensity, max_intensity) == 2) {
+       if (sscanf((gchar *)prop_string, "%f %f", min_intensity, max_intensity) == 2) {
                LOGD(" - %s: %f %f", property_name, *min_intensity, *max_intensity);
        } else {
                exists = FALSE;
@@ -93,15 +93,13 @@ static gboolean _get_xml_prop_intensity_range(xmlNode * node, const gchar * prop
        return exists;
 }
 
-int rose_sem_parse(xmlNode * node, rose_sem ** sem)
+int rose_sem_parse(xmlNode *node, rose_sem **sem)
 {
        xmlNode *cur_node;
        rose_sem *new_sem;
        int ret = ROSE_ERROR_NONE;
        gboolean exist = FALSE;
 
-       rose_sem_free(*sem);
-       *sem = NULL;
 
        new_sem = g_slice_new0(rose_sem);
 
@@ -122,17 +120,17 @@ int rose_sem_parse(xmlNode * node, rose_sem ** sem)
        for (cur_node = node->children; cur_node; cur_node = cur_node->next) {
                if (cur_node->type != XML_ELEMENT_NODE)
                        continue;
-               if (xmlStrstr(cur_node->name, (xmlChar *) "Declarations")) {
+               if (xmlStrstr(cur_node->name, (xmlChar *)"Declarations")) {
                        LOGD("Parsing Declaration");
                        _parse_declarations(cur_node, new_sem);
-               } else if (xmlStrstr(cur_node->name, (xmlChar *) "GroupOfEffects")) {
+               } else if (xmlStrstr(cur_node->name, (xmlChar *)"GroupOfEffects")) {
                        _parse_group_effect(cur_node, new_sem);
-               } else if (xmlStrstr(cur_node->name, (xmlChar *) "Effect")) {
+               } else if (xmlStrstr(cur_node->name, (xmlChar *)"Effect")) {
                        _parse_effect(cur_node, new_sem, NULL, NULL);
                        LOGD("Parsing Effect");
-               } else if (xmlStrstr(cur_node->name, (xmlChar *) "ReferenceEffect")) {
+               } else if (xmlStrstr(cur_node->name, (xmlChar *)"ReferenceEffect")) {
                        LOGD("Parsing ReferenceEffect");
-               } else if (xmlStrstr(cur_node->name, (xmlChar *) "Parameter")) {
+               } else if (xmlStrstr(cur_node->name, (xmlChar *)"Parameter")) {
                        LOGD("Parsing Parameter");
                } else {
                        LOGW("there is no node in SEM");
@@ -146,6 +144,7 @@ int rose_sem_parse(xmlNode * node, rose_sem ** sem)
                ret = ROSE_ERROR_INVALID_OPERATION;
        }
 
+       rose_sem_free(*sem);
        *sem = new_sem;
 
        LOGD("complete parsing sem = %p", *sem);
@@ -153,25 +152,24 @@ int rose_sem_parse(xmlNode * node, rose_sem ** sem)
        return ret;
 }
 
-void rose_sem_free(rose_sem * sem)
+void rose_sem_free(rose_sem *sem)
 {
-       if (!sem)
-               return;
+       ROSE_CHECK_NULL_VOID(sem);
 
-       g_list_free_full(sem->namespace, (GDestroyNotify) _free_namespace);
-       g_list_free_full(sem->effect_elements, (GDestroyNotify) _free_effect_elements);
+       g_list_free_full(sem->namespace, (GDestroyNotify)_free_namespace);
+       g_list_free_full(sem->effect_elements, (GDestroyNotify)_free_effect_elements);
        _free_si_attr(sem->si_attr);
 
        g_slice_free(rose_sem, sem);
 }
 
-static gboolean _parse_namespace(xmlNode * node, rose_sem * sem)
+static gboolean _parse_namespace(xmlNode *node, rose_sem *sem)
 {
        xmlNs *curr_ns;
        gboolean exist = FALSE;
 
-       if (!sem || !node)
-               return FALSE;
+       ROSE_CHECK_NULL_FALSE(node);
+       ROSE_CHECK_NULL_FALSE(sem);
 
        g_list_free_full(sem->namespace, (GDestroyNotify) _free_namespace);
 
@@ -189,10 +187,9 @@ static gboolean _parse_namespace(xmlNode * node, rose_sem * sem)
        return exist;
 }
 
-static void _free_namespace(rose_sem_namespace * namespace)
+static void _free_namespace(rose_sem_namespace *namespace)
 {
-       if (!namespace)
-               return;
+       ROSE_CHECK_NULL_VOID(namespace);
 
        if (namespace->prefix)
                xmlFree(namespace->prefix);
@@ -202,19 +199,19 @@ static void _free_namespace(rose_sem_namespace * namespace)
        g_slice_free(rose_sem_namespace, namespace);
 }
 
-static gboolean _parse_declarations(xmlNode * node, rose_sem * sem)
+static gboolean _parse_declarations(xmlNode *node, rose_sem *sem)
 {
        gboolean exist = FALSE;
        xmlNode *cur_node;
 
        for (cur_node = node->children; cur_node; cur_node = cur_node->next) {
-               if (xmlStrstr(cur_node->name, (xmlChar *) "GroupOfEffects")) {
+               if (xmlStrstr(cur_node->name, (xmlChar *)"GroupOfEffects")) {
                        LOGD("Parsing ReferenceEffect");
                        exist |= _parse_group_effect(cur_node, sem);
-               } else if (xmlStrstr(cur_node->name, (xmlChar *) "Effect")) {
+               } else if (xmlStrstr(cur_node->name, (xmlChar *)"Effect")) {
                        LOGD("Parsing Effect");
                        exist |= _parse_effect(cur_node, sem, NULL, NULL);
-               } else if (xmlStrstr(cur_node->name, (xmlChar *) "Parameter")) {
+               } else if (xmlStrstr(cur_node->name, (xmlChar *)"Parameter")) {
                        LOGD("Parsing Parameter");
                } else {
                        LOGW("there is no node in SEM");
@@ -224,7 +221,7 @@ static gboolean _parse_declarations(xmlNode * node, rose_sem * sem)
        return exist;
 }
 
-static gboolean _parse_group_effect(xmlNode * node, rose_sem * sem)
+static gboolean _parse_group_effect(xmlNode *node, rose_sem *sem)
 {
        gboolean exist = FALSE;
        xmlNode *cur_node;
@@ -236,10 +233,10 @@ static gboolean _parse_group_effect(xmlNode * node, rose_sem * sem)
 
        for (cur_node = node->children; cur_node; cur_node = cur_node->next) {
                if (cur_node->type == XML_ELEMENT_NODE) {
-                       if (xmlStrstr(cur_node->name, (xmlChar *) "Effect")) {
+                       if (xmlStrstr(cur_node->name, (xmlChar *)"Effect")) {
                                LOGD("Parsing Effect");
                                exist |= _parse_effect(cur_node, sem, base_attr, si_attr);
-                       } else if (xmlStrstr(cur_node->name, (xmlChar *) "ReferenceEffect")) {
+                       } else if (xmlStrstr(cur_node->name, (xmlChar *)"ReferenceEffect")) {
                                LOGD("Parsing ReferenceEffect");
                        } else {
                                LOGW("there is no children node in GroupEffects");
@@ -253,7 +250,7 @@ static gboolean _parse_group_effect(xmlNode * node, rose_sem * sem)
        return exist;
 }
 
-static gboolean _parse_effect(xmlNode * node, rose_sem * sem,
+static gboolean _parse_effect(xmlNode *node, rose_sem *sem,
                                                                rose_sem_base_attr *base_attr,
                                                                rose_sem_si_attr *si_attr)
 {
@@ -268,7 +265,7 @@ static gboolean _parse_effect(xmlNode * node, rose_sem * sem,
 
        if (new_effect->type > SEM_EFFECT_NONE) {
                switch (new_effect->type) {
-               case SEM_EFFECT_FLASH:
+               case SEM_EFFECT_FLASH: // falls through
                        exist |= new_effect->frequency_flag = _get_xml_prop_unsigned_integer(node, "frequency", &new_effect->frequency);
                case SEM_EFFECT_LIGHT:
                        exist |= new_effect->color_type_flag = _get_xml_prop_string(node, "color", &new_effect->color_type);
@@ -301,28 +298,25 @@ static gboolean _parse_effect(xmlNode * node, rose_sem * sem,
 
        sem->effect_elements = g_list_append(sem->effect_elements, new_effect);
 
-       return exist;
+       return TRUE;
 }
 
-static void _free_si_attr(rose_sem_si_attr * si_attr)
+static void _free_si_attr(rose_sem_si_attr *si_attr)
 {
-       if (si_attr) {
-               if (si_attr->abs_time_scheme_flag)
-                       xmlFree(si_attr->abs_time_scheme);
-               if (si_attr->abs_time_flag)
-                       xmlFree(si_attr->abs_time);
-               g_slice_free(rose_sem_si_attr, si_attr);
-       }
+       ROSE_CHECK_NULL_VOID(si_attr);
+
+       if (si_attr->abs_time_scheme_flag)
+               xmlFree(si_attr->abs_time_scheme);
+       if (si_attr->abs_time_flag)
+               xmlFree(si_attr->abs_time);
+       g_slice_free(rose_sem_si_attr, si_attr);
 }
 
-static gboolean _parse_si_attr(xmlNode * node, rose_sem_si_attr ** si_attr)
+static gboolean _parse_si_attr(xmlNode *node, rose_sem_si_attr **si_attr)
 {
        rose_sem_si_attr *new_si_attr;
        gboolean exist = FALSE;
 
-       _free_si_attr(*si_attr);
-       *si_attr = NULL;
-
        new_si_attr = g_slice_new0(rose_sem_si_attr);
 
        exist |= new_si_attr->anchor_element_flag = _get_xml_prop_boolean(node, "anchorElement", &new_si_attr->anchor_element);
@@ -336,31 +330,30 @@ static gboolean _parse_si_attr(xmlNode * node, rose_sem_si_attr ** si_attr)
        if (!exist) {
                g_slice_free(rose_sem_si_attr, new_si_attr);
                new_si_attr = NULL;
+               return FALSE;
        }
 
+       _free_si_attr(*si_attr);
        *si_attr = new_si_attr;
 
-       return exist;
+       return TRUE;
 
 }
 
-static void _free_effect_base_attr(rose_sem_base_attr * attr)
+static void _free_effect_base_attr(rose_sem_base_attr *attr)
 {
-       if (attr) {
-               xmlFree(attr->alt);
-               xmlFree(attr->location);
-               g_slice_free(rose_sem_base_attr, attr);
-       }
+       ROSE_CHECK_NULL_VOID(attr);
+
+       xmlFree(attr->alt);
+       xmlFree(attr->location);
+       g_slice_free(rose_sem_base_attr, attr);
 }
 
-static gboolean _parse_effect_base_attr(xmlNode * node, rose_sem_base_attr ** attr)
+static gboolean _parse_effect_base_attr(xmlNode *node, rose_sem_base_attr **attr)
 {
        rose_sem_base_attr *new_attr;
        gboolean exist = FALSE;
 
-       _free_effect_base_attr(*attr);
-       *attr = NULL;
-
        new_attr = g_slice_new0(rose_sem_base_attr);
 
        exist |= new_attr->activate_flag = _get_xml_prop_boolean(node, "activate", &new_attr->activate);
@@ -373,17 +366,18 @@ static gboolean _parse_effect_base_attr(xmlNode * node, rose_sem_base_attr ** at
        if (!exist) {
                g_slice_free(rose_sem_base_attr, new_attr);
                new_attr = NULL;
+               return FALSE;
        }
 
+       _free_effect_base_attr(*attr);
        *attr = new_attr;
 
-       return exist;
+       return TRUE;
 }
 
-static void _save_effect_base_attr(rose_sem_effect_elements *effect, rose_sem_base_attr * attr)
+static void _save_effect_base_attr(rose_sem_effect_elements *effect, rose_sem_base_attr *attr)
 {
-       if (!effect || !attr)
-               return;
+       ROSE_CHECK_NULL_VOID(effect && attr);
 
        if (!effect->base_attr) {
                LOGD("copy parent base attr");
@@ -413,14 +407,13 @@ static void _save_effect_base_attr(rose_sem_effect_elements *effect, rose_sem_ba
 
        if (!effect->base_attr->location_flag && attr->location_flag) {
                effect->base_attr->location_flag = attr->location_flag;
-               strncpy(effect->base_attr->location, attr->location, strlen(attr->location));
+               strncpy(effect->base_attr->location, attr->location, strlen(attr->location) + 1);
        }
 }
 
-static void _save_si_attr(rose_sem_effect_elements * effect, rose_sem_si_attr * attr)
+static void _save_si_attr(rose_sem_effect_elements *effect, rose_sem_si_attr *attr)
 {
-       if (!effect || !attr)
-               return;
+       ROSE_CHECK_NULL_VOID(effect && attr);
 
        if (!effect->si_attr) {
                LOGD("copy parent si attr");
@@ -445,7 +438,7 @@ static void _save_si_attr(rose_sem_effect_elements * effect, rose_sem_si_attr *
 
        if (!effect->si_attr->abs_time_flag && attr->abs_time_flag) {
                effect->si_attr->abs_time_flag = attr->abs_time_flag;
-               strncpy(effect->si_attr->abs_time, attr->abs_time, strlen(attr->abs_time));
+               strncpy(effect->si_attr->abs_time, attr->abs_time, strlen(attr->abs_time) + 1);
        }
 
        if (!effect->si_attr->pts_flag && attr->pts_flag) {
@@ -454,12 +447,11 @@ static void _save_si_attr(rose_sem_effect_elements * effect, rose_sem_si_attr *
        }
 }
 
-static void _free_effect_elements(rose_sem_effect_elements * elements)
+static void _free_effect_elements(rose_sem_effect_elements *elements)
 {
-       if (!elements)
-               return;
+       ROSE_CHECK_NULL_VOID(elements);
 
-       g_free(elements->id)            ;
+       g_free(elements->id);
        g_free(elements->color_type);
        _free_effect_base_attr(elements->base_attr);
        _free_si_attr(elements->si_attr);
@@ -498,7 +490,7 @@ gint64 _rose_sem_get_render_time(rose_sem_effect_elements *effect, guint time_sc
        return time_with_delay;
 }
 
-gint _sort_element_pts (rose_sem_effect_elements *e1, rose_sem_effect_elements *e2, rose_sem *sem)
+gint _sort_element_pts(rose_sem_effect_elements *e1, rose_sem_effect_elements *e2, rose_sem *sem)
 {
        gint64 time1 = 0;
        gint64 time2 = 0;
@@ -522,36 +514,35 @@ void _rose_sem_sort_pts_with_delay(rose_sem *sem)
 }
 
 #ifdef __FOR_DEBUG
-const char * _convert_type_to_str(rose_sem_effect_type_e type)
+const char *_convert_type_to_str(rose_sem_effect_type_e type)
 {
        const char *msg;
        switch (type) {
-               case SEM_EFFECT_LIGHT:
-                       msg = "SEM_EFFECT_LIGHT";
-                       break;
-               case SEM_EFFECT_FLASH:
-                       msg = "SEM_EFFECT_FLASH";
-                       break;
-               case SEM_EFFECT_TEMPERATURE:
-                       msg = "SEM_EFFECT_TEMPERATURE";
-                       break;
-               case SEM_EFFECT_WIND:
-                       msg = "SEM_EFFECT_WIND";
-                       break;
-               case SEM_EFFECT_VIBRATION:
-                       msg = "SEM_EFFECT_VIBRATION";
-                       break;
-               default:
-                       msg = "SEM_EFFECT_UNKNOWN";
-                       break;
+       case SEM_EFFECT_LIGHT:
+               msg = "SEM_EFFECT_LIGHT";
+               break;
+       case SEM_EFFECT_FLASH:
+               msg = "SEM_EFFECT_FLASH";
+               break;
+       case SEM_EFFECT_TEMPERATURE:
+               msg = "SEM_EFFECT_TEMPERATURE";
+               break;
+       case SEM_EFFECT_WIND:
+               msg = "SEM_EFFECT_WIND";
+               break;
+       case SEM_EFFECT_VIBRATION:
+               msg = "SEM_EFFECT_VIBRATION";
+               break;
+       default:
+               msg = "SEM_EFFECT_UNKNOWN";
+               break;
        }
        return msg;
 }
 
-void _print_sem_data (rose_sem_effect_elements *effect, guint time_scale)
+void _print_sem_data(rose_sem_effect_elements *effect, guint time_scale)
 {
        ROSE_CHECK_NULL_VOID(effect);
-       // GString *string = g_string_new(NULL);
        LOGI("-----------------------------------------------------------------------");
        LOGD("%s", _convert_type_to_str(effect->type));
 
@@ -596,4 +587,4 @@ void _print_sem_data (rose_sem_effect_elements *effect, guint time_scale)
                }
        }
 }
-#endif
\ No newline at end of file
+#endif
index 1399986cc07dd0e27b85298699431adba82c5b69..ac229c32477967d1b4bf0436e6c68eb77244d4bb 100644 (file)
@@ -220,7 +220,6 @@ static void change_surface(int option)
        }
 
        if (surface_type == ROSE_DISPLAY_TYPE_OVERLAY) {
-
                        if (!g_win_id) {
                                g_win_id = create_win(PACKAGE);
                                if (g_win_id == NULL)
@@ -513,7 +512,7 @@ static void interpret(char *cmd)
  * @remark
  * @see
  */
-gboolean input(GIOChannel * channel)
+gboolean input(GIOChannel *channel)
 {
        gchar buf[MAX_STRING_LEN];
        gsize read;