bool CCECProcessor::Transmit(const cec_command &data)
{
+ bool bReturn(false);
LogOutput(data);
- CCECAdapterMessagePtr output(new CCECAdapterMessage(data));
- return Transmit(output);
+ CCECAdapterMessage *output = new CCECAdapterMessage(data);
+ bReturn = Transmit(output);
+ delete output;
+
+ return bReturn;
}
-bool CCECProcessor::Transmit(CCECAdapterMessagePtr output)
+bool CCECProcessor::Transmit(CCECAdapterMessage *output)
{
bool bReturn(false);
CLockObject lock(&m_mutex);
return bReturn;
else
{
- output->condition.Wait(&output->mutex, 1000);
+ output->condition.Wait(&output->mutex);
if (output->state != ADAPTER_MESSAGE_STATE_SENT)
{
m_controller->AddLog(CEC_LOG_ERROR, "command was not sent");
continue;
}
- bError = msg.is_error();
- m_controller->AddLog(msg.is_error() ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString());
-
- switch(msg.message())
+ if ((bError = msg.is_error()) == false)
{
- case MSGCODE_COMMAND_ACCEPTED:
- if (iPacketsLeft > 0)
- iPacketsLeft--;
- break;
- case MSGCODE_TRANSMIT_SUCCEEDED:
- bTransmitSucceeded = (iPacketsLeft == 0);
- bError = !bTransmitSucceeded;
- break;
- default:
- CStdString strLog;
- strLog.Format("received unexpected reply '%s' instead of ack", msg.MessageCodeAsString().c_str());
- m_controller->AddLog(CEC_LOG_WARNING, strLog);
- ParseMessage(msg);
- bError = true;
- break;
- }
+ m_controller->AddLog(bError ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString());
- iNow = GetTimeMs();
+ switch(msg.message())
+ {
+ case MSGCODE_COMMAND_ACCEPTED:
+ if (iPacketsLeft > 0)
+ iPacketsLeft--;
+ break;
+ case MSGCODE_TRANSMIT_SUCCEEDED:
+ bTransmitSucceeded = (iPacketsLeft == 0);
+ bError = !bTransmitSucceeded;
+ break;
+ default:
+ ParseMessage(msg);
+ }
+
+ iNow = GetTimeMs();
+ }
}
return bTransmitSucceeded && !bError;
void CCECProcessor::AddCommand(const cec_command &command)
{
-// m_controller->AddCommand(command);
+ m_controller->AddCommand(command);
+}
+
+void CCECProcessor::AddKey(cec_keypress &key)
+{
+ m_controller->AddKey(key);
}
void CCECProcessor::AddKey(void)
bool CCECProcessor::SetAckMask(uint16_t iMask)
{
+ bool bReturn(false);
CStdString strLog;
strLog.Format("setting ackmask to %2x", iMask);
m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
- CCECAdapterMessagePtr output(new CCECAdapterMessage);
+ CCECAdapterMessage *output = new CCECAdapterMessage;
output->push_back(MSGSTART);
output->push_escaped(MSGCODE_SET_ACK_MASK);
output->push_escaped((uint8_t)iMask);
output->push_back(MSGEND);
- if (!Transmit(output))
- {
+ if ((bReturn = Transmit(output)) == false)
m_controller->AddLog(CEC_LOG_ERROR, "could not set the ackmask");
- return false;
- }
- return true;
+ delete output;
+
+ return bReturn;
}