summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeongmo Yang <jm80.yang@samsung.com>2016-12-15 17:26:23 +0900
committerJeongmo Yang <jm80.yang@samsung.com>2016-12-16 14:41:51 +0900
commit27ef7c00603fb98284c61466c3c7f564984d3a9d (patch)
tree2651672b908c223ca6fc7fde06f0ca35f9e0d6f0
parent9befe982d183c58a3ba5d9b62cfbf04b8b310c9b (diff)
downloadrecorder-27ef7c00603fb98284c61466c3c7f564984d3a9d.tar.gz
recorder-27ef7c00603fb98284c61466c3c7f564984d3a9d.tar.bz2
recorder-27ef7c00603fb98284c61466c3c7f564984d3a9d.zip
If some API's return value is come lately from muse server after waiting timeout, api_activating can be true. Then, previous return value is returned if same API is called. This patch resolves it. [Version] 0.2.48 [Profile] Common [Issue Type] Update [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-3.0-mobile_20161213.3] Change-Id: I5a2f3bb7ea034f74aa3815fde12bbcd4c4132e8f Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r--include/recorder_private.h1
-rw-r--r--packaging/capi-media-recorder.spec2
-rw-r--r--src/recorder.c78
3 files changed, 68 insertions, 13 deletions
diff --git a/include/recorder_private.h b/include/recorder_private.h
index 46ba469..daefa2c 100644
--- a/include/recorder_private.h
+++ b/include/recorder_private.h
@@ -85,6 +85,7 @@ typedef struct _recorder_cb_info_s {
GCond api_cond[MUSE_RECORDER_API_MAX];
GMutex api_mutex[MUSE_RECORDER_API_MAX];
gint api_activating[MUSE_RECORDER_API_MAX];
+ gint api_waiting[MUSE_RECORDER_API_MAX];
gint api_ret[MUSE_RECORDER_API_MAX];
/* general message handler info */
diff --git a/packaging/capi-media-recorder.spec b/packaging/capi-media-recorder.spec
index 714aac2..0f5d4f0 100644
--- a/packaging/capi-media-recorder.spec
+++ b/packaging/capi-media-recorder.spec
@@ -1,6 +1,6 @@
Name: capi-media-recorder
Summary: A Recorder API
-Version: 0.2.47
+Version: 0.2.48
Release: 0
Group: Multimedia/API
License: Apache-2.0
diff --git a/src/recorder.c b/src/recorder.c
index a290390..f0116e6 100644
--- a/src/recorder.c
+++ b/src/recorder.c
@@ -46,6 +46,26 @@ static GDBusConnection *g_rec_dev_state_changed_cb_conn;
static guint g_rec_dev_state_changed_cb_subscribe_id;
+
+static void __recorder_update_api_waiting(recorder_cb_info_s *cb_info, int api, int value)
+{
+ if (!cb_info ||
+ api < 0 || api >= MUSE_RECORDER_API_MAX) {
+ LOGE("invalid param %p %d", cb_info, api);
+ return;
+ }
+
+ g_mutex_lock(&(cb_info->api_mutex[api]));
+ cb_info->api_waiting[api] += value;
+ g_mutex_unlock(&(cb_info->api_mutex[api]));
+
+ /*LOGD("api %d, value %d, waiting %d",
+ api, value, cb_info->api_waiting[api]);*/
+
+ return;
+}
+
+
static void __recorder_device_state_changed_cb(GDBusConnection *connection,
const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
const gchar *signal_name, GVariant *param, gpointer user_data)
@@ -687,9 +707,6 @@ static void __recorder_process_msg(recorder_cb_info_s *cb_info, char *msg)
g_mutex_lock(&cb_info->api_mutex[api]);
- cb_info->api_ret[api] = ret;
- cb_info->api_activating[api] = 1;
-
if (api == MUSE_RECORDER_API_GET_DEVICE_STATE) {
g_atomic_int_set(&cb_info->msg_recv_running, 0);
LOGD("get device state done. close client cb handler");
@@ -713,7 +730,15 @@ static void __recorder_process_msg(recorder_cb_info_s *cb_info, char *msg)
}
}
- g_cond_signal(&cb_info->api_cond[api]);
+ if (cb_info->api_waiting[api] > 0) {
+ cb_info->api_ret[api] = ret;
+ cb_info->api_activating[api] = 1;
+
+ g_cond_signal(&cb_info->api_cond[api]);
+ } else {
+ LOGE("no waiting for api [%d]", api);
+ }
+
g_mutex_unlock(&cb_info->api_mutex[api]);
} else if (api_class == MUSE_RECORDER_API_CLASS_THREAD_SUB || api == MUSE_RECORDER_CB_EVENT) {
__recorder_add_msg_to_queue(cb_info, api, event, event_class, msg);
@@ -774,12 +799,16 @@ static void *_recorder_msg_handler_func(gpointer data)
g_mutex_lock(&cb_info->api_mutex[api]);
if (muse_recorder_msg_get(ret, rec_msg->recv_msg)) {
- cb_info->api_ret[api] = ret;
- cb_info->api_activating[api] = 1;
+ if (cb_info->api_waiting[api] > 0) {
+ cb_info->api_ret[api] = ret;
+ cb_info->api_activating[api] = 1;
- /*LOGD("recorder api %d - return 0x%x", ret);*/
+ /*LOGD("recorder api %d - return 0x%x", ret);*/
- g_cond_signal(&cb_info->api_cond[api]);
+ g_cond_signal(&cb_info->api_cond[api]);
+ } else {
+ LOGE("no waiting for api [%d]", api);
+ }
} else {
LOGE("t:%d failed to get ret for api %d, msg %s", type, api, rec_msg->recv_msg);
}
@@ -1088,6 +1117,8 @@ static recorder_cb_info_s *_recorder_client_callback_new(gint sockfd)
goto ErrorExit;
}
+ cb_info->api_waiting[MUSE_RECORDER_API_CREATE] = 1;
+
for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
g_mutex_init(&cb_info->api_mutex[i]);
g_cond_init(&cb_info->api_cond[i]);
@@ -1213,8 +1244,11 @@ static int _recorder_msg_send(int api, recorder_cb_info_s *cb_info, int *ret)
/*LOGD("send msg %s", msg);*/
- if (cb_info->is_server_connected)
+ if (cb_info->is_server_connected) {
+ __recorder_update_api_waiting(cb_info, api, 1);
+
send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
+ }
if (send_ret < 0) {
LOGE("message send failed");
@@ -1223,6 +1257,8 @@ static int _recorder_msg_send(int api, recorder_cb_info_s *cb_info, int *ret)
*ret = _recorder_client_wait_for_cb_return(api, cb_info, RECORDER_CB_TIMEOUT);
}
+ __recorder_update_api_waiting(cb_info, api, -1);
+
muse_core_msg_json_factory_free(msg);
return RECORDER_ERROR_NONE;
@@ -1264,8 +1300,11 @@ static int _recorder_msg_send_param1(int api, recorder_cb_info_s *cb_info, int *
/*LOGD("send msg %s", msg);*/
- if (cb_info->is_server_connected)
+ if (cb_info->is_server_connected) {
+ __recorder_update_api_waiting(cb_info, api, 1);
+
send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
+ }
if (send_ret < 0) {
LOGE("message send failed");
@@ -1274,6 +1313,8 @@ static int _recorder_msg_send_param1(int api, recorder_cb_info_s *cb_info, int *
*ret = _recorder_client_wait_for_cb_return(api, cb_info, RECORDER_CB_TIMEOUT);
}
+ __recorder_update_api_waiting(cb_info, api, -1);
+
muse_core_msg_json_factory_free(msg);
return RECORDER_ERROR_NONE;
@@ -1463,6 +1504,9 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty
sock_fd = -1;
ret = _recorder_client_wait_for_cb_return(MUSE_RECORDER_API_CREATE, pc->cb_info, RECORDER_CB_TIMEOUT);
+
+ pc->cb_info->api_waiting[MUSE_RECORDER_API_CREATE] = 0;
+
if (ret != RECORDER_ERROR_NONE) {
LOGE("API_CREATE failed 0x%x", ret);
goto _ERR_RECORDER_EXIT;
@@ -1837,8 +1881,11 @@ int recorder_set_video_resolution(recorder_h recorder, int width, int height)
MUSE_TYPE_INT, "height", height,
NULL);
if (send_msg) {
- if (pc->cb_info->is_server_connected)
+ if (pc->cb_info->is_server_connected) {
+ __recorder_update_api_waiting(pc->cb_info, api, 1);
+
send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, send_msg);
+ }
if (send_ret < 0) {
LOGE("message send failed");
@@ -1847,6 +1894,8 @@ int recorder_set_video_resolution(recorder_h recorder, int width, int height)
ret = _recorder_client_wait_for_cb_return(api, pc->cb_info, RECORDER_CB_TIMEOUT);
}
+ __recorder_update_api_waiting(pc->cb_info, api, -1);
+
muse_core_msg_json_factory_free(send_msg);
} else {
LOGE("failed to create msg");
@@ -2111,8 +2160,11 @@ int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stre
MUSE_TYPE_INT, "stream_index", stream_index,
NULL);
if (send_msg) {
- if (pc->cb_info->is_server_connected)
+ if (pc->cb_info->is_server_connected) {
+ __recorder_update_api_waiting(pc->cb_info, api, 1);
+
send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, send_msg);
+ }
if (send_ret < 0) {
LOGE("message send failed");
@@ -2121,6 +2173,8 @@ int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stre
ret = _recorder_client_wait_for_cb_return(api, pc->cb_info, RECORDER_CB_TIMEOUT);
}
+ __recorder_update_api_waiting(pc->cb_info, api, -1);
+
muse_core_msg_json_factory_free(send_msg);
} else {
LOGE("failed to create msg");