From: Lars Op den Kamp Date: Sun, 4 Dec 2011 20:26:06 +0000 (+0100) Subject: cec: force update the device status in the background scan thread. only scan once... X-Git-Tag: upstream/2.2.0~1^2~44^2~41 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;ds=sidebyside;h=ef79edcce663c6156731ad73d63acbe0c6be85b9;p=deb_libcec.git cec: force update the device status in the background scan thread. only scan once per minute --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 8e761b1..11065eb 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -1270,19 +1270,26 @@ const char *CCECProcessor::ToString(const cec_vendor_id vendor) void *CCECBusScan::Process(void) { CCECBusDevice *device(NULL); + int iCount(0); while (!IsStopped()) { - for (unsigned int iPtr = 0; iPtr < 15 && !IsStopped(); iPtr++) + if (iCount == 0) { - device = m_processor->m_busDevices[iPtr]; - if (device && device->GetStatus() == CEC_DEVICE_STATUS_PRESENT) + for (unsigned int iPtr = 0; iPtr < 15 && !IsStopped(); iPtr++) { - if (!IsStopped()) - device->GetVendorId(); - Sleep(5); + device = m_processor->m_busDevices[iPtr]; + if (device && device->GetStatus(true) == CEC_DEVICE_STATUS_PRESENT) + { + if (!IsStopped()) + device->GetVendorId(); + Sleep(5); + } } } - Sleep(5000); + + if (++iCount > 60) + iCount = 0; + Sleep(1000); } return NULL; }