using namespace PLATFORM;
#define CEC_PROCESSOR_SIGNAL_WAIT_TIME 1000
-#define ACTIVE_SOURCE_CHECK_TIMEOUT 10000
+#define ACTIVE_SOURCE_CHECK_INTERVAL 500
#define ToString(x) CCECTypeUtils::ToString(x)
it->second->ReplaceHandler(true);
}
-void CCECProcessor::CheckPendingActiveSource(void)
-{
- if (!CECInitialised())
- return;
-
- // check each device
- for (CECDEVICEMAP::iterator it = m_busDevices->Begin(); it != m_busDevices->End(); it++)
- {
- if (it->second->GetHandler()->ActiveSourcePending())
- it->second->ActivateSource();
- }
-}
-
bool CCECProcessor::OnCommandReceived(const cec_command &command)
{
return m_inBuffer.Push(command);
{
m_libcec->AddLog(CEC_LOG_DEBUG, "processor thread started");
- cec_command command;
- CTimeout activeSourceCheck(ACTIVE_SOURCE_CHECK_TIMEOUT);
+ cec_command command; command.Clear();
+ CTimeout activeSourceCheck(ACTIVE_SOURCE_CHECK_INTERVAL);
// as long as we're not being stopped and the connection is open
while (!IsStopped() && m_communication->IsOpen())
// check whether we need to activate a source, if it failed before
if (activeSourceCheck.TimeLeft() == 0)
{
- CheckPendingActiveSource();
- activeSourceCheck.Init(ACTIVE_SOURCE_CHECK_TIMEOUT);
+ if (CECInitialised())
+ TransmitPendingActiveSourceCommands();
+ activeSourceCheck.Init(ACTIVE_SOURCE_CHECK_INTERVAL);
}
}
}
m_iLastTransmission = GetTimeMs();
// set the number of tries
iMaxTries = initiator->GetHandler()->GetTransmitRetries() + 1;
+ initiator->MarkHandlerReady();
}
// and try to send the command
bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress)
{
// stream path changes are sent by the TV
- return GetTV()->GetHandler()->TransmitSetStreamPath(iPhysicalAddress);
+ bool bReturn = GetTV()->GetHandler()->TransmitSetStreamPath(iPhysicalAddress);
+ GetTV()->MarkHandlerReady();
+ return bReturn;
}
bool CCECProcessor::CanPersistConfiguration(void)
return false;
}
+ // ensure that we know the vendor id of the TV
+ CCECBusDevice *tv = GetTV();
+ tv->GetVendorId(CECDEVICE_UNREGISTERED);
+ tv->ReplaceHandler(false);
+
// unregister the client first if it's already been marked as registered
if (client->IsRegistered())
UnregisterClient(client);
m_busDevices->GetByLogicalAddresses(devices, configuration.logicalAddresses);
for (CECDEVICEVEC::const_iterator it = devices.begin(); it != devices.end(); it++)
{
+ // set the physical address of the device at this LA
+ if (CLibCEC::IsValidPhysicalAddress(configuration.iPhysicalAddress))
+ (*it)->SetPhysicalAddress(configuration.iPhysicalAddress);
+
// replace a previous client
CLockObject lock(m_mutex);
m_clients.erase((*it)->GetLogicalAddress());
// get the settings from the rom
if (configuration.bGetSettingsFromROM == 1)
{
- libcec_configuration config;
+ libcec_configuration config; config.Clear();
m_communication->GetConfiguration(config);
CLockObject lock(m_mutex);
client->Alert(CEC_ALERT_SERVICE_DEVICE, param);
}
+ // ensure that the command handler for the TV is initialised
+ if (bReturn)
+ {
+ CCECCommandHandler *handler = GetTV()->GetHandler();
+ if (handler)
+ handler->InitHandler();
+ GetTV()->MarkHandlerReady();
+ }
+
return bReturn;
}