cec: signal waiting threads when receiving a feature abort too
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
index eed60878d8231244346e80756ef45f39081f9d5d..2d3fbe0af29376e5ad5500b09f29d87583f9bbac 100644 (file)
@@ -334,12 +334,7 @@ bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command)
   {
     CCECBusDevice *device = GetDevice(command.destination);
     if (device)
-    {
-      device->SetActiveSource();
-      return device->TransmitPhysicalAddress() &&
-          device->TransmitImageViewOn() &&
-          device->TransmitActiveSource();
-    }
+      return device->TransmitPhysicalAddress();
   }
 
   return false;
@@ -379,11 +374,20 @@ bool CCECCommandHandler::HandleMenuRequest(const cec_command &command)
 {
   if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination))
   {
-    if (command.parameters[0] == CEC_MENU_REQUEST_TYPE_QUERY)
+    CCECBusDevice *device = GetDevice(command.destination);
+    if (device)
     {
-      CCECBusDevice *device = GetDevice(command.destination);
-      if (device)
-        return device->TransmitMenuState(command.initiator);
+      if (command.parameters[0] == CEC_MENU_REQUEST_TYPE_ACTIVATE)
+      {
+        if (CLibCEC::MenuStateChanged(CEC_MENU_STATE_ACTIVATED) == 1)
+          device->SetMenuState(CEC_MENU_STATE_ACTIVATED);
+      }
+      else if (command.parameters[0] == CEC_MENU_REQUEST_TYPE_DEACTIVATE)
+      {
+        if (CLibCEC::MenuStateChanged(CEC_MENU_STATE_DEACTIVATED) == 1)
+          device->SetMenuState(CEC_MENU_STATE_DEACTIVATED);
+      }
+      return device->TransmitMenuState(command.initiator);
     }
   }
 
@@ -1006,8 +1010,8 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /*
   }
 
   {
-    uint8_t iTries(0), iMaxTries(command.opcode == CEC_OPCODE_NONE ? 1 : m_iTransmitRetries + 1);
-    while (!bReturn && ++iTries <= iMaxTries)
+    uint8_t iTries(0), iMaxTries(!command.opcode_set ? 1 : m_iTransmitRetries + 1);
+    while (!bReturn && ++iTries <= iMaxTries && !m_busDevice->IsUnsupportedFeature(command.opcode))
     {
       if ((bReturn = m_processor->Transmit(command)) == true)
       {
@@ -1043,3 +1047,8 @@ bool CCECCommandHandler::ActivateSource(void)
   }
   return true;
 }
+
+void CCECCommandHandler::SignalOpcode(cec_opcode opcode)
+{
+  m_waitForResponse->Received(opcode);
+}