cec: and now proper predicates
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
index 27e80094cd27555de2a3f2858a41a80192397158..44cf477b3507fa0d9073a577e7fbee887514fff1 100644 (file)
@@ -51,7 +51,8 @@ CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice) :
     m_iUseCounter(0),
     m_expectedResponse(CEC_OPCODE_NONE),
     m_bOPTSendDeckStatusUpdateOnActiveSource(false),
-    m_vendorId(CEC_VENDOR_UNKNOWN)
+    m_vendorId(CEC_VENDOR_UNKNOWN),
+    m_bRcvSignal(false)
 {
 }
 
@@ -195,7 +196,10 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command)
     CLockObject lock(m_receiveMutex);
     if (m_expectedResponse == CEC_OPCODE_NONE ||
         m_expectedResponse == command.opcode)
+    {
+      m_bRcvSignal = true;
       m_condition.Signal();
+    }
   }
 
   MarkReady();
@@ -714,17 +718,6 @@ void CCECCommandHandler::SetPhysicalAddress(cec_logical_address iAddress, uint16
   }
 }
 
-void CCECCommandHandler::HandlePoll(const cec_logical_address iInitiator, const cec_logical_address iDestination)
-{
-  CLibCEC::AddLog(CEC_LOG_DEBUG, "<< POLL: %s (%x) -> %s (%x)", m_processor->ToString(iInitiator), iInitiator, m_processor->ToString(iDestination), iDestination);
-}
-
-bool CCECCommandHandler::HandleReceiveFailed(void)
-{
-  /* default = error */
-  return true;
-}
-
 bool CCECCommandHandler::TransmitImageViewOn(const cec_logical_address iInitiator, const cec_logical_address iDestination)
 {
   cec_command command;
@@ -910,6 +903,16 @@ bool CCECCommandHandler::TransmitSetSystemAudioMode(const cec_logical_address iI
   return Transmit(command, false);
 }
 
+bool CCECCommandHandler::TransmitSetStreamPath(uint16_t iStreamPath)
+{
+  cec_command command;
+  cec_command::Format(command, m_busDevice->GetLogicalAddress(), CECDEVICE_BROADCAST, CEC_OPCODE_SET_STREAM_PATH);
+  command.parameters.PushBack((uint8_t) ((iStreamPath >> 8) & 0xFF));
+  command.parameters.PushBack((uint8_t) (iStreamPath        & 0xFF));
+
+  return Transmit(command, false);
+}
+
 bool CCECCommandHandler::TransmitSystemAudioModeStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_system_audio_status state)
 {
   cec_command command;
@@ -963,7 +966,9 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /*
       {
         CLibCEC::AddLog(CEC_LOG_DEBUG, "command transmitted");
         if (bExpectResponse)
-          bReturn = m_condition.Wait(m_receiveMutex, m_iTransmitWait);
+          bReturn = m_condition.Wait(m_receiveMutex, m_bRcvSignal, m_iTransmitWait);
+        if (bReturn)
+          m_bRcvSignal = false;
       }
     }
     --m_iUseCounter;