cec: don't keep trying the same command/request after receiving a feature abort message
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
index b43d2b0ed87262f9723ad1b349319f07f7b910a1..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))
@@ -299,7 +310,11 @@ bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command)
   {
     CCECBusDevice *device = GetDevice(command.destination);
     if (device)
-      return device->TransmitPhysicalAddress();
+    {
+      device->SetActiveSource();
+      return device->TransmitPhysicalAddress() &&
+          device->TransmitActiveSource();
+    }
   }
 
   return false;
@@ -577,7 +592,10 @@ bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command)
           }
         }
       }
-      m_processor->SetCurrentButton((cec_user_control_code) command.parameters[0]);
+      else
+      {
+        m_processor->SetCurrentButton((cec_user_control_code) command.parameters[0]);
+      }
       return true;
     }
   }
@@ -919,3 +937,17 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /*
 
   return false;
 }
+
+bool CCECCommandHandler::InitHandler(void)
+{
+  if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
+  {
+    CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+    primary->SetPowerStatus(CEC_POWER_STATUS_ON);
+    primary->SetMenuState(CEC_MENU_STATE_ACTIVATED);
+
+    m_processor->SetActiveSource();
+    primary->TransmitMenuState(m_busDevice->GetLogicalAddress());
+  }
+  return true;
+}