From ef79edcce663c6156731ad73d63acbe0c6be85b9 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sun, 4 Dec 2011 21:26:06 +0100 Subject: [PATCH] cec: force update the device status in the background scan thread. only scan once per minute --- src/lib/CECProcessor.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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; } -- 2.34.1