cec: cleanups in ActivateSource() and CSLCommandHandler
[deb_libcec.git] / src / lib / CECProcessor.cpp
index 6eeb38df53a6d4fc25cecf3a554b61de7e04f0f1..ebd17729f4e0355f3ad77ab8f2a30a3a85f70188 100644 (file)
@@ -211,10 +211,10 @@ bool CCECProcessor::Initialise(void)
 
   /* get the vendor id from the TV, so we are using the correct handler */
   m_busDevices[CECDEVICE_TV]->RequestVendorId();
-  ReplaceHandlers();
 
   if (m_iPhysicalAddress != 0)
   {
+    CLibCEC::AddLog(CEC_LOG_NOTICE, "setting the physical address to %4x", m_iPhysicalAddress);
     m_busDevices[m_logicalAddresses.primary]->m_iPhysicalAddress = m_iPhysicalAddress;
     if ((bReturn = m_busDevices[m_logicalAddresses.primary]->TransmitPhysicalAddress()) == false)
       CLibCEC::AddLog(CEC_LOG_ERROR, "unable to set the physical address to %4x", m_iPhysicalAddress);
@@ -406,7 +406,6 @@ bool CCECProcessor::FindLogicalAddresses(void)
 
 void CCECProcessor::ReplaceHandlers(void)
 {
-  CLockObject lock(m_mutex);
   if (!IsInitialised())
     return;
   for (uint8_t iPtr = 0; iPtr <= CECDEVICE_PLAYBACKDEVICE3; iPtr++)
@@ -460,22 +459,7 @@ bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RE
 
   m_busDevices[addr]->SetActiveSource();
   if (m_busDevices[addr]->GetPhysicalAddress(false) != 0xFFFF)
-  {
-    bReturn = m_busDevices[addr]->TransmitActiveSource();
-
-    if (bReturn)
-    {
-      m_busDevices[addr]->SetMenuState(CEC_MENU_STATE_ACTIVATED);
-      m_busDevices[addr]->TransmitMenuState(CECDEVICE_TV);
-    }
-
-    if (bReturn && (m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
-        m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) &&
-        m_busDevices[addr]->GetHandler()->SendDeckStatusUpdateOnActiveSource())
-    {
-      bReturn = ((CCECPlaybackDevice *)m_busDevices[addr])->TransmitDeckStatus(CECDEVICE_TV);
-    }
-  }
+    bReturn = m_busDevices[addr]->ActivateSource();
 
   return bReturn;
 }
@@ -1369,3 +1353,23 @@ bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress)
   // stream path changes are sent by the TV
   return m_busDevices[CECDEVICE_TV]->GetHandler()->TransmitSetStreamPath(iPhysicalAddress);
 }
+
+bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration)
+{
+  configuration->iPhysicalAddress = m_iPhysicalAddress;
+  configuration->iHDMIPort = m_iHDMIPort;
+  configuration->baseDevice = m_iBaseDevice;
+  snprintf(configuration->strDeviceName, 13, "%s", m_strDeviceName.c_str());
+  configuration->deviceTypes = m_types;
+  return true;
+}
+
+bool CCECProcessor::CanPersistConfiguration(void)
+{
+  return m_communication->GetFirmwareVersion() >= 2;
+}
+
+bool CCECProcessor::PersistConfiguration(libcec_configuration *configuration)
+{
+  return m_communication->PersistConfiguration(configuration);
+}