cec: fixed 'unsupported command' marking in CCECBusDevice
authorLars Op den Kamp <lars@opdenkamp.eu>
Fri, 17 Feb 2012 09:53:56 +0000 (10:53 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Fri, 17 Feb 2012 10:39:30 +0000 (11:39 +0100)
src/lib/devices/CECBusDevice.cpp
src/lib/implementations/CECCommandHandler.cpp
src/lib/implementations/CECCommandHandler.h

index 3638453125809c92ef2383e4f77cad62202ff7af..a0d612ed5daa8178740a58475d2ff8b415da3170 100644 (file)
@@ -169,7 +169,8 @@ bool CCECBusDevice::RequestCecVersion(void)
 {
   bool bReturn(false);
 
-  if (!MyLogicalAddressContains(m_iLogicalAddress))
+  if (!MyLogicalAddressContains(m_iLogicalAddress) &&
+      !IsUnsupportedFeature(CEC_OPCODE_GET_CEC_VERSION))
   {
     MarkBusy();
     CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting CEC version of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
@@ -811,7 +812,7 @@ bool CCECBusDevice::TransmitOSDName(cec_logical_address dest)
 bool CCECBusDevice::TransmitOSDString(cec_logical_address dest, cec_display_control duration, const char *strMessage)
 {
   bool bReturn(false);
-  if (!IsUnsupportedFeature(CEC_OPCODE_SET_OSD_STRING))
+  if (!m_processor->m_busDevices[dest]->IsUnsupportedFeature(CEC_OPCODE_SET_OSD_STRING))
   {
     CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, strMessage);
     MarkBusy();
@@ -933,11 +934,15 @@ bool CCECBusDevice::TransmitKeyRelease(bool bWait /* = true */)
 
 bool CCECBusDevice::IsUnsupportedFeature(cec_opcode opcode) const
 {
-  return m_unsupportedFeatures.find(opcode) != m_unsupportedFeatures.end();
+  bool bUnsupported = (m_unsupportedFeatures.find(opcode) != m_unsupportedFeatures.end());
+  if (bUnsupported)
+    CLibCEC::AddLog(CEC_LOG_NOTICE, "'%s' is marked as unsupported feature for device '%s'", ToString(opcode), GetLogicalAddressName());
+  return bUnsupported;
 }
 
 void CCECBusDevice::SetUnsupportedFeature(cec_opcode opcode)
 {
+  CLibCEC::AddLog(CEC_LOG_DEBUG, "marking opcode '%s' as unsupported feature for device '%s'", ToString(opcode), GetLogicalAddressName());
   m_unsupportedFeatures.insert(opcode);
 }
 
index 83d993682b510d97132aa98af76e969410c2536a..f742fc9922b98bedefecb36314471326b5e64eb8 100644 (file)
@@ -49,6 +49,7 @@ CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice) :
     m_iTransmitRetries(CEC_DEFAULT_TRANSMIT_RETRIES),
     m_bHandlerInited(false),
     m_expectedResponse(CEC_OPCODE_NONE),
+    m_lastCommandSent(CEC_OPCODE_NONE),
     m_bOPTSendDeckStatusUpdateOnActiveSource(false),
     m_vendorId(CEC_VENDOR_UNKNOWN),
     m_bRcvSignal(false)
@@ -191,7 +192,8 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command)
   {
     CLockObject lock(m_receiveMutex);
     if (m_expectedResponse == CEC_OPCODE_NONE ||
-        m_expectedResponse == command.opcode)
+        m_expectedResponse == command.opcode ||
+        (command.opcode == CEC_OPCODE_FEATURE_ABORT && command.parameters.size > 0 && command.parameters[0] == m_lastCommandSent))
     {
       m_bRcvSignal = true;
       m_condition.Signal();
@@ -251,10 +253,8 @@ bool CCECCommandHandler::HandleDeviceVendorId(const cec_command &command)
 
 bool CCECCommandHandler::HandleFeatureAbort(const cec_command &command)
 {
-  if (command.parameters.size == 2)
-  {
+  if (command.parameters.size == 2 && command.parameters[1] == CEC_ABORT_REASON_UNRECOGNIZED_OPCODE)
     m_processor->m_busDevices[command.initiator]->SetUnsupportedFeature((cec_opcode)command.parameters[0]);
-  }
   return true;
 }
 
@@ -967,12 +967,13 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /*
     while (!bReturn && ++iTries <= iMaxTries)
     {
       m_expectedResponse = expectedResponse;
+      m_lastCommandSent  = command.opcode;
+      m_bRcvSignal = false;
       if ((bReturn = m_processor->Transmit(command)) == true)
       {
         CLibCEC::AddLog(CEC_LOG_DEBUG, "command transmitted");
         if (bExpectResponse)
           bReturn = m_condition.Wait(m_receiveMutex, m_bRcvSignal, m_iTransmitWait);
-        m_bRcvSignal = false;
         CLibCEC::AddLog(CEC_LOG_DEBUG, bReturn ? "expected response received" : "expected response not received");
       }
     }
index a60dc731276bb450b4460e4a5e8e6be1b2f43b75..a1b1f96fb90e2c16ff5c57f711d6af7703d8028a 100644 (file)
@@ -137,6 +137,7 @@ namespace CEC
     int8_t                                m_iTransmitRetries;
     bool                                  m_bHandlerInited;
     cec_opcode                            m_expectedResponse;
+    cec_opcode                            m_lastCommandSent;
     bool                                  m_bOPTSendDeckStatusUpdateOnActiveSource;
     cec_vendor_id                         m_vendorId;
     PLATFORM::CMutex                      m_receiveMutex;