From: Lars Op den Kamp Date: Mon, 15 Oct 2012 10:13:09 +0000 (+0200) Subject: fixed - updating the device status after a poll was broken and could reset the status... X-Git-Tag: upstream/2.2.0~1^2~14^2^2~7 X-Git-Url: https://git.piment-noir.org/?p=deb_libcec.git;a=commitdiff_plain;h=be3b6983b9b51528b3d2f379fccf7a0bfcca1f5d fixed - updating the device status after a poll was broken and could reset the status of devices that were marked as handled by libCEC to 'not present' --- diff --git a/src/lib/CECClient.cpp b/src/lib/CECClient.cpp index f85a53c..a5a960e 100644 --- a/src/lib/CECClient.cpp +++ b/src/lib/CECClient.cpp @@ -1255,7 +1255,7 @@ bool CCECClient::PollDevice(const cec_logical_address iAddress) CCECBusDevice *primary = GetPrimaryDevice(); // poll the destination, with the primary as source if (primary) - return primary->TransmitPoll(iAddress, false); + return primary->TransmitPoll(iAddress, true); return m_processor ? m_processor->PollDevice(iAddress) : false; } diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index cc6adda..73c921d 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -315,11 +315,11 @@ bool CCECProcessor::PollDevice(cec_logical_address iAddress) CCECBusDevice *primary = GetPrimaryDevice(); // poll the destination, with the primary as source if (primary) - return primary->TransmitPoll(iAddress, false); + return primary->TransmitPoll(iAddress, true); CCECBusDevice *device = m_busDevices->At(CECDEVICE_UNREGISTERED); if (device) - return device->TransmitPoll(iAddress, false); + return device->TransmitPoll(iAddress, true); return false; } diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index b42230d..a33a9c3 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -741,7 +741,8 @@ cec_bus_device_status CCECBusDevice::GetStatus(bool bForcePoll /* = false */, bo CLockObject lock(m_mutex); status = m_deviceStatus; bNeedsPoll = !bSuppressPoll && - (bForcePoll || m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN); + (bForcePoll || m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN) && + m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC; } if (bNeedsPoll) @@ -782,6 +783,7 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus, cec_v if (m_deviceStatus != newStatus) LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): device status changed into 'present'", GetLogicalAddressName(), m_iLogicalAddress); m_deviceStatus = newStatus; + m_iLastActive = GetTimeMs(); break; case CEC_DEVICE_STATUS_NOT_PRESENT: if (m_deviceStatus != newStatus) @@ -819,7 +821,7 @@ void CCECBusDevice::ResetDeviceStatus(void) m_deviceStatus = CEC_DEVICE_STATUS_UNKNOWN; } -bool CCECBusDevice::TransmitPoll(const cec_logical_address dest, bool bIsReply) +bool CCECBusDevice::TransmitPoll(const cec_logical_address dest, bool bUpdateDeviceStatus) { bool bReturn(false); cec_logical_address destination(dest); @@ -832,17 +834,11 @@ bool CCECBusDevice::TransmitPoll(const cec_logical_address dest, bool bIsReply) MarkBusy(); LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< %s (%X) -> %s (%X): POLL", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest); - bReturn = m_handler->TransmitPoll(m_iLogicalAddress, destination, bIsReply); + bReturn = m_handler->TransmitPoll(m_iLogicalAddress, destination, false); LIB_CEC->AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent"); - CLockObject lock(m_mutex); - if (bReturn) - { - m_iLastActive = GetTimeMs(); - SetDeviceStatus(CEC_DEVICE_STATUS_PRESENT); - } - else - SetDeviceStatus(CEC_DEVICE_STATUS_NOT_PRESENT); + if (bUpdateDeviceStatus) + destDevice->SetDeviceStatus(bReturn ? CEC_DEVICE_STATUS_PRESENT : CEC_DEVICE_STATUS_NOT_PRESENT); MarkReady(); return bReturn; diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index d208fd9..fad7191 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -206,7 +206,7 @@ namespace CEC virtual cec_bus_device_status GetStatus(bool bForcePoll = false, bool bSuppressPoll = false); virtual void SetDeviceStatus(const cec_bus_device_status newStatus, cec_version libCECSpecVersion = CEC_VERSION_1_4); virtual void ResetDeviceStatus(void); - virtual bool TransmitPoll(const cec_logical_address destination, bool bIsReply); + virtual bool TransmitPoll(const cec_logical_address destination, bool bUpdateDeviceStatus); virtual void HandlePoll(const cec_logical_address destination); virtual void HandlePollFrom(const cec_logical_address initiator); virtual bool HandleReceiveFailed(void);