X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fadapter%2FRPi%2FRPiCECAdapterCommunication.cpp;h=2905c56bb0d06b5e7fbb942903f52da4fa8d4d27;hb=38b8eaae3ef151943595c4033b628a7c98d90c64;hp=f15b1c0baad3b1dd9f8404182f229992c064d122;hpb=49ba42d414995d3b3f746d19cbb84ca18fc42897;p=deb_libcec.git diff --git a/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp b/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp index f15b1c0..2905c56 100644 --- a/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp +++ b/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp @@ -1,7 +1,7 @@ /* * This file is part of the libCEC(R) library. * - * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved. + * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved. * libCEC(R) is an original work, containing original code. * * libCEC(R) is a trademark of Pulse-Eight Limited. @@ -118,17 +118,13 @@ void CRPiCECAdapterCommunication::OnTVServiceCallback(uint32_t reason, uint32_t { switch(reason) { - case VC_HDMI_UNPLUGGED: - { - m_callback->HandlePhysicalAddressChanged(0x1000); - break; - } case VC_HDMI_ATTACHED: { uint16_t iNewAddress = GetPhysicalAddress(); m_callback->HandlePhysicalAddressChanged(iNewAddress); break; } + case VC_HDMI_UNPLUGGED: case VC_HDMI_DVI: case VC_HDMI_HDMI: case VC_HDMI_HDCP_UNAUTH: @@ -293,7 +289,7 @@ int CRPiCECAdapterCommunication::InitHostCEC(void) return VCHIQ_SUCCESS; } -bool CRPiCECAdapterCommunication::Open(uint32_t UNUSED(iTimeoutMs) /* = CEC_DEFAULT_CONNECT_TIMEOUT */, bool UNUSED(bSkipChecks) /* = false */, bool bStartListening) +bool CRPiCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */, bool UNUSED(bSkipChecks) /* = false */, bool bStartListening) { Close(); @@ -309,6 +305,14 @@ bool CRPiCECAdapterCommunication::Open(uint32_t UNUSED(iTimeoutMs) /* = CEC_DEFA vc_cec_register_callback(rpi_cec_callback, (void*)this); vc_tv_register_callback(rpi_tv_callback, (void*)this); + // release previous LA + vc_cec_release_logical_address(); + if (!m_logicalAddressCondition.Wait(m_mutex, m_bLogicalAddressChanged, iTimeoutMs)) + { + LIB_CEC->AddLog(CEC_LOG_ERROR, "failed to release the previous LA"); + return false; + } + // register LA "freeuse" if (RegisterLogicalAddress(CECDEVICE_FREEUSE)) { @@ -378,13 +382,18 @@ cec_adapter_message_state CRPiCECAdapterCommunication::Write(const cec_command & return (data.initiator == data.destination) ? ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED : ADAPTER_MESSAGE_STATE_ERROR; } - if (!data.opcode_set && data.initiator == data.destination) + if (!m_queue->Write(data, bIsReply)) { - // registration of the logical address would have failed - return ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED; + if (!data.opcode_set) + { + return ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED; + } + + return ADAPTER_MESSAGE_STATE_SENT; } - return m_queue->Write(data, bIsReply) ? ADAPTER_MESSAGE_STATE_SENT_ACKED : ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED; + return ADAPTER_MESSAGE_STATE_SENT_ACKED; + } uint16_t CRPiCECAdapterCommunication::GetFirmwareVersion(void)