cec: don't keep trying the same command/request after receiving a feature abort message
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 21 Dec 2011 23:21:29 +0000 (00:21 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 21 Dec 2011 23:56:33 +0000 (00:56 +0100)
src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h
src/lib/implementations/CECCommandHandler.cpp
src/lib/implementations/CECCommandHandler.h

index 794829ae3ab51ec84e23ed83275ebbde0f5116bd..1f612c4b551601fa38deaa2b85509951d0e7188a 100644 (file)
@@ -194,7 +194,8 @@ cec_menu_language &CCECBusDevice::GetMenuLanguage(bool bUpdate /* = false */)
 bool CCECBusDevice::RequestMenuLanguage(void)
 {
   bool bReturn(false);
-  if (!MyLogicalAddressContains(m_iLogicalAddress))
+  if (!MyLogicalAddressContains(m_iLogicalAddress) &&
+      !IsUnsupportedFeature(CEC_OPCODE_GET_MENU_LANGUAGE))
   {
     CStdString strLog;
     strLog.Format("<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
@@ -228,7 +229,8 @@ CStdString CCECBusDevice::GetOSDName(bool bUpdate /* = false */)
 bool CCECBusDevice::RequestOSDName(void)
 {
   bool bReturn(false);
-  if (!MyLogicalAddressContains(m_iLogicalAddress))
+  if (!MyLogicalAddressContains(m_iLogicalAddress) &&
+      !IsUnsupportedFeature(CEC_OPCODE_GIVE_OSD_NAME))
   {
     CStdString strLog;
     strLog.Format("<< requesting OSD name of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
@@ -277,7 +279,8 @@ cec_power_status CCECBusDevice::GetPowerStatus(bool bUpdate /* = false */)
 bool CCECBusDevice::RequestPowerStatus(void)
 {
   bool bReturn(false);
-  if (!MyLogicalAddressContains(m_iLogicalAddress))
+  if (!MyLogicalAddressContains(m_iLogicalAddress) &&
+      !IsUnsupportedFeature(CEC_OPCODE_GIVE_DEVICE_POWER_STATUS))
   {
     CStdString strLog;
     strLog.Format("<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
@@ -689,11 +692,15 @@ bool CCECBusDevice::TransmitOSDName(cec_logical_address dest)
 
 bool CCECBusDevice::TransmitOSDString(cec_logical_address dest, cec_display_control duration, const char *strMessage)
 {
-  CStdString strLog;
-  strLog.Format("<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, strMessage);
-  AddLog(CEC_LOG_NOTICE, strLog.c_str());
+  if (!IsUnsupportedFeature(CEC_OPCODE_SET_OSD_STRING))
+  {
+    CStdString strLog;
+    strLog.Format("<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, strMessage);
+    AddLog(CEC_LOG_NOTICE, strLog.c_str());
 
-  return m_handler->TransmitOSDString(m_iLogicalAddress, dest, duration, strMessage);
+    return m_handler->TransmitOSDString(m_iLogicalAddress, dest, duration, strMessage);
+  }
+  return false;
 }
 
 bool CCECBusDevice::TransmitPhysicalAddress(void)
@@ -797,4 +804,14 @@ bool CCECBusDevice::TransmitKeyRelease(bool bWait /* = true */)
 {
   return m_handler->TransmitKeyRelease(m_processor->GetLogicalAddress(), m_iLogicalAddress, bWait);
 }
+
+bool CCECBusDevice::IsUnsupportedFeature(cec_opcode opcode) const
+{
+  return m_unsupportedFeatures.find(opcode) != m_unsupportedFeatures.end();
+}
+
+void CCECBusDevice::SetUnsupportedFeature(cec_opcode opcode)
+{
+  m_unsupportedFeatures.insert(opcode);
+}
 //@}
index 23b6c15cd5ec0d8cc51946b205be920140dda12c..c25966359a03e78b39e3e347a3fad3852f742f56 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <cectypes.h>
+#include <set>
 #include "../platform/threads.h"
 #include "../util/StdString.h"
 
@@ -73,7 +74,8 @@ namespace CEC
     virtual bool                  MyLogicalAddressContains(cec_logical_address address) const;
     virtual cec_bus_device_status GetStatus(bool bForcePoll = false);
     virtual bool                  IsActiveSource(void) const { return m_bActiveSource; }
-
+    virtual bool                  IsUnsupportedFeature(cec_opcode opcode) const;
+    virtual void                  SetUnsupportedFeature(cec_opcode opcode);
 
     virtual void SetInactiveSource(void);
     virtual void SetActiveSource(void);
@@ -127,6 +129,7 @@ namespace CEC
     uint64_t              m_iLastActive;
     cec_version           m_cecVersion;
     cec_bus_device_status m_deviceStatus;
+    std::set<cec_opcode>  m_unsupportedFeatures;
     CMutex                m_writeMutex;
     CMutex                m_mutex;
   };
index 3906060691712eb822137a5c0dc2978b7e433351..8d16a02fded9c611518c66207693ea95e29385d0 100644 (file)
@@ -158,6 +158,9 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command)
   case CEC_OPCODE_TEXT_VIEW_ON:
     HandleTextViewOn(command);
     break;
+  case CEC_OPCODE_FEATURE_ABORT:
+    HandleFeatureAbort(command);
+    break;
   default:
     UnhandledCommand(command);
     bHandled = false;
@@ -221,6 +224,14 @@ bool CCECCommandHandler::HandleDeviceVendorId(const cec_command &command)
   return SetVendorId(command);
 }
 
+bool CCECCommandHandler::HandleFeatureAbort(const cec_command &command)
+{
+  if (command.parameters.size == 2)
+  {
+    m_processor->m_busDevices[command.initiator]->SetUnsupportedFeature((cec_opcode)command.parameters[0]);
+  }
+}
+
 bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command)
 {
   if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination))
index 5da9823a0694949429c81305a82f4bba0716ceb3..762052bc6050c752e56fd0a7d16650f0a492fb55 100644 (file)
@@ -86,6 +86,7 @@ namespace CEC
     virtual bool HandleDeviceCecVersion(const cec_command &command);
     virtual bool HandleDeviceVendorCommandWithId(const cec_command &command);
     virtual bool HandleDeviceVendorId(const cec_command &command);
+    virtual bool HandleFeatureAbort(const cec_command &command);
     virtual bool HandleGetCecVersion(const cec_command &command);
     virtual bool HandleGiveAudioStatus(const cec_command &command);
     virtual bool HandleGiveDeckStatus(const cec_command &command);