CLockObject lock(m_mutex);
m_iLastActive = GetTimeMs();
+ /* don't call GetStatus() here, just read the value with the mutex locked */
if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
cec_bus_device_status CCECBusDevice::GetStatus(bool bForcePoll /* = false */)
{
- CLockObject lock(m_mutex);
- if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC &&
- (m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN || bForcePoll))
+ cec_bus_device_status status(CEC_DEVICE_STATUS_UNKNOWN);
+ bool bNeedsPoll(false);
+
+ {
+ CLockObject lock(m_mutex);
+ status = m_deviceStatus;
+ bNeedsPoll = (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC &&
+ (m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN || bForcePoll));
+ }
+
+ if (bNeedsPoll)
{
- lock.Unlock();
bool bPollAcked(false);
- if (bForcePoll || NeedsPoll())
+ if (bNeedsPoll || NeedsPoll())
bPollAcked = m_processor->PollDevice(m_iLogicalAddress);
- lock.Lock();
- m_deviceStatus = bPollAcked ? CEC_DEVICE_STATUS_PRESENT : CEC_DEVICE_STATUS_NOT_PRESENT;
+ status = bPollAcked ? CEC_DEVICE_STATUS_PRESENT : CEC_DEVICE_STATUS_NOT_PRESENT;
+ SetDeviceStatus(status);
}
- return m_deviceStatus;
+ return status;
}
//@}