hardware: samsung_slsi: libcamera2: Add a signal buffer to threads
authorSungjoong Kang <sj3.kang@samsung.com>
Tue, 18 Sep 2012 19:25:13 +0000 (12:25 -0700)
committerRebecca Schultz Zavin <rebecca@android.com>
Tue, 18 Sep 2012 20:26:25 +0000 (13:26 -0700)
Add a simple signal buffer to threads
so that they can hold one pending signal.

Change-Id: I38474b5fabdaf337d683a6291a3a0f6d522ec256
Signed-off-by: Sungjoong Kang <sj3.kang@samsung.com>
libcamera2/SignalDrivenThread.cpp
libcamera2/SignalDrivenThread.h

index 8c491a280cbea0a9b4c86eef4fad7b2726f0e28f..77881cafd9edacf473670eb52b5cc6aa13001e14 100644 (file)
@@ -46,6 +46,7 @@ SignalDrivenThread::SignalDrivenThread()
     ALOGV("(SignalDrivenThread() ):");
     m_processingSignal = 0;
     m_receivedSignal = 0;
+    m_pendingSignal = 0;
     m_isTerminated = false;    
 }
 
@@ -62,6 +63,7 @@ SignalDrivenThread::SignalDrivenThread(const char* name,
     ALOGV("DEBUG(SignalDrivenThread( , , )):");
     m_processingSignal = 0;
     m_receivedSignal = 0;
+    m_pendingSignal = 0;
     m_isTerminated = false;
     run(name, priority, stack);
     return;
@@ -79,7 +81,11 @@ status_t SignalDrivenThread::SetSignal(uint32_t signal)
 
     Mutex::Autolock lock(m_signalMutex);
     ALOGV("DEBUG(%s):Signal Set     (%x) - prev(%x)", __FUNCTION__, signal, m_receivedSignal);
-    m_receivedSignal |= signal;
+    if (m_receivedSignal & signal) {
+        m_pendingSignal |= signal;
+    } else {
+        m_receivedSignal |= signal;
+    }
     m_threadCondition.signal();
     return NO_ERROR;
 }
@@ -120,7 +126,8 @@ bool SignalDrivenThread::threadLoop()
             m_threadCondition.wait(m_signalMutex);
         }
         m_processingSignal = m_receivedSignal;
-        m_receivedSignal = 0;
+        m_receivedSignal = m_pendingSignal;
+        m_pendingSignal = 0;
     }
     ALOGV("DEBUG(%s):Got Signal (%x)", __FUNCTION__, m_processingSignal);
 
index 87d54aa76263586f8a982ff8d0fdf3f9383f4905..5bb61f27fae69f450cadd9239a9245fc607f7c79 100644 (file)
@@ -71,6 +71,7 @@ private:
 
             uint32_t    m_receivedSignal;
             uint32_t    m_processingSignal;
+            uint32_t    m_pendingSignal;
 
             Mutex       m_signalMutex;
             Condition   m_threadCondition;