m_bMonitor(false),
m_busScan(NULL),
m_iStandardLineTimeout(3),
- m_iRetryLineTimeout(3)
+ m_iRetryLineTimeout(3),
+ m_iLastTransmission(0)
{
m_communication = new CAdapterCommunication(this);
m_logicalAddresses.Clear();
m_controller(controller),
m_bMonitor(false),
m_iStandardLineTimeout(3),
- m_iRetryLineTimeout(3)
+ m_iRetryLineTimeout(3),
+ m_iLastTransmission(0)
{
m_communication = new CAdapterCommunication(this);
m_logicalAddresses.Clear();
CCECProcessor::~CCECProcessor(void)
{
- if (m_busScan)
- {
- m_busScan->StopThread();
- delete m_busScan;
- }
-
+ m_bStarted = false;
m_startCondition.Broadcast();
StopThread();
}
else
{
- m_busDevices[m_logicalAddresses.primary]->TransmitPhysicalAddress();
+ m_busDevices[CECDEVICE_TV]->GetVendorId();
+ m_busDevices[m_logicalAddresses.primary]->TransmitVendorID(CECDEVICE_TV, false);
+
CLockObject lock(&m_mutex);
m_bStarted = true;
m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started");
m_controller->CheckKeypressTimeout();
}
+ if (m_busScan)
+ {
+ m_busScan->StopThread();
+ delete m_busScan;
+ m_busScan = NULL;
+ }
+
if (m_communication)
m_communication->Close();
}
}
- bReturn = m_busDevices[CECDEVICE_TV]->PowerOn() &&
- m_busDevices[addr]->TransmitActiveSource() &&
+ bReturn = m_busDevices[addr]->TransmitActiveSource() &&
SetStreamPath(m_busDevices[addr]->GetPhysicalAddress(false));
if (bReturn && (m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
m_iRetryLineTimeout = iTimeout;
}
-bool CCECProcessor::SetActiveSource(cec_logical_address iAddress)
-{
- return SetStreamPath(m_busDevices[iAddress]->GetPhysicalAddress(false));
-}
-
bool CCECProcessor::SetActiveView(void)
{
return SetActiveSource(m_types.IsEmpty() ? CEC_DEVICE_TYPE_RESERVED : m_types[0]);
{
for (uint8_t iPtr = 0; iPtr < 15; iPtr++)
if (m_logicalAddresses[iPtr])
+ {
+ m_busDevices[iPtr]->SetInactiveDevice();
m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress);
+ m_busDevices[iPtr]->TransmitPhysicalAddress();
+ }
return SetActiveView();
}
return false;
CLockObject lock(&m_mutex);
m_bMonitor = bEnable;
- if (bEnable)
+ if (!bEnable)
{
if (!m_busScan)
{
return false;
}
+uint16_t CCECProcessor::GetDevicePhysicalAddress(cec_logical_address iAddress)
+{
+ if (m_busDevices[iAddress])
+ return m_busDevices[iAddress]->GetPhysicalAddress(false);
+ return false;
+}
+
cec_power_status CCECProcessor::GetDevicePowerStatus(cec_logical_address iAddress)
{
if (m_busDevices[iAddress])
bool bReturn(false);
CLockObject lock(&m_mutex);
{
+ m_iLastTransmission = GetTimeMs();
m_communication->SetLineTimeout(m_iStandardLineTimeout);
output->tries = 1;
void *CCECBusScan::Process(void)
{
CCECBusDevice *device(NULL);
- int iCount(50);
+ uint8_t iCounter(0);
+
while (!IsStopped())
{
- if (iCount == 0)
+ if (++iCounter < 30)
{
- for (unsigned int iPtr = 0; iPtr <= 11 && !IsStopped(); iPtr++)
+ Sleep(1000);
+ continue;
+ }
+ for (unsigned int iPtr = 0; iPtr <= 11 && !IsStopped(); iPtr++)
+ {
+ device = m_processor->m_busDevices[iPtr];
+ WaitUntilIdle();
+ if (device && device->GetStatus(true) == CEC_DEVICE_STATUS_PRESENT)
{
- device = m_processor->m_busDevices[iPtr];
- if (device && device->GetStatus(true) == CEC_DEVICE_STATUS_PRESENT)
- {
- if (!IsStopped())
- {
- device->GetVendorId();
- Sleep(5);
- }
- if (!IsStopped())
- {
- device->GetPowerStatus(true);
- Sleep(5);
- }
- }
+ WaitUntilIdle();
+ if (!IsStopped())
+ device->GetVendorId();
+
+ WaitUntilIdle();
+ if (!IsStopped())
+ device->GetPowerStatus(true);
}
}
-
- if (++iCount > 60)
- iCount = 0;
- Sleep(1000);
}
+
return NULL;
}
+void CCECBusScan::WaitUntilIdle(void)
+{
+ if (IsStopped())
+ return;
+
+ int64_t iWaitTime = 3000 - (GetTimeMs() - m_processor->GetLastTransmission());
+ while (iWaitTime > 0)
+ {
+ Sleep(iWaitTime);
+ iWaitTime = 3000 - (GetTimeMs() - m_processor->GetLastTransmission());
+ }
+}
+
bool CCECProcessor::StartBootloader(void)
{
return m_communication->StartBootloader();