Camera2: Implement semaphore with mutex and condition.
POSIX semaphore is not used or well tested on Android.
Implement it using mutex and conditional variable instead.
Change-Id: I480aa69a682821674aa95ff58f40a3b90a8714bc
diff --git a/QCamera2/HAL/QCamera2HWI.cpp b/QCamera2/HAL/QCamera2HWI.cpp
index f1f8cd7..3269c77 100644
--- a/QCamera2/HAL/QCamera2HWI.cpp
+++ b/QCamera2/HAL/QCamera2HWI.cpp
@@ -1345,9 +1345,9 @@
ALOGD("%s: E", __func__);
do {
do {
- ret = sem_wait(&cmdThread->cmd_sem);
+ ret = cam_sem_wait(&cmdThread->cmd_sem);
if (ret != 0 && errno != EINVAL) {
- ALOGE("%s: sem_wait error (%s)",
+ ALOGE("%s: cam_sem_wait error (%s)",
__func__, strerror(errno));
return NULL;
}
diff --git a/QCamera2/HAL/QCameraCmdThread.cpp b/QCamera2/HAL/QCameraCmdThread.cpp
index 83fbc50..f1b1578 100644
--- a/QCamera2/HAL/QCameraCmdThread.cpp
+++ b/QCamera2/HAL/QCameraCmdThread.cpp
@@ -46,8 +46,8 @@
cmd_queue()
{
cmd_pid = 0;
- sem_init(&sync_sem, 0, 0);
- sem_init(&cmd_sem, 0, 0);
+ cam_sem_init(&sync_sem, 0);
+ cam_sem_init(&cmd_sem, 0);
}
/*===========================================================================
@@ -61,8 +61,8 @@
*==========================================================================*/
QCameraCmdThread::~QCameraCmdThread()
{
- sem_destroy(&sync_sem);
- sem_destroy(&cmd_sem);
+ cam_sem_destroy(&sync_sem);
+ cam_sem_destroy(&cmd_sem);
}
/*===========================================================================
@@ -121,11 +121,11 @@
} else {
cmd_queue.enqueue((void *)node);
}
- sem_post(&cmd_sem);
+ cam_sem_post(&cmd_sem);
/* if is a sync call, need to wait until it returns */
if (sync_cmd) {
- sem_wait(&sync_sem);
+ cam_sem_wait(&sync_sem);
}
return NO_ERROR;
}
diff --git a/QCamera2/HAL/QCameraCmdThread.h b/QCamera2/HAL/QCameraCmdThread.h
index c8c4db0..cc84646 100644
--- a/QCamera2/HAL/QCameraCmdThread.h
+++ b/QCamera2/HAL/QCameraCmdThread.h
@@ -31,7 +31,9 @@
#define __QCAMERA_CMD_THREAD_H__
#include <pthread.h>
-#include <semaphore.h>
+#include <cam_semaphore.h>
+
+#include "cam_types.h"
#include "QCameraQueue.h"
namespace android {
@@ -62,8 +64,8 @@
QCameraQueue cmd_queue; /* cmd queue */
pthread_t cmd_pid; /* cmd thread ID */
- sem_t cmd_sem; /* semaphore for cmd thread */
- sem_t sync_sem; /* semaphore for synchronized call signal */
+ cam_semaphore_t cmd_sem; /* semaphore for cmd thread */
+ cam_semaphore_t sync_sem; /* semaphore for synchronized call signal */
};
}; // namespace android
diff --git a/QCamera2/HAL/QCameraPostProc.cpp b/QCamera2/HAL/QCameraPostProc.cpp
index d59e76f..5a46611 100644
--- a/QCamera2/HAL/QCameraPostProc.cpp
+++ b/QCamera2/HAL/QCameraPostProc.cpp
@@ -985,9 +985,9 @@
ALOGD("%s: E", __func__);
do {
do {
- ret = sem_wait(&cmdThread->cmd_sem);
+ ret = cam_sem_wait(&cmdThread->cmd_sem);
if (ret != 0 && errno != EINVAL) {
- ALOGE("%s: sem_wait error (%s)",
+ ALOGE("%s: cam_sem_wait error (%s)",
__func__, strerror(errno));
return NULL;
}
@@ -1090,9 +1090,9 @@
ALOGD("%s: E", __func__);
do {
do {
- ret = sem_wait(&cmdThread->cmd_sem);
+ ret = cam_sem_wait(&cmdThread->cmd_sem);
if (ret != 0 && errno != EINVAL) {
- ALOGE("%s: sem_wait error (%s)",
+ ALOGE("%s: cam_sem_wait error (%s)",
__func__, strerror(errno));
return NULL;
}
@@ -1131,7 +1131,7 @@
pme->m_inputPPQ.flush();
// signal cmd is completed
- sem_post(&cmdThread->sync_sem);
+ cam_sem_post(&cmdThread->sync_sem);
}
break;
case CAMERA_CMD_TYPE_DO_NEXT_JOB:
diff --git a/QCamera2/HAL/QCameraStateMachine.cpp b/QCamera2/HAL/QCameraStateMachine.cpp
index f5b8298..d051a51 100644
--- a/QCamera2/HAL/QCameraStateMachine.cpp
+++ b/QCamera2/HAL/QCameraStateMachine.cpp
@@ -55,9 +55,9 @@
ALOGD("%s: E", __func__);
do {
do {
- ret = sem_wait(&pme->cmd_sem);
+ ret = cam_sem_wait(&pme->cmd_sem);
if (ret != 0 && errno != EINVAL) {
- ALOGE("%s: sem_wait error (%s)",
+ ALOGE("%s: cam_sem_wait error (%s)",
__func__, strerror(errno));
return NULL;
}
@@ -115,7 +115,7 @@
m_parent = ctrl;
m_state = QCAMERA_SM_STATE_PREVIEW_STOPPED;
cmd_pid = 0;
- sem_init(&cmd_sem, 0, 0);
+ cam_sem_init(&cmd_sem, 0);
pthread_create(&cmd_pid,
NULL,
smEvtProcRoutine,
@@ -141,7 +141,7 @@
node->cmd = QCAMERA_SM_CMD_TYPE_EXIT;
api_queue.enqueue((void *)node);
- sem_post(&cmd_sem);
+ cam_sem_post(&cmd_sem);
/* wait until cmd thread exits */
if (pthread_join(cmd_pid, NULL) != 0) {
@@ -150,7 +150,7 @@
}
cmd_pid = 0;
}
- sem_destroy(&cmd_sem);
+ cam_sem_destroy(&cmd_sem);
}
/*===========================================================================
@@ -181,7 +181,7 @@
node->evt = evt;
node->evt_payload = api_payload;
if (api_queue.enqueue((void *)node)) {
- sem_post(&cmd_sem);
+ cam_sem_post(&cmd_sem);
return NO_ERROR;
} else {
free(node);
@@ -218,7 +218,7 @@
node->evt = evt;
node->evt_payload = evt_payload;
if (evt_queue.enqueue((void *)node)) {
- sem_post(&cmd_sem);
+ cam_sem_post(&cmd_sem);
return NO_ERROR;
} else {
free(node);
diff --git a/QCamera2/HAL/QCameraStateMachine.h b/QCamera2/HAL/QCameraStateMachine.h
index 6ed53fc..1199823 100644
--- a/QCamera2/HAL/QCameraStateMachine.h
+++ b/QCamera2/HAL/QCameraStateMachine.h
@@ -31,14 +31,15 @@
#define __QCAMERA_STATEMACHINE_H__
#include <pthread.h>
-#include <semaphore.h>
-#include "QCameraQueue.h"
-#include "QCameraChannel.h"
+#include <cam_semaphore.h>
extern "C" {
#include <mm_camera_interface.h>
}
+#include "QCameraQueue.h"
+#include "QCameraChannel.h"
+
namespace android {
class QCamera2HardwareInterface;
@@ -181,7 +182,7 @@
QCameraQueue api_queue; // cmd queue for APIs
QCameraQueue evt_queue; // cmd queue for evt from mm-camera-intf/mm-jpeg-intf
pthread_t cmd_pid; // cmd thread ID
- sem_t cmd_sem; // semaphore for cmd thread
+ cam_semaphore_t cmd_sem; // semaphore for cmd thread
};
diff --git a/QCamera2/HAL/QCameraStream.cpp b/QCamera2/HAL/QCameraStream.cpp
index 8c296c4..bcc76fa 100644
--- a/QCamera2/HAL/QCameraStream.cpp
+++ b/QCamera2/HAL/QCameraStream.cpp
@@ -247,9 +247,9 @@
ALOGI("%s: E", __func__);
do {
do {
- ret = sem_wait(&cmdThread->cmd_sem);
+ ret = cam_sem_wait(&cmdThread->cmd_sem);
if (ret != 0 && errno != EINVAL) {
- ALOGE("%s: sem_wait error (%s)",
+ ALOGE("%s: cam_sem_wait error (%s)",
__func__, strerror(errno));
return NULL;
}
diff --git a/QCamera2/stack/common/cam_semaphore.h b/QCamera2/stack/common/cam_semaphore.h
new file mode 100644
index 0000000..a52f907
--- /dev/null
+++ b/QCamera2/stack/common/cam_semaphore.h
@@ -0,0 +1,85 @@
+/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef __QCAMERA_SEMAPHORE_H__
+#define __QCAMERA_SEMAPHORE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Implement semaphore with mutex and conditional variable.
+ * Reason being, POSIX semaphore on Android are not used or
+ * well tested.
+ */
+
+typedef struct {
+ int val;
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+} cam_semaphore_t;
+
+static inline void cam_sem_init(cam_semaphore_t *s, int n)
+{
+ pthread_mutex_init(&(s->mutex), NULL);
+ pthread_cond_init(&(s->cond), NULL);
+ s->val = n;
+}
+
+static inline void cam_sem_post(cam_semaphore_t *s)
+{
+ pthread_mutex_lock(&(s->mutex));
+ s->val++;
+ pthread_cond_signal(&(s->cond));
+ pthread_mutex_unlock(&(s->mutex));
+}
+
+static inline int cam_sem_wait(cam_semaphore_t *s)
+{
+ int rc = 0;
+ pthread_mutex_lock(&(s->mutex));
+ while (s->val == 0)
+ rc = pthread_cond_wait(&(s->cond), &(s->mutex));
+ s->val--;
+ pthread_mutex_unlock(&(s->mutex));
+ return rc;
+}
+
+static inline void cam_sem_destroy(cam_semaphore_t *s)
+{
+ pthread_mutex_destroy(&(s->mutex));
+ pthread_cond_destroy(&(s->cond));
+ s->val = 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __QCAMERA_SEMAPHORE_H__ */
diff --git a/QCamera2/stack/mm-camera-interface/inc/mm_camera.h b/QCamera2/stack/mm-camera-interface/inc/mm_camera.h
index 511d6bf..126c2f5 100755
--- a/QCamera2/stack/mm-camera-interface/inc/mm_camera.h
+++ b/QCamera2/stack/mm-camera-interface/inc/mm_camera.h
@@ -30,6 +30,8 @@
#ifndef __MM_CAMERA_H__
#define __MM_CAMERA_H__
+#include <cam_semaphore.h>
+
#include "mm_camera_interface.h"
/**********************************************************************************
@@ -93,7 +95,7 @@
typedef struct {
cam_queue_t cmd_queue; /* cmd queue (queuing dataCB, asyncCB, or exitCMD) */
pthread_t cmd_pid; /* cmd thread ID */
- sem_t cmd_sem; /* semaphore for cmd thread */
+ cam_semaphore_t cmd_sem; /* semaphore for cmd thread */
mm_camera_cmd_cb_t cb; /* cb for cmd */
void* user_data; /* user_data for cb */
} mm_camera_cmd_thread_t;
diff --git a/QCamera2/stack/mm-camera-interface/src/mm_camera.c b/QCamera2/stack/mm-camera-interface/src/mm_camera.c
index d449c57..1013a80 100755
--- a/QCamera2/stack/mm-camera-interface/src/mm_camera.c
+++ b/QCamera2/stack/mm-camera-interface/src/mm_camera.c
@@ -34,7 +34,8 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <poll.h>
-#include <semaphore.h>
+
+#include <cam_semaphore.h>
#include "mm_camera_dbg.h"
#include "mm_camera_sock.h"
@@ -192,7 +193,7 @@
/* enqueue to evt cmd thread */
cam_queue_enq(&(my_obj->evt_thread.cmd_queue), node);
/* wake up evt cmd thread */
- sem_post(&(my_obj->evt_thread.cmd_sem));
+ cam_sem_post(&(my_obj->evt_thread.cmd_sem));
}
}
}
@@ -227,7 +228,7 @@
/* enqueue to evt cmd thread */
cam_queue_enq(&(my_obj->evt_thread.cmd_queue), node);
/* wake up evt cmd thread */
- sem_post(&(my_obj->evt_thread.cmd_sem));
+ cam_sem_post(&(my_obj->evt_thread.cmd_sem));
} else {
CDBG_ERROR("%s: No memory for mm_camera_node_t", __func__);
rc = -1;
diff --git a/QCamera2/stack/mm-camera-interface/src/mm_camera_channel.c b/QCamera2/stack/mm-camera-interface/src/mm_camera_channel.c
index 8bbec99..9a46bf6 100755
--- a/QCamera2/stack/mm-camera-interface/src/mm_camera_channel.c
+++ b/QCamera2/stack/mm-camera-interface/src/mm_camera_channel.c
@@ -34,7 +34,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <poll.h>
-#include <semaphore.h>
+#include <cam_semaphore.h>
#include "mm_camera_dbg.h"
#include "mm_camera_interface.h"
@@ -227,7 +227,7 @@
CDBG("%s: Send superbuf to HAL, pending_cnt=%d",
__func__, ch_obj->pending_cnt);
- /* send sem_post to wake up cb thread to dispatch super buffer */
+ /* send cam_sem_post to wake up cb thread to dispatch super buffer */
cb_node = (mm_camera_cmdcb_t *)malloc(sizeof(mm_camera_cmdcb_t));
if (NULL != cb_node) {
memset(cb_node, 0, sizeof(mm_camera_cmdcb_t));
@@ -243,7 +243,7 @@
cam_queue_enq(&(ch_obj->cb_thread.cmd_queue), cb_node);
/* wake up cb thread */
- sem_post(&(ch_obj->cb_thread.cmd_sem));
+ cam_sem_post(&(ch_obj->cb_thread.cmd_sem));
} else {
CDBG_ERROR("%s: No memory for mm_camera_node_t", __func__);
/* buf done with the nonuse super buf */
@@ -957,7 +957,7 @@
/* set pending_cnt
* will trigger dispatching super frames if pending_cnt > 0 */
- /* send sem_post to wake up cmd thread to dispatch super buffer */
+ /* send cam_sem_post to wake up cmd thread to dispatch super buffer */
node = (mm_camera_cmdcb_t *)malloc(sizeof(mm_camera_cmdcb_t));
if (NULL != node) {
memset(node, 0, sizeof(mm_camera_cmdcb_t));
@@ -968,7 +968,7 @@
cam_queue_enq(&(my_obj->cmd_thread.cmd_queue), node);
/* wake up cmd thread */
- sem_post(&(my_obj->cmd_thread.cmd_sem));
+ cam_sem_post(&(my_obj->cmd_thread.cmd_sem));
} else {
CDBG_ERROR("%s: No memory for mm_camera_node_t", __func__);
rc = -1;
diff --git a/QCamera2/stack/mm-camera-interface/src/mm_camera_interface.c b/QCamera2/stack/mm-camera-interface/src/mm_camera_interface.c
index 7c58c44..d402428 100755
--- a/QCamera2/stack/mm-camera-interface/src/mm_camera_interface.c
+++ b/QCamera2/stack/mm-camera-interface/src/mm_camera_interface.c
@@ -35,7 +35,6 @@
#include <fcntl.h>
#include <poll.h>
#include <linux/media.h>
-#include <semaphore.h>
#include "mm_camera_dbg.h"
#include "mm_camera_interface.h"
diff --git a/QCamera2/stack/mm-camera-interface/src/mm_camera_stream.c b/QCamera2/stack/mm-camera-interface/src/mm_camera_stream.c
index fdd034b..f04fe04 100755
--- a/QCamera2/stack/mm-camera-interface/src/mm_camera_stream.c
+++ b/QCamera2/stack/mm-camera-interface/src/mm_camera_stream.c
@@ -35,7 +35,7 @@
#include <fcntl.h>
#include <poll.h>
#include <time.h>
-#include <semaphore.h>
+#include <cam_semaphore.h>
#include <media/msm_media_info.h>
#include "mm_camera_dbg.h"
@@ -138,7 +138,7 @@
if (my_obj->is_bundled) {
mm_camera_cmdcb_t* node = NULL;
- /* send sem_post to wake up channel cmd thread to enqueue to super buffer */
+ /* send cam_sem_post to wake up channel cmd thread to enqueue to super buffer */
node = (mm_camera_cmdcb_t *)malloc(sizeof(mm_camera_cmdcb_t));
if (NULL != node) {
memset(node, 0, sizeof(mm_camera_cmdcb_t));
@@ -149,7 +149,7 @@
cam_queue_enq(&(my_obj->ch_obj->cmd_thread.cmd_queue), node);
/* wake up cmd thread */
- sem_post(&(my_obj->ch_obj->cmd_thread.cmd_sem));
+ cam_sem_post(&(my_obj->ch_obj->cmd_thread.cmd_sem));
} else {
CDBG_ERROR("%s: No memory for mm_camera_node_t", __func__);
}
@@ -158,7 +158,7 @@
if(has_cb) {
mm_camera_cmdcb_t* node = NULL;
- /* send sem_post to wake up cmd thread to dispatch dataCB */
+ /* send cam_sem_post to wake up cmd thread to dispatch dataCB */
node = (mm_camera_cmdcb_t *)malloc(sizeof(mm_camera_cmdcb_t));
if (NULL != node) {
memset(node, 0, sizeof(mm_camera_cmdcb_t));
@@ -169,7 +169,7 @@
cam_queue_enq(&(my_obj->cmd_thread.cmd_queue), node);
/* wake up cmd thread */
- sem_post(&(my_obj->cmd_thread.cmd_sem));
+ cam_sem_post(&(my_obj->cmd_thread.cmd_sem));
} else {
CDBG_ERROR("%s: No memory for mm_camera_node_t", __func__);
}
diff --git a/QCamera2/stack/mm-camera-interface/src/mm_camera_thread.c b/QCamera2/stack/mm-camera-interface/src/mm_camera_thread.c
index 01bda83..6a7a35a 100755
--- a/QCamera2/stack/mm-camera-interface/src/mm_camera_thread.c
+++ b/QCamera2/stack/mm-camera-interface/src/mm_camera_thread.c
@@ -34,7 +34,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <poll.h>
-#include <semaphore.h>
+#include <cam_semaphore.h>
#include "mm_camera_dbg.h"
#include "mm_camera_interface.h"
@@ -466,9 +466,9 @@
do {
do {
- ret = sem_wait(&cmd_thread->cmd_sem);
+ ret = cam_sem_wait(&cmd_thread->cmd_sem);
if (ret != 0 && errno != EINVAL) {
- CDBG_ERROR("%s: sem_wait error (%s)",
+ CDBG_ERROR("%s: cam_sem_wait error (%s)",
__func__, strerror(errno));
return NULL;
}
@@ -504,7 +504,7 @@
{
int32_t rc = 0;
- sem_init(&cmd_thread->cmd_sem, 0, 0);
+ cam_sem_init(&cmd_thread->cmd_sem, 0);
cam_queue_init(&cmd_thread->cmd_queue);
cmd_thread->cb = cb;
cmd_thread->user_data = user_data;
@@ -530,7 +530,7 @@
node->cmd_type = MM_CAMERA_CMD_TYPE_EXIT;
cam_queue_enq(&cmd_thread->cmd_queue, node);
- sem_post(&cmd_thread->cmd_sem);
+ cam_sem_post(&cmd_thread->cmd_sem);
/* wait until cmd thread exits */
if (pthread_join(cmd_thread->cmd_pid, NULL) != 0) {
@@ -543,7 +543,7 @@
{
int32_t rc = 0;
cam_queue_deinit(&cmd_thread->cmd_queue);
- sem_destroy(&cmd_thread->cmd_sem);
+ cam_sem_destroy(&cmd_thread->cmd_sem);
memset(cmd_thread, 0, sizeof(mm_camera_cmd_thread_t));
return rc;
}
diff --git a/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg.h b/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg.h
index a62e5e1..b4ceb78 100755
--- a/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg.h
+++ b/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg.h
@@ -30,6 +30,7 @@
#ifndef MM_JPEG_H_
#define MM_JPEG_H_
+#include <cam_semaphore.h>
#include "mm_jpeg_interface.h"
#include "cam_list.h"
#include "OMX_Types.h"
@@ -37,7 +38,6 @@
#include "OMX_Core.h"
#include "OMX_Component.h"
#include "QOMX_JpegExtensions.h"
-#include <semaphore.h>
typedef struct {
struct cam_list list;
@@ -96,7 +96,7 @@
typedef struct {
pthread_t pid; /* job cmd thread ID */
- sem_t job_sem; /* semaphore for job cmd thread */
+ cam_semaphore_t job_sem; /* semaphore for job cmd thread */
mm_jpeg_queue_t job_queue; /* queue for job to do */
} mm_jpeg_job_cmd_thread_t;
diff --git a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg.c b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg.c
index 3c73ad7..3a32317 100755
--- a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg.c
+++ b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg.c
@@ -34,7 +34,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <poll.h>
-#include <semaphore.h>
#include "mm_jpeg_dbg.h"
#include "mm_jpeg_interface.h"
@@ -783,9 +782,9 @@
do {
do {
- rc = sem_wait(&cmd_thread->job_sem);
+ rc = cam_sem_wait(&cmd_thread->job_sem);
if (rc != 0 && errno != EINVAL) {
- CDBG_ERROR("%s: sem_wait error (%s)",
+ CDBG_ERROR("%s: cam_sem_wait error (%s)",
__func__, strerror(errno));
return NULL;
}
@@ -826,7 +825,7 @@
int32_t rc = 0;
mm_jpeg_job_cmd_thread_t * job_mgr = &my_obj->job_mgr;
- sem_init(&job_mgr->job_sem, 0, 0);
+ cam_sem_init(&job_mgr->job_sem, 0);
mm_jpeg_queue_init(&job_mgr->job_queue);
/* launch the thread */
@@ -852,7 +851,7 @@
node->type = MM_JPEG_CMD_TYPE_EXIT;
mm_jpeg_queue_enq(&cmd_thread->job_queue, node);
- sem_post(&cmd_thread->job_sem);
+ cam_sem_post(&cmd_thread->job_sem);
/* wait until cmd thread exits */
if (pthread_join(cmd_thread->pid, NULL) != 0) {
@@ -860,7 +859,7 @@
}
mm_jpeg_queue_deinit(&cmd_thread->job_queue);
- sem_destroy(&cmd_thread->job_sem);
+ cam_sem_destroy(&cmd_thread->job_sem);
memset(cmd_thread, 0, sizeof(mm_jpeg_job_cmd_thread_t));
return rc;
}
@@ -988,7 +987,7 @@
rc = mm_jpeg_queue_enq(&my_obj->job_mgr.job_queue, node);
if (0 == rc) {
- sem_post(&my_obj->job_mgr.job_sem);
+ cam_sem_post(&my_obj->job_mgr.job_sem);
*jobId = job_id;
}
@@ -1044,7 +1043,7 @@
pthread_mutex_unlock(&my_obj->job_lock);
/* wake up jobMgr thread to work on new job if there is any */
- sem_post(&my_obj->job_mgr.job_sem);
+ cam_sem_post(&my_obj->job_mgr.job_sem);
return rc;
}
@@ -1204,7 +1203,7 @@
pthread_mutex_unlock(&my_obj->job_lock);
/* Wake up jobMgr thread to work on next job if there is any */
- sem_post(&my_obj->job_mgr.job_sem);
+ cam_sem_post(&my_obj->job_mgr.job_sem);
return rc;
}
diff --git a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_interface.c b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_interface.c
index 8d8b893..a6ad08f 100755
--- a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_interface.c
+++ b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_interface.c
@@ -33,7 +33,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <semaphore.h>
#include "mm_jpeg_dbg.h"
#include "mm_jpeg_interface.h"