From: Lars Op den Kamp Date: Thu, 16 Feb 2012 00:58:29 +0000 (+0100) Subject: cec: fix active source switches for the standard CEC implementation. added some log... X-Git-Tag: upstream/2.2.0~1^2~35^2~32 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c4287bcda5182b4fe1f76c1b6492a6ac8902599d;p=deb_libcec.git cec: fix active source switches for the standard CEC implementation. added some log messages. ensure that we don't send data to ourself --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 20b8e05..00d7744 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -853,6 +853,12 @@ bool CCECProcessor::IsActiveSource(cec_logical_address iAddress) bool CCECProcessor::Transmit(const cec_command &data) { + if (m_logicalAddresses[(uint8_t)data.destination]) + { + CLibCEC::AddLog(CEC_LOG_WARNING, "not sending data to myself!"); + return false; + } + cec_adapter_message_state retVal(ADAPTER_MESSAGE_STATE_UNKNOWN); { CLockObject lock(m_mutex); diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index 7037c78..96571cc 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -173,12 +173,12 @@ bool CUSBCECAdapterCommunication::Open(IAdapterCommunicationCallback *cb, uint32 void CUSBCECAdapterCommunication::Close(void) { - SetAckMask(0); { CLockObject lock(m_mutex); m_bHasData = true; m_rcvCondition.Broadcast(); } + SetAckMask(0); StopThread(); } diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 59dcb46..a5d884e 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -534,6 +534,8 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus) switch (newStatus) { case CEC_DEVICE_STATUS_UNKNOWN: + if (m_deviceStatus != newStatus) + CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'unknown'", ToString(m_iLogicalAddress)); m_iStreamPath = 0; m_powerStatus = CEC_POWER_STATUS_UNKNOWN; m_vendor = CEC_VENDOR_UNKNOWN; @@ -544,6 +546,8 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus) m_deviceStatus = newStatus; break; case CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC: + if (m_deviceStatus != newStatus) + CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'handled by libCEC'", ToString(m_iLogicalAddress)); m_iStreamPath = 0; m_powerStatus = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON; m_vendor = CEC_VENDOR_UNKNOWN; @@ -554,7 +558,13 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus) m_deviceStatus = newStatus; break; case CEC_DEVICE_STATUS_PRESENT: + if (m_deviceStatus != newStatus) + CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'present'", ToString(m_iLogicalAddress)); + m_deviceStatus = newStatus; + break; case CEC_DEVICE_STATUS_NOT_PRESENT: + if (m_deviceStatus != newStatus) + CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'not present'", ToString(m_iLogicalAddress)); m_deviceStatus = newStatus; break; } diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 8ec93ee..83d9936 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -983,22 +983,20 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /* bool CCECCommandHandler::ActivateSource(void) { - if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV) - { - CCECBusDevice *primary = m_processor->GetPrimaryDevice(); - primary->SetPowerStatus(CEC_POWER_STATUS_ON); - primary->SetMenuState(CEC_MENU_STATE_ACTIVATED); - - if (m_busDevice->GetStatus(false) == CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC) - { - m_busDevice->TransmitMenuState(CECDEVICE_TV); - - if ((m_busDevice->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || - m_busDevice->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) && - SendDeckStatusUpdateOnActiveSource()) - ((CCECPlaybackDevice *)m_busDevice)->TransmitDeckStatus(CECDEVICE_TV); - m_bHandlerInited = true; - } + if (m_busDevice->IsActiveSource() && + m_busDevice->GetStatus(false) == CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC) + { + m_busDevice->SetPowerStatus(CEC_POWER_STATUS_ON); + m_busDevice->SetMenuState(CEC_MENU_STATE_ACTIVATED); + + m_busDevice->TransmitImageViewOn(); + m_busDevice->TransmitActiveSource(); + m_busDevice->TransmitMenuState(CECDEVICE_TV); + if ((m_busDevice->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || + m_busDevice->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) && + SendDeckStatusUpdateOnActiveSource()) + ((CCECPlaybackDevice *)m_busDevice)->TransmitDeckStatus(CECDEVICE_TV); + m_bHandlerInited = true; } return true; }