X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2FCECProcessor.cpp;h=b8d6d2bfb357b46538794e699449eeccd7327659;hb=7c63a480cbe63c5c6725b9558ae21acbe427ccc2;hp=132d01e4990f8440ba27b710f36b338cc9af7566;hpb=9fd73dd492819cc18bac465d2a98f31019378886;p=deb_libcec.git diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 132d01e..b8d6d2b 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -53,7 +53,8 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, CAdapterCommunication *serComm m_strDeviceName(strDeviceName), m_communication(serComm), m_controller(controller), - m_bMonitor(false) + m_bMonitor(false), + m_busScan(NULL) { m_logicalAddresses.Clear(); m_logicalAddresses.Set(iLogicalAddress); @@ -107,8 +108,15 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, CAdapterCommunication *serComm CCECProcessor::~CCECProcessor(void) { + if (m_busScan) + { + m_busScan->StopThread(); + delete m_busScan; + } + m_startCondition.Broadcast(); StopThread(); + m_communication = NULL; m_controller = NULL; for (unsigned int iPtr = 0; iPtr < 16; iPtr++) @@ -136,7 +144,8 @@ bool CCECProcessor::Start(void) if (SetAckMask(m_logicalAddresses.AckMask()) && SetHDMIPort(m_iHDMIPort, true)) { - ScanCECBus(); + m_busScan = new CCECBusScan(this); + m_busScan->CreateThread(true); return true; } } @@ -383,21 +392,6 @@ bool CCECProcessor::SetHDMIPort(uint8_t iPort, bool bForce /* = false */) return bReturn; } -void CCECProcessor::ScanCECBus(void) -{ - CCECBusDevice *device(NULL); - for (unsigned int iPtr = 0; iPtr < 16; iPtr++) - { - device = m_busDevices[iPtr]; - if (device && device->GetStatus() == CEC_DEVICE_STATUS_PRESENT) - { - device->GetPhysicalAddress(); - device->GetCecVersion(); - device->GetVendorId(); - } - } -} - bool CCECProcessor::CheckPhysicalAddress(uint16_t iPhysicalAddress) { for (unsigned int iPtr = 0; iPtr < 15; iPtr++) @@ -422,13 +416,13 @@ bool CCECProcessor::SetStreamPath(uint16_t iStreamPath) return bReturn; } -bool CCECProcessor::SetInactiveView(void) +bool CCECProcessor::TransmitInactiveSource(void) { if (!IsRunning()) return false; if (!m_logicalAddresses.IsEmpty() && m_busDevices[m_logicalAddresses.primary]) - return m_busDevices[m_logicalAddresses.primary]->TransmitInactiveView(); + return m_busDevices[m_logicalAddresses.primary]->TransmitInactiveSource(); return false; } @@ -852,3 +846,27 @@ bool CCECProcessor::SendKeyRelease(cec_logical_address iDestination, bool bWait { return m_busDevices[iDestination]->SendKeyRelease(bWait); } + +void *CCECBusScan::Process(void) +{ + CCECBusDevice *device(NULL); + for (unsigned int iPtr = 0; iPtr < 15 && !IsStopped(); iPtr++) + { + device = m_processor->m_busDevices[iPtr]; + if (device && device->GetStatus() == CEC_DEVICE_STATUS_PRESENT) + { + if (!IsStopped()) + device->GetPhysicalAddress(); + Sleep(5); + + if (!IsStopped()) + device->GetCecVersion(); + Sleep(5); + + if (!IsStopped()) + device->GetVendorId(); + Sleep(5); + } + } + return NULL; +}