From: Lars Op den Kamp Date: Wed, 25 Jul 2012 09:45:15 +0000 (+0200) Subject: p8: fixed - always set controlled mode to false when unregistering the last client... X-Git-Tag: upstream/2.2.0~1^2~20^2^2~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a38292a3c2ec93a21d74da778516276e92d431c0;p=deb_libcec.git p8: fixed - always set controlled mode to false when unregistering the last client. fixes 30 second timeout before controlled mode gets deactivated --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 71e5c69..76c2465 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -660,6 +660,9 @@ bool CCECProcessor::RegisterClient(CCECClient *client) if (client->IsRegistered()) UnregisterClient(client); + // ensure that controlled mode is enabled + m_communication->SetControlledMode(true); + // ensure that we know the vendor id of the TV CCECBusDevice *tv = GetTV(); if (m_communication->SupportsSourceLogicalAddress(CECDEVICE_UNREGISTERED)) @@ -784,7 +787,17 @@ bool CCECProcessor::UnregisterClient(CCECClient *client) } // set the new ackmask - return SetLogicalAddresses(GetLogicalAddresses());; + cec_logical_addresses addresses = GetLogicalAddresses(); + if (SetLogicalAddresses(addresses)) + { + // no more clients left, disable controlled mode + if (addresses.IsEmpty()) + m_communication->SetControlledMode(false); + + return true; + } + + return false; } void CCECProcessor::UnregisterClients(void) diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp index af4d6a0..457889c 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp @@ -53,7 +53,8 @@ CUSBCECAdapterCommands::CUSBCECAdapterCommands(CUSBCECAdapterCommunication *comm m_settingCecVersion(CEC_VERSION_UNKNOWN), m_iSettingLAMask(0), m_bNeedsWrite(false), - m_iBuildDate(CEC_FW_BUILD_UNKNOWN) + m_iBuildDate(CEC_FW_BUILD_UNKNOWN), + m_bControlledMode(false) { m_persistedConfiguration.Clear(); } @@ -575,6 +576,12 @@ bool CUSBCECAdapterCommands::SetLineTimeout(uint8_t iTimeout) bool CUSBCECAdapterCommands::SetControlledMode(bool controlled) { + { + CLockObject lock(m_mutex); + if (m_bControlledMode == controlled) + return true; + } + LIB_CEC->AddLog(CEC_LOG_DEBUG, "turning controlled mode %s", controlled ? "on" : "off"); CCECAdapterMessage params; @@ -582,5 +589,12 @@ bool CUSBCECAdapterCommands::SetControlledMode(bool controlled) CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_CONTROLLED, params); bool bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED; delete message; + + if (bReturn) + { + CLockObject lock(m_mutex); + m_bControlledMode = controlled; + } + return bReturn; } diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.h b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.h index df376f3..897ed1c 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.h +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.h @@ -232,6 +232,7 @@ namespace CEC bool m_bNeedsWrite; /**< true when we sent changed settings to the adapter that have not been persisted */ libcec_configuration m_persistedConfiguration; /**< the configuration that is persisted in the eeprom */ uint32_t m_iBuildDate; /**< the build date of the firmware */ + bool m_bControlledMode; /**< current value of the controlled mode feature */ PLATFORM::CMutex m_mutex; }; }