+ do { \
+ if (x) { \
+ g_free(x); \
+ x = NULL; \
+ } \
+ } while (0)
+
+#define MMPLAYER_GET_ATTRS(x_player) ((mmplayer_t *)x_player)->attrs
+
+/* command */
+#define MMPLAYER_CMD_LOCK(x_player) g_mutex_lock(&((mmplayer_t *)x_player)->cmd_lock)
+#define MMPLAYER_CMD_TRYLOCK(x_player) g_mutex_trylock(&((mmplayer_t *)x_player)->cmd_lock)
+#define MMPLAYER_CMD_UNLOCK(x_player) g_mutex_unlock(&((mmplayer_t *)x_player)->cmd_lock)
+
+/* pipeline reconfigure */
+#define MMPLAYER_RECONFIGURE_LOCK(x_player) g_mutex_lock(&((mmplayer_t *)x_player)->reconfigure_lock)
+#define MMPLAYER_RECONFIGURE_UNLOCK(x_player) g_mutex_unlock(&((mmplayer_t *)x_player)->reconfigure_lock)
+#define MMPLAYER_RECONFIGURE_WAIT(x_player) g_cond_wait(&((mmplayer_t *)x_player)->reconfigure_cond, &((mmplayer_t *)x_player)->reconfigure_lock)
+#define MMPLAYER_RECONFIGURE_SIGNAL(x_player) g_cond_signal(&((mmplayer_t *)x_player)->reconfigure_cond);
+
+/* capture thread */
+#define MMPLAYER_CAPTURE_THREAD_LOCK(x_player) g_mutex_lock(&((mmplayer_t *)x_player)->capture_thread_mutex)
+#define MMPLAYER_CAPTURE_THREAD_UNLOCK(x_player) g_mutex_unlock(&((mmplayer_t *)x_player)->capture_thread_mutex)
+#define MMPLAYER_CAPTURE_THREAD_WAIT(x_player) g_cond_wait(&((mmplayer_t *)x_player)->capture_thread_cond, &((mmplayer_t *)x_player)->capture_thread_mutex)
+#define MMPLAYER_CAPTURE_THREAD_SIGNAL(x_player) g_cond_signal(&((mmplayer_t *)x_player)->capture_thread_cond);
+
+/* gapless play thread */
+#define MMPLAYER_GAPLESS_PLAY_THREAD_LOCK(x_player) g_mutex_lock(&((mmplayer_t *)x_player)->gapless_play_thread_mutex)
+#define MMPLAYER_GAPLESS_PLAY_THREAD_UNLOCK(x_player) g_mutex_unlock(&((mmplayer_t *)x_player)->gapless_play_thread_mutex)
+#define MMPLAYER_GAPLESS_PLAY_THREAD_WAIT(x_player) g_cond_wait(&((mmplayer_t *)x_player)->gapless_play_thread_cond, &((mmplayer_t *)x_player)->gapless_play_thread_mutex)
+#define MMPLAYER_GAPLESS_PLAY_THREAD_SIGNAL(x_player) g_cond_signal(&((mmplayer_t *)x_player)->gapless_play_thread_cond);
+
+/* gst bus msg thread */
+#define MMPLAYER_BUS_MSG_THREAD_LOCK(x_player) g_mutex_lock(&((mmplayer_t *)x_player)->bus_msg_thread_mutex)
+#define MMPLAYER_BUS_MSG_THREAD_UNLOCK(x_player) g_mutex_unlock(&((mmplayer_t *)x_player)->bus_msg_thread_mutex)
+#define MMPLAYER_BUS_MSG_THREAD_WAIT(x_player) g_cond_wait(&((mmplayer_t *)x_player)->bus_msg_thread_cond, &((mmplayer_t *)x_player)->bus_msg_thread_mutex)
+#define MMPLAYER_BUS_MSG_THREAD_WAIT_UNTIL(x_player, end_time) g_cond_wait_until(&((mmplayer_t *)x_player)->bus_msg_thread_cond, &((mmplayer_t *)x_player)->bus_msg_thread_mutex, end_time)
+#define MMPLAYER_BUS_MSG_THREAD_SIGNAL(x_player) g_cond_signal(&((mmplayer_t *)x_player)->bus_msg_thread_cond);
+
+/* gst bus watcher thread */
+#define MMPLAYER_BUS_WATCHER_LOCK(x_player) g_mutex_lock(&((mmplayer_t *)x_player)->bus_watcher_mutex)
+#define MMPLAYER_BUS_WATCHER_UNLOCK(x_player) g_mutex_unlock(&((mmplayer_t *)x_player)->bus_watcher_mutex)
+#define MMPLAYER_BUS_WATCHER_WAIT_UNTIL(x_player, end_time) g_cond_wait_until(&((mmplayer_t *)x_player)->bus_watcher_cond, &((mmplayer_t *)x_player)->bus_watcher_mutex, end_time)
+#define MMPLAYER_BUS_WATCHER_SIGNAL(x_player) g_cond_signal(&((mmplayer_t *)x_player)->bus_watcher_cond);
+
+/* handling fakesink */
+#define MMPLAYER_FSINK_LOCK(x_player) g_mutex_lock(&((mmplayer_t *)x_player)->fsink_lock)
+#define MMPLAYER_FSINK_UNLOCK(x_player) g_mutex_unlock(&((mmplayer_t *)x_player)->fsink_lock)
+
+/* handling update tag */
+#define MMPLAYER_UPDATE_TAG_LOCK(x_player) g_mutex_lock(&((mmplayer_t *)x_player)->update_tag_lock)
+#define MMPLAYER_UPDATE_TAG_UNLOCK(x_player) g_mutex_unlock(&((mmplayer_t *)x_player)->update_tag_lock)
+
+/* video stream bo */
+#define MMPLAYER_VIDEO_BO_LOCK(x_player) g_mutex_lock(&((mmplayer_t *)x_player)->video_bo_mutex)
+#define MMPLAYER_VIDEO_BO_UNLOCK(x_player) g_mutex_unlock(&((mmplayer_t *)x_player)->video_bo_mutex)
+#define MMPLAYER_VIDEO_BO_WAIT(x_player) g_cond_wait(&((mmplayer_t *)x_player)->video_bo_cond, &((mmplayer_t *)x_player)->video_bo_mutex)
+#define MMPLAYER_VIDEO_BO_WAIT_UNTIL(x_player, end_time) g_cond_wait_until(&((mmplayer_t *)x_player)->video_bo_cond, &((mmplayer_t *)x_player)->video_bo_mutex, end_time)
+#define MMPLAYER_VIDEO_BO_SIGNAL(x_player) g_cond_signal(&((mmplayer_t *)x_player)->video_bo_cond);
+
+/* subtitle info */
+#define MMPLAYER_SUBTITLE_INFO_LOCK(x_player) g_mutex_lock(&((mmplayer_t *)x_player)->subtitle_info_mutex)
+#define MMPLAYER_SUBTITLE_INFO_UNLOCK(x_player) g_mutex_unlock(&((mmplayer_t *)x_player)->subtitle_info_mutex)
+#define MMPLAYER_SUBTITLE_INFO_WAIT(x_player) g_cond_wait(&((mmplayer_t *)x_player)->subtitle_info_cond, &((mmplayer_t *)x_player)->subtitle_info_mutex)
+#define MMPLAYER_SUBTITLE_INFO_WAIT_UNTIL(x_player, end_time) g_cond_wait_until(&((mmplayer_t *)x_player)->subtitle_info_cond, &((mmplayer_t *)x_player)->subtitle_info_mutex, end_time)
+#define MMPLAYER_SUBTITLE_INFO_SIGNAL(x_player) g_cond_signal(&((mmplayer_t *)x_player)->subtitle_info_cond);