From: Lars Op den Kamp Date: Mon, 25 Jun 2012 09:50:42 +0000 (+0200) Subject: cec: fixed - commands that were forwarded to clients used the source address of the... X-Git-Tag: upstream/2.2.0~1^2~22^2^2~12 X-Git-Url: https://git.piment-noir.org/?p=deb_libcec.git;a=commitdiff_plain;h=5d19989ff572f154b7c42f2151390b02dc106983 cec: fixed - commands that were forwarded to clients used the source address of the message instead of destination address when searching for clients. changed so all directly addressed and broadcast command are forwarded to the correct client --- diff --git a/src/lib/CECClient.cpp b/src/lib/CECClient.cpp index accd565..35dd415 100644 --- a/src/lib/CECClient.cpp +++ b/src/lib/CECClient.cpp @@ -882,14 +882,17 @@ bool CCECClient::SetConfiguration(const libcec_configuration &configuration) void CCECClient::AddCommand(const cec_command &command) { - CLockObject lock(m_mutex); + 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) diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index 8838ff4..d41df71 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -475,6 +475,13 @@ void CLibCEC::AddLog(const cec_log_level level, const char *strFormat, ...) (*it)->AddLog(message); } +void CLibCEC::AddCommand(const cec_command &command) +{ + // send the command to all clients + for (vector::iterator it = m_clients.begin(); it != m_clients.end(); it++) + (*it)->AddCommand(command); +} + void CLibCEC::Alert(const libcec_alert type, const libcec_parameter ¶m) { // send the alert to all clients @@ -599,7 +606,6 @@ bool CLibCEC::GetDeviceInformation(const char *strPort, libcec_configuration *co // no longer being used void CLibCEC::AddKey(const cec_keypress &UNUSED(key)) {} -void CLibCEC::AddCommand(const cec_command &UNUSED(command)) {} void CLibCEC::ConfigurationChanged(const libcec_configuration &UNUSED(config)) {} void CLibCEC::SetCurrentButton(cec_user_control_code UNUSED(iButtonCode)) {} CLibCEC *CLibCEC::GetInstance(void) { return NULL; } diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index 0ef3e83..6407e57 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -134,7 +134,7 @@ namespace CEC void AddLog(const cec_log_level level, const char *strFormat, ...); static void AddKey(void) {} //UNUSED static void AddKey(const cec_keypress &key); //UNUSED - static void AddCommand(const cec_command &command); //UNUSED + void AddCommand(const cec_command &command); static void ConfigurationChanged(const libcec_configuration &config); //UNUSED static void SetCurrentButton(cec_user_control_code iButtonCode); //UNUSED void CheckKeypressTimeout(void); diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index e06eb2b..03165e9 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -73,9 +73,7 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command) int iHandled(CEC_ABORT_REASON_UNRECOGNIZED_OPCODE); - CCECClient *client = m_busDevice->GetClient(); - if (client) - client->AddCommand(command); + LIB_CEC->AddCommand(command); switch(command.opcode) {