g_free(x); \
x = NULL;
-#define MMPLAYER_CMD_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->cmd_lock)
-#define MMPLAYER_CMD_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t*)x_player)->cmd_lock)
-#define MMPLAYER_PLAYBACK_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->playback_lock)
-#define MMPLAYER_PLAYBACK_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t*)x_player)->playback_lock)
#define MMPLAYER_GET_ATTRS(x_player) ((mm_player_t*)x_player)->attrs
+/* command */
+#define MMPLAYER_CMD_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->cmd_lock)
+#define MMPLAYER_CMD_TRYLOCK(x_player) g_mutex_trylock(&((mm_player_t *)x_player)->cmd_lock)
+#define MMPLAYER_CMD_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t*)x_player)->cmd_lock)
+
+/* playback */
+#define MMPLAYER_PLAYBACK_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->playback_lock)
+#define MMPLAYER_PLAYBACK_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t*)x_player)->playback_lock)
+
+/* capture thread */
+#define MMPLAYER_CAPTURE_THREAD_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->capture_thread_mutex)
+#define MMPLAYER_CAPTURE_THREAD_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t *)x_player)->capture_thread_mutex)
+#define MMPLAYER_CAPTURE_THREAD_WAIT(x_player) g_cond_wait(&((mm_player_t *)x_player)->capture_thread_cond, &((mm_player_t *)x_player)->capture_thread_mutex)
+#define MMPLAYER_CAPTURE_THREAD_SIGNAL(x_player) g_cond_signal(&((mm_player_t *)x_player)->capture_thread_cond);
+
+/* next play thread */
+#define MMPLAYER_NEXT_PLAY_THREAD_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->next_play_thread_mutex)
+#define MMPLAYER_NEXT_PLAY_THREAD_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t *)x_player)->next_play_thread_mutex)
+#define MMPLAYER_NEXT_PLAY_THREAD_WAIT(x_player) g_cond_wait(&((mm_player_t *)x_player)->next_play_thread_cond, &((mm_player_t *)x_player)->next_play_thread_mutex)
+#define MMPLAYER_NEXT_PLAY_THREAD_SIGNAL(x_player) g_cond_signal(&((mm_player_t *)x_player)->next_play_thread_cond);
+
+/* repeat thread */
+#define MMPLAYER_REPEAT_THREAD_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->repeat_thread_mutex)
+#define MMPLAYER_REPEAT_THREAD_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t *)x_player)->repeat_thread_mutex)
+#define MMPLAYER_REPEAT_THREAD_WAIT(x_player) g_cond_wait(&((mm_player_t *)x_player)->repeat_thread_cond, &((mm_player_t *)x_player)->repeat_thread_mutex)
+#define MMPLAYER_REPEAT_THREAD_SIGNAL(x_player) g_cond_signal(&((mm_player_t *)x_player)->repeat_thread_cond);
+
+/* handling fakesink */
+#define MMPLAYER_FSINK_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->fsink_lock)
+#define MMPLAYER_FSINK_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t *)x_player)->fsink_lock)
+
+/* video stream bo */
+#define MMPLAYER_VIDEO_BO_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->video_bo_mutex)
+#define MMPLAYER_VIDEO_BO_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t *)x_player)->video_bo_mutex)
+#define MMPLAYER_VIDEO_BO_WAIT(x_player) g_cond_wait(&((mm_player_t *)x_player)->video_bo_cond, &((mm_player_t *)x_player)->video_bo_mutex)
+#define MMPLAYER_VIDEO_BO_WAIT_UNTIL(x_player, end_time) g_cond_wait_until(&((mm_player_t *)x_player)->video_bo_cond, &((mm_player_t *)x_player)->video_bo_mutex, end_time);
+#define MMPLAYER_VIDEO_BO_SIGNAL(x_player) g_cond_signal(&((mm_player_t *)x_player)->video_bo_cond);
+
#if 0
#define MMPLAYER_FENTER(); LOGD("<ENTER>");
#define MMPLAYER_FLEAVE(); LOGD("<LEAVE>");
MMPLAYER_RETURN_VAL_IF_FAIL(player, NULL);
- g_mutex_lock(&player->next_play_thread_mutex);
+ MMPLAYER_NEXT_PLAY_THREAD_LOCK(player);
while (!player->next_play_thread_exit) {
LOGD("next play thread started. waiting for signal.\n");
- g_cond_wait(&player->next_play_thread_cond, &player->next_play_thread_mutex);
+ MMPLAYER_NEXT_PLAY_THREAD_WAIT(player);
LOGD("reconfigure pipeline for gapless play.\n");
__mmplayer_activate_next_source(player, GST_STATE_PLAYING);
}
- g_mutex_unlock(&player->next_play_thread_mutex);
+ MMPLAYER_NEXT_PLAY_THREAD_UNLOCK(player);
return NULL;
}
MMPLAYER_RETURN_VAL_IF_FAIL(player, NULL);
- g_mutex_lock(&player->repeat_thread_mutex);
+ MMPLAYER_REPEAT_THREAD_LOCK(player);
while (!player->repeat_thread_exit) {
LOGD("repeat thread started. waiting for signal.\n");
- g_cond_wait(&player->repeat_thread_cond, &player->repeat_thread_mutex);
+ MMPLAYER_REPEAT_THREAD_WAIT(player);
if (player->repeat_thread_exit) {
LOGD("exiting repeat thread\n");
/* lock */
- g_mutex_lock(&player->cmd_lock);
+ MMPLAYER_CMD_LOCK(player);
attrs = MMPLAYER_GET_ATTRS(player);
}
/* unlock */
- g_mutex_unlock(&player->cmd_lock);
+ MMPLAYER_CMD_UNLOCK(player);
}
- g_mutex_unlock(&player->repeat_thread_mutex);
+ MMPLAYER_REPEAT_THREAD_UNLOCK(player);
return NULL;
}
if (smooth_repeat) {
LOGD("smooth repeat enabled. seeking operation will be excuted in new thread\n");
- g_cond_signal(&player->repeat_thread_cond);
+ MMPLAYER_REPEAT_THREAD_SIGNAL(player);
break;
} else {
MMPLAYER_RETURN_VAL_IF_FAIL(fakesink, TRUE);
/* lock */
- g_mutex_lock(&player->fsink_lock);
+ MMPLAYER_FSINK_LOCK(player);
if (!fakesink->gst)
goto ERROR;
gst_element_set_locked_state(fakesink->gst, FALSE);
- g_mutex_unlock(&player->fsink_lock);
+ MMPLAYER_FSINK_UNLOCK(player);
return TRUE;
ERROR:
if (fakesink->gst)
gst_element_set_locked_state(fakesink->gst, FALSE);
- g_mutex_unlock(&player->fsink_lock);
+ MMPLAYER_FSINK_UNLOCK(player);
return FALSE;
}
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_INVALID_ARGUMENT);
- g_mutex_lock(&player->video_bo_mutex);
+ MMPLAYER_VIDEO_BO_LOCK(player);
if (player->video_bo_list) {
for (l = g_list_first(player->video_bo_list); l; l = g_list_next(l)) {
if (tmp && tmp->bo == bo) {
tmp->using = FALSE;
LOGD("release bo %p", bo);
- g_mutex_unlock(&player->video_bo_mutex);
- g_cond_signal(&player->video_bo_cond);
+ MMPLAYER_VIDEO_BO_UNLOCK(player);
+ MMPLAYER_VIDEO_BO_SIGNAL(player);
return ret;
}
}
/* hw codec is running or the list was reset for DRC. */
LOGW("there is no bo list.");
}
- g_mutex_unlock(&player->video_bo_mutex);
+ MMPLAYER_VIDEO_BO_UNLOCK(player);
LOGW("failed to find bo %p", bo);
return ret;
MMPLAYER_FENTER();
MMPLAYER_RETURN_IF_FAIL(player);
- g_mutex_lock(&player->video_bo_mutex);
+ MMPLAYER_VIDEO_BO_LOCK(player);
if (player->video_bo_list) {
LOGD("destroy video_bo_list : %d", g_list_length(player->video_bo_list));
for (l = g_list_first(player->video_bo_list); l; l = g_list_next(l)) {
player->video_bo_list = NULL;
}
player->video_bo_size = 0;
- g_mutex_unlock(&player->video_bo_mutex);
+ MMPLAYER_VIDEO_BO_UNLOCK(player);
MMPLAYER_FLEAVE();
return;
player->video_bo_size = size;
}
- g_mutex_lock(&player->video_bo_mutex);
+ MMPLAYER_VIDEO_BO_LOCK(player);
if ((!player->video_bo_list) ||
(g_list_length(player->video_bo_list) < player->ini.num_of_video_bo)) {
player->video_extra_num_buffers = player->ini.num_of_video_bo/2;
if (idx == 0) {
- g_mutex_unlock(&player->video_bo_mutex);
+ MMPLAYER_VIDEO_BO_UNLOCK(player);
return NULL;
}
if (tmp && (tmp->using == FALSE)) {
LOGD("found bo %p to use", tmp->bo);
tmp->using = TRUE;
- g_mutex_unlock(&player->video_bo_mutex);
+ MMPLAYER_VIDEO_BO_UNLOCK(player);
return tmp->bo;
}
}
if (!ret) {
LOGE("failed to get bo in %d timeout", player->ini.video_bo_timeout);
- g_mutex_unlock(&player->video_bo_mutex);
+ MMPLAYER_VIDEO_BO_UNLOCK(player);
return NULL;
}
if (player->ini.video_bo_timeout <= 0) {
- g_cond_wait(&player->video_bo_cond, &player->video_bo_mutex);
+ MMPLAYER_VIDEO_BO_WAIT(player);
} else {
gint64 timeout = g_get_monotonic_time() + player->ini.video_bo_timeout*G_TIME_SPAN_SECOND;
- ret = g_cond_wait_until(&player->video_bo_cond, &player->video_bo_mutex, timeout);
+ ret = MMPLAYER_VIDEO_BO_WAIT_UNTIL(player, timeout);
}
continue;
}
}
/* check other thread */
- if (!g_mutex_trylock(&player->cmd_lock)) {
+ if (!MMPLAYER_CMD_TRYLOCK(player)) {
LOGW("locked already, cmd state : %d", player->cmd);
/* check application command */
LOGW("playing.. should wait cmd lock then, will be interrupted");
/* lock will be released at mrp_resource_release_cb() */
- g_mutex_lock(&player->cmd_lock);
+ MMPLAYER_CMD_LOCK(player);
goto INTERRUPT;
}
LOGW("nothing to do");
/* free thread */
if (player->repeat_thread) {
player->repeat_thread_exit = TRUE;
- g_cond_signal(&player->repeat_thread_cond);
+ MMPLAYER_REPEAT_THREAD_SIGNAL(player);
g_thread_join(player->repeat_thread);
player->repeat_thread = NULL;
/* free next play thread */
if (player->next_play_thread) {
player->next_play_thread_exit = TRUE;
- g_cond_signal(&player->next_play_thread_cond);
+ MMPLAYER_NEXT_PLAY_THREAD_SIGNAL(player);
g_thread_join(player->next_play_thread);
player->next_play_thread = NULL;
/* release repeat thread */
if (player->repeat_thread) {
player->repeat_thread_exit = TRUE;
- g_cond_signal(&player->repeat_thread_cond);
+ MMPLAYER_REPEAT_THREAD_SIGNAL(player);
LOGD("waitting for repeat thread exit\n");
g_thread_join(player->repeat_thread);
/* release next play thread */
if (player->next_play_thread) {
player->next_play_thread_exit = TRUE;
- g_cond_signal(&player->next_play_thread_cond);
+ MMPLAYER_NEXT_PLAY_THREAD_SIGNAL(player);
LOGD("waitting for next play thread exit\n");
g_thread_join(player->next_play_thread);
}
MMPLAYER_PLAYBACK_LOCK(player);
- g_cond_signal(&player->next_play_thread_cond);
+ MMPLAYER_NEXT_PLAY_THREAD_SIGNAL(player);
MMPLAYER_FLEAVE();
return;
return;
}
- if (!g_mutex_trylock(&player->cmd_lock)) {
+ if (!MMPLAYER_CMD_TRYLOCK(player)) {
LOGW("Fail to get cmd lock");
return;
}
if (!__mmplayer_verify_next_play_path(player)) {
LOGD("decoding is finished.");
__mmplayer_reset_gapless_state(player);
- g_mutex_unlock(&player->cmd_lock);
+ MMPLAYER_CMD_UNLOCK(player);
return;
}
/* deactivate pipeline except sinkbins to set up the new pipeline of next uri*/
__mmplayer_deactivate_old_path(player);
- g_mutex_unlock(&player->cmd_lock);
+ MMPLAYER_CMD_UNLOCK(player);
MMPLAYER_FLEAVE();
}