m_bInitialised(false),
m_bRegistered(false),
m_iCurrentButton(CEC_USER_CONTROL_CODE_UNKNOWN),
- m_buttontime(0)
+ m_buttontime(0),
+ m_iPreventForwardingPowerOffCommand(0)
{
// set the initial configuration
SetConfiguration(configuration);
void CCECClient::AddCommand(const cec_command &command)
{
- CLockObject lock(m_mutex);
+ // don't forward the standby opcode more than once every 10 seconds
+ if (command.opcode == CEC_OPCODE_STANDBY)
+ {
+ CLockObject lock(m_mutex);
+ if (m_iPreventForwardingPowerOffCommand != 0 &&
+ m_iPreventForwardingPowerOffCommand > GetTimeMs())
+ return;
+ else
+ m_iPreventForwardingPowerOffCommand = GetTimeMs() + CEC_FORWARD_STANDBY_MIN_INTERVAL;
+ }
+
+ if (command.destination == CECDEVICE_BROADCAST || GetLogicalAddresses().IsSet(command.destination))
+ {
+ CLockObject lock(m_mutex);
- LIB_CEC->AddLog(CEC_LOG_NOTICE, ">> %s (%X) -> %s (%X): %s (%2X)", ToString(command.initiator), command.initiator, ToString(command.destination), command.destination, ToString(command.opcode), command.opcode);
+ LIB_CEC->AddLog(CEC_LOG_NOTICE, ">> %s (%X) -> %s (%X): %s (%2X)", ToString(command.initiator), command.initiator, ToString(command.destination), command.destination, ToString(command.opcode), command.opcode);
- if (m_configuration.callbacks && m_configuration.callbacks->CBCecCommand)
- m_configuration.callbacks->CBCecCommand(m_configuration.callbackParam, command);
- else if (!m_commandBuffer.Push(command))
- LIB_CEC->AddLog(CEC_LOG_WARNING, "command buffer is full");
+ if (m_configuration.callbacks && m_configuration.callbacks->CBCecCommand)
+ m_configuration.callbacks->CBCecCommand(m_configuration.callbackParam, command);
+ else if (!m_commandBuffer.Push(command))
+ LIB_CEC->AddLog(CEC_LOG_WARNING, "command buffer is full");
+ }
}
int CCECClient::MenuStateChanged(const cec_menu_state newState)
return 0;
}
+void CCECClient::SourceActivated(const cec_logical_address logicalAddress)
+{
+ CLockObject lock(m_mutex);
+
+ LIB_CEC->AddLog(CEC_LOG_NOTICE, ">> source activated: %s (%x)", ToString(logicalAddress), logicalAddress);
+
+ if (m_configuration.callbacks &&
+ m_configuration.clientVersion >= CEC_CLIENT_VERSION_1_7_1 &&
+ m_configuration.callbacks->CBCecSourceActivated)
+ m_configuration.callbacks->CBCecSourceActivated(m_configuration.callbackParam, logicalAddress, 1);
+}
+
+void CCECClient::SourceDeactivated(const cec_logical_address logicalAddress)
+{
+ CLockObject lock(m_mutex);
+
+ LIB_CEC->AddLog(CEC_LOG_NOTICE, ">> source deactivated: %s (%x)", ToString(logicalAddress), logicalAddress);
+
+ if (m_configuration.callbacks &&
+ m_configuration.clientVersion >= CEC_CLIENT_VERSION_1_7_1 &&
+ m_configuration.callbacks->CBCecSourceActivated)
+ m_configuration.callbacks->CBCecSourceActivated(m_configuration.callbackParam, logicalAddress, 0);
+}
+
void CCECClient::Alert(const libcec_alert type, const libcec_parameter ¶m)
{
CLockObject lock(m_mutex);
{
if (!CLibCEC::IsValidPhysicalAddress(iPhysicalAddress))
{
- LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - not setting invalid physical address %04x", iPhysicalAddress);
+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - not setting invalid physical address %04x", __FUNCTION__, iPhysicalAddress);
return false;
}