summaryrefslogtreecommitdiff
path: root/src/include/mm_radio_utils.h
diff options
context:
space:
mode:
authorGilbok Lee <gilbok.lee@samsung.com>2018-03-27 19:16:41 +0900
committerGilbok Lee <gilbok.lee@samsung.com>2018-03-30 14:19:46 +0900
commit8731374d6ce658639898e208d02bd3d63e030975 (patch)
treefe7fd2a577e566749b326f2a13f44aece02e765e /src/include/mm_radio_utils.h
parentcd6cb94937c27469f1f90990efea5b37c2592ab7 (diff)
downloadlibmm-radio-8731374d6ce658639898e208d02bd3d63e030975.tar.gz
libmm-radio-8731374d6ce658639898e208d02bd3d63e030975.tar.bz2
libmm-radio-8731374d6ce658639898e208d02bd3d63e030975.zip
Create seek/scan thread once when radio handle create.
[Version] 0.2.35 [Profile] Mobile, Wearable [Issue Type] Refactoring Change-Id: Ie41d3190074310e94a180ca3f45c9e0ce5e865f7
Diffstat (limited to 'src/include/mm_radio_utils.h')
-rw-r--r--src/include/mm_radio_utils.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/include/mm_radio_utils.h b/src/include/mm_radio_utils.h
index bcc5959..b538b6d 100644
--- a/src/include/mm_radio_utils.h
+++ b/src/include/mm_radio_utils.h
@@ -112,6 +112,22 @@ do { \
#define MMRADIO_VOLUME_LOCK(x_radio) pthread_mutex_lock(&((mm_radio_t *)x_radio)->volume_lock)
#define MMRADIO_VOLUME_UNLOCK(x_radio) pthread_mutex_unlock(&((mm_radio_t *)x_radio)->volume_lock)
+/* seek thread */
+#define MMRADIO_SEEK_THREAD_LOCK(x_radio) pthread_mutex_lock(&((mm_radio_t *)x_radio)->seek.mutex)
+#define MMRADIO_SEEK_THREAD_UNLOCK(x_radio) pthread_mutex_unlock(&((mm_radio_t *)x_radio)->seek.mutex)
+#define MMRADIO_SEEK_THREAD_WAIT(x_radio) pthread_cond_wait(&((mm_radio_t *)x_radio)->seek.cond, &((mm_radio_t *)x_radio)->seek.mutex)
+#define MMRADIO_SEEK_THREAD_SIGNAL(x_radio) pthread_cond_signal(&((mm_radio_t *)x_radio)->seek.cond)
+
+/* scan thread */
+#define MMRADIO_SCAN_THREAD_LOCK(x_radio) pthread_mutex_lock(&((mm_radio_t *)x_radio)->scan.mutex)
+#define MMRADIO_SCAN_THREAD_UNLOCK(x_radio) pthread_mutex_unlock(&((mm_radio_t *)x_radio)->scan.mutex)
+#define MMRADIO_SCAN_THREAD_WAIT(x_radio) pthread_cond_wait(&((mm_radio_t *)x_radio)->scan.cond, &((mm_radio_t *)x_radio)->scan.mutex)
+#define MMRADIO_SCAN_THREAD_SIGNAL(x_radio) pthread_cond_signal(&((mm_radio_t *)x_radio)->scan.cond)
+
+/* hal seek thread */
+#define MMRADIO_HAL_SEEK_THREAD_LOCK(x_radio) pthread_mutex_lock(&((mm_radio_t *)x_radio)->hal_seek_mutex)
+#define MMRADIO_HAL_SEEK_THREAD_UNLOCK(x_radio) pthread_mutex_unlock(&((mm_radio_t *)x_radio)->hal_seek_mutex)
+
/* message posting */
#define MMRADIO_POST_MSG(x_radio, x_msgtype, x_msg_param) \
do { \
@@ -146,10 +162,26 @@ do { \
#define MMRADIO_CHECK_RETURN_IF_FAIL(x_ret, x_msg) \
do { \
if (x_ret < 0) { \
- MMRADIO_LOG_ERROR("%s error\n", x_msg); \
+ MMRADIO_LOG_ERROR("%s error\n", x_msg); \
return x_ret; \
} \
} while (0);
+#define MMRADIO_INIT_MUTEX(x_mutex) \
+do { \
+ if (pthread_mutex_init(&x_mutex, NULL) < 0) { \
+ MMRADIO_LOG_ERROR("failed to create mutex"); \
+ goto ERROR; \
+ } \
+} while (0)
+
+#define MMRADIO_INIT_COND(x_cond) \
+do { \
+ if (pthread_cond_init(&x_cond, NULL) < 0) { \
+ MMRADIO_LOG_ERROR("failed to create cond"); \
+ goto ERROR; \
+ } \
+} while (0)
+
#endif