/* open a new connection */
unsigned iConnectTry(0);
- while (timeout.TimeLeft() > 0 && (bReturn = m_communication->Open(this, (timeout.TimeLeft() / CEC_CONNECT_TRIES), false, bStartListening)) == false)
+ while (timeout.TimeLeft() > 0 && (bReturn = m_communication->Open((timeout.TimeLeft() / CEC_CONNECT_TRIES), false, bStartListening)) == false)
{
CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry);
m_communication->Close();
else if (m_configuration.iPhysicalAddress == 0 && (bReturn = SetHDMIPort(m_configuration.baseDevice, m_configuration.iHDMIPort, true)) == false)
CLibCEC::AddLog(CEC_LOG_ERROR, "unable to set HDMI port %d on %s (%x)", m_configuration.iHDMIPort, ToString(m_configuration.baseDevice), (uint8_t)m_configuration.baseDevice);
- if (m_configuration.bActivateSource == 1)
+ if (bReturn && m_configuration.bActivateSource == 1)
m_busDevices[m_configuration.logicalAddresses.primary]->ActivateSource();
SetInitialised(bReturn);
bool CCECProcessor::OnCommandReceived(const cec_command &command)
{
- ParseCommand(command);
- return true;
+ return m_inBuffer.Push(command);
}
void *CCECProcessor::Process(void)
{
CLibCEC::AddLog(CEC_LOG_DEBUG, "processor thread started");
+ cec_command command;
+ command.Clear();
+
while (!IsStopped() && m_communication->IsOpen())
{
+ if (m_inBuffer.Pop(command, 500))
+ ParseCommand(command);
+
if (IsInitialised())
{
ReplaceHandlers();
m_controller->CheckKeypressTimeout();
}
- Sleep(5);
}
return NULL;
{
bool bReturn(false);
- CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamPath);
+ // suppress polls when searching for a device
+ CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamPath, false, true);
if (device)
{
device->SetActiveSource();
{
bool bReturn(false);
+ // limit the HDMI port range to 1-15
+ if (iPort < 1)
+ iPort = 1;
+ if (iPort > 15)
+ iPort = 15;
+
{
CLockObject lock(m_mutex);
m_configuration.baseDevice = iBaseDevice;
return status;
}
-CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bRefresh /* = false */) const
+CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bRefresh /* = false */, bool bSuppressPoll /* = false */) const
{
if (m_busDevices[m_configuration.logicalAddresses.primary]->GetPhysicalAddress(false) == iPhysicalAddress)
return m_busDevices[m_configuration.logicalAddresses.primary];
CCECBusDevice *device = NULL;
for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
{
- if (m_busDevices[iPtr]->GetPhysicalAddress(bRefresh) == iPhysicalAddress)
+ if (m_busDevices[iPtr]->GetPhysicalAddress(bRefresh, bSuppressPoll) == iPhysicalAddress)
{
device = m_busDevices[iPtr];
break;
void CCECProcessor::HandlePoll(cec_logical_address initiator, cec_logical_address destination)
{
- m_busDevices[destination]->HandlePoll(initiator);
+ if (destination < CECDEVICE_BROADCAST)
+ m_busDevices[destination]->HandlePollFrom(initiator);
}
bool CCECProcessor::HandleReceiveFailed(cec_logical_address initiator)
{
if (configuration->iPhysicalAddress != 0)
bPhysicalAddressChanged = IsRunning() && m_configuration.iPhysicalAddress != configuration->iPhysicalAddress;
- if (IsRunning())
- CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using physical address '%4x'", __FUNCTION__, configuration->iPhysicalAddress);
- m_configuration.iPhysicalAddress = configuration->iPhysicalAddress;
+ if (bPhysicalAddressChanged)
+ {
+ if (IsRunning())
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using physical address '%4x'", __FUNCTION__, configuration->iPhysicalAddress);
+ m_configuration.iPhysicalAddress = configuration->iPhysicalAddress;
+ }
}
bool bHdmiPortChanged(false);
if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_1)
m_configuration.bSendInactiveSource = configuration->bSendInactiveSource;
+ // client version 1.6.0
+ if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_6_0)
+ {
+ m_configuration.bPowerOffDevicesOnStandby = configuration->bPowerOffDevicesOnStandby;
+ m_configuration.bShutdownOnStandby = configuration->bShutdownOnStandby;
+ }
+
// ensure that there is at least 1 device type set
if (m_configuration.deviceTypes.IsEmpty())
m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
configuration->logicalAddresses = m_configuration.logicalAddresses;
// client version 1.6.0
- if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_3)
- configuration->logicalAddresses = m_configuration.logicalAddresses;
+ if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_6_0)
+ {
+ configuration->iFirmwareVersion = m_configuration.iFirmwareVersion;
+ configuration->bPowerOffDevicesOnStandby = m_configuration.bPowerOffDevicesOnStandby;
+ configuration->bShutdownOnStandby = m_configuration.bShutdownOnStandby;
+ }
return true;
}