cec: always wait for thread exit in CThread's desctructor
[deb_libcec.git] / src / lib / CECProcessor.cpp
index dee5f5949af2321acdfbb62a0682599014305d67..83e9ee8c40451211dc0a79f75cdfb403142a6284 100644 (file)
@@ -150,6 +150,7 @@ void CCECProcessor::Close(void)
 
   if (bClose && m_communication)
   {
+    m_communication->PersistConfiguration(&m_configuration);
     m_communication->Close();
     delete m_communication;
     m_communication = NULL;
@@ -193,6 +194,9 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint
   if (bReturn)
     CLibCEC::AddLog(CEC_LOG_NOTICE, "connected to the CEC adapter. firmware version = %d, client version = %s", m_communication->GetFirmwareVersion(), ToString((cec_client_version)m_configuration.clientVersion));
 
+  if (m_configuration.bGetSettingsFromROM == 1)
+    m_communication->GetConfiguration(&m_configuration);
+
   return bReturn;
 }
 
@@ -888,7 +892,7 @@ bool CCECProcessor::Transmit(const cec_command &data)
     iMaxTries = m_busDevices[data.initiator]->GetHandler()->GetTransmitRetries() + 1;
   }
 
-  return m_communication->Write(data, iMaxTries, m_iLineTimeout, m_iRetryLineTimeout)
+  return m_communication->Write(data, iMaxTries, m_iStandardLineTimeout, m_iRetryLineTimeout)
       == ADAPTER_MESSAGE_STATE_SENT_ACKED;
 }
 
@@ -908,7 +912,9 @@ void CCECProcessor::TransmitAbort(cec_logical_address address, cec_opcode opcode
 void CCECProcessor::ParseCommand(const cec_command &command)
 {
   CStdString dataStr;
-  dataStr.Format(">> %1x%1x:%02x", command.initiator, command.destination, command.opcode);
+  dataStr.Format(">> %1x%1x", command.initiator, command.destination);
+  if (command.opcode_set == 1)
+    dataStr.AppendFormat(":%02x", command.opcode);
   for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++)
     dataStr.AppendFormat(":%02x", (unsigned int)command.parameters[iPtr]);
   CLibCEC::AddLog(CEC_LOG_TRAFFIC, dataStr.c_str());
@@ -1475,7 +1481,7 @@ bool CCECProcessor::PingAdapter(void)
 
 void CCECProcessor::HandlePoll(cec_logical_address initiator, cec_logical_address destination)
 {
-  m_busDevices[initiator]->HandlePoll(destination);
+  m_busDevices[destination]->HandlePoll(initiator);
 }
 
 bool CCECProcessor::HandleReceiveFailed(cec_logical_address initiator)