+
+void CCECProcessor::HandlePoll(cec_logical_address initiator, cec_logical_address destination)
+{
+ m_busDevices[initiator]->HandlePoll(destination);
+}
+
+bool CCECProcessor::HandleReceiveFailed(cec_logical_address initiator)
+{
+ return !m_busDevices[initiator]->HandleReceiveFailed();
+}
+
+bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress)
+{
+ // stream path changes are sent by the TV
+ return m_busDevices[CECDEVICE_TV]->GetHandler()->TransmitSetStreamPath(iPhysicalAddress);
+}
+
+bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
+{
+ bool bReinit(false);
+ CCECBusDevice *primary = IsRunning() ? GetPrimaryDevice() : NULL;
+ cec_device_type oldPrimaryType = primary ? primary->GetType() : CEC_DEVICE_TYPE_RECORDING_DEVICE;
+ m_configuration.clientVersion = configuration->clientVersion;
+
+ // client version 1.5.0
+
+ // device types
+ bool bDeviceTypeChanged = IsRunning () && m_configuration.deviceTypes != configuration->deviceTypes;
+ m_configuration.deviceTypes = configuration->deviceTypes;
+
+ // autodetect address
+ uint16_t iPhysicalAddress = IsRunning() && configuration->bAutodetectAddress ? m_communication->GetPhysicalAddress() : 0;
+ bool bPhysicalAutodetected = IsRunning() && configuration->bAutodetectAddress && iPhysicalAddress != m_configuration.iPhysicalAddress && iPhysicalAddress != 0;
+ if (bPhysicalAutodetected)
+ {
+ m_configuration.iPhysicalAddress = iPhysicalAddress;
+ m_configuration.bAutodetectAddress = true;
+ }
+ else
+ {
+ m_configuration.bAutodetectAddress = false;
+ }
+
+ // physical address
+ bool bPhysicalAddressChanged(false);
+ if (!bPhysicalAutodetected)
+ {
+ bPhysicalAddressChanged = IsRunning() && m_configuration.iPhysicalAddress != configuration->iPhysicalAddress;
+ m_configuration.iPhysicalAddress = configuration->iPhysicalAddress;
+ }
+
+ // base device
+ bool bHdmiPortChanged(false);
+ if (!bPhysicalAutodetected && !bPhysicalAddressChanged)
+ {
+ bHdmiPortChanged = IsRunning() && m_configuration.baseDevice != configuration->baseDevice;
+ m_configuration.baseDevice = configuration->baseDevice;
+ }
+ else
+ {
+ m_configuration.baseDevice = CECDEVICE_UNKNOWN;
+ }
+
+ // hdmi port
+ if (!bPhysicalAutodetected && !bPhysicalAddressChanged)
+ {
+ bHdmiPortChanged |= IsRunning() && m_configuration.iHDMIPort != configuration->iHDMIPort;
+ m_configuration.iHDMIPort = configuration->iHDMIPort;
+ }
+ else
+ {
+ m_configuration.iHDMIPort = 0;
+ }
+
+ bReinit = bPhysicalAddressChanged || bHdmiPortChanged || bDeviceTypeChanged || bPhysicalAutodetected;
+
+ // device name
+ snprintf(m_configuration.strDeviceName, 13, "%s", configuration->strDeviceName);
+ if (primary && !primary->GetOSDName().Equals(m_configuration.strDeviceName))
+ {
+ primary->SetOSDName(m_configuration.strDeviceName);
+ if (!bReinit && IsRunning())
+ primary->TransmitOSDName(CECDEVICE_TV);
+ }
+
+ // tv vendor id override
+ if (m_configuration.tvVendor != configuration->tvVendor)
+ {
+ m_configuration.tvVendor= configuration->tvVendor;
+ m_busDevices[CECDEVICE_TV]->SetVendorId((uint64_t)m_configuration.tvVendor);
+ }
+
+ // wake CEC devices
+ if (m_configuration.wakeDevices != configuration->wakeDevices)
+ {
+ m_configuration.wakeDevices = configuration->wakeDevices;
+ if (!bReinit && IsRunning())
+ PowerOnDevices();
+ }
+
+ // just copy these
+ m_configuration.clientVersion = configuration->clientVersion;
+ m_configuration.bActivateSource = configuration->bActivateSource;
+ m_configuration.bGetSettingsFromROM = configuration->bGetSettingsFromROM;
+ m_configuration.powerOffDevices = configuration->powerOffDevices;
+ m_configuration.bPowerOffScreensaver = configuration->bPowerOffScreensaver;
+ m_configuration.bPowerOffOnStandby = configuration->bPowerOffOnStandby;
+
+ // ensure that there is at least 1 device type set
+ if (m_configuration.deviceTypes.IsEmpty())
+ m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
+
+ if (bReinit)
+ {
+ if (bDeviceTypeChanged)
+ return ChangeDeviceType(oldPrimaryType, m_configuration.deviceTypes[0]);
+ else if (bPhysicalAddressChanged)
+ return SetPhysicalAddress(m_configuration.iPhysicalAddress);
+ else
+ return SetHDMIPort(m_configuration.baseDevice, m_configuration.iHDMIPort);
+ }
+
+ return true;
+}
+
+bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration)
+{
+ // client version 1.5.0
+ snprintf(configuration->strDeviceName, 13, "%s", m_configuration.strDeviceName);
+ configuration->deviceTypes = m_configuration.deviceTypes;
+ configuration->bAutodetectAddress = m_configuration.bAutodetectAddress;
+ configuration->iPhysicalAddress = m_configuration.iPhysicalAddress;
+ configuration->baseDevice = m_configuration.baseDevice;
+ configuration->iHDMIPort = m_configuration.iHDMIPort;
+ configuration->clientVersion = m_configuration.clientVersion;
+ configuration->serverVersion = m_configuration.serverVersion;
+ configuration->tvVendor = m_configuration.tvVendor;
+
+ configuration->bGetSettingsFromROM = m_configuration.bGetSettingsFromROM;
+ configuration->bUseTVMenuLanguage = m_configuration.bUseTVMenuLanguage;
+ configuration->bActivateSource = m_configuration.bActivateSource;
+ configuration->wakeDevices = m_configuration.wakeDevices;
+ configuration->powerOffDevices = m_configuration.powerOffDevices;
+ configuration->bPowerOffScreensaver = m_configuration.bPowerOffScreensaver;
+ configuration->bPowerOffOnStandby = m_configuration.bPowerOffOnStandby;
+
+ return true;
+}
+
+bool CCECProcessor::CanPersistConfiguration(void)
+{
+ return m_communication->GetFirmwareVersion() >= 2;
+}
+
+bool CCECProcessor::PersistConfiguration(libcec_configuration *configuration)
+{
+ return m_communication->PersistConfiguration(configuration);
+}
+
+void CCECProcessor::RescanActiveDevices(void)
+{
+ for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
+ m_busDevices[iPtr]->GetStatus(true);
+}