X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FCECProcessor.cpp;h=292d69dd56e223dbf5249383831ade80b29de88e;hb=0b775bf2f3832de0bf4cf894b68e6f48baca4959;hp=0b834bf545fb8eee2387c9f3f130ddff9d1dc98b;hpb=12251a8773258f68964cdb5237d8086af073d92c;p=deb_libcec.git diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 0b834bf..292d69d 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; } } @@ -268,14 +277,6 @@ void *CCECProcessor::Process(void) Sleep(5); m_controller->CheckKeypressTimeout(); - - for (uint8_t iDevicePtr = 0; iDevicePtr < 16; iDevicePtr++) - { - if (!m_logicalAddresses[iDevicePtr]) - m_busDevices[iDevicePtr]->PollVendorId(); - } - - Sleep(5); } return NULL; @@ -383,24 +384,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(); - Sleep(5); - device->GetCecVersion(); - Sleep(5); - device->GetVendorId(); - Sleep(5); - } - } -} - bool CCECProcessor::CheckPhysicalAddress(uint16_t iPhysicalAddress) { for (unsigned int iPtr = 0; iPtr < 15; iPtr++) @@ -855,3 +838,31 @@ bool CCECProcessor::SendKeyRelease(cec_logical_address iDestination, bool bWait { return m_busDevices[iDestination]->SendKeyRelease(bWait); } + +void *CCECBusScan::Process(void) +{ + CCECBusDevice *device(NULL); + while (!IsStopped()) + { + 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(false); + Sleep(5); + + if (!IsStopped()) + device->GetCecVersion(); + Sleep(5); + + if (!IsStopped()) + device->GetVendorId(); + Sleep(5); + } + } + Sleep(1000); + } + return NULL; +}