added changelog for v1.5.1
[deb_libcec.git] / src / lib / CECProcessor.cpp
index a4bbcbc8e0b7ed0d6acb30f0190ed6f21b67a5dd..96e82ce626ff4f23f3e3287b0ead0cd26f2797df 100644 (file)
@@ -60,7 +60,7 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, libcec_configuration *configur
   m_logicalAddresses.Clear();
   CreateBusDevices();
   m_configuration.Clear();
-  m_configuration.serverVersion = CEC_SERVER_VERSION_1_5_0;
+  m_configuration.serverVersion = configuration->serverVersion;
   SetConfiguration(configuration);
 
   if (m_configuration.tvVendor != CEC_VENDOR_UNKNOWN)
@@ -78,7 +78,7 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, con
     m_iLastTransmission(0)
 {
   m_configuration.Clear();
-  m_configuration.serverVersion = CEC_SERVER_VERSION_1_5_0;
+  m_configuration.serverVersion    = CEC_SERVER_VERSION_1_5_1;
 
   // client version < 1.5.0
   m_configuration.clientVersion    = (uint32_t)CEC_CLIENT_VERSION_PRE_1_5;
@@ -188,7 +188,8 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint
   while (timeout.TimeLeft() > 0 && (bReturn = m_communication->Open(this, (timeout.TimeLeft() / CEC_CONNECT_TRIES))) == false)
   {
     CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry);
-    Sleep(500);
+    m_communication->Close();
+    CEvent::Sleep(1000);
   }
 
   if (bReturn)
@@ -1371,6 +1372,8 @@ const char *CCECProcessor::ToString(const cec_client_version version)
     return "pre-1.5";
   case CEC_CLIENT_VERSION_1_5_0:
     return "1.5.0";
+  case CEC_CLIENT_VERSION_1_5_1:
+    return "1.5.1";
   default:
     return "Unknown";
   }
@@ -1384,6 +1387,8 @@ const char *CCECProcessor::ToString(const cec_server_version version)
     return "pre-1.5";
   case CEC_SERVER_VERSION_1_5_0:
     return "1.5.0";
+  case CEC_SERVER_VERSION_1_5_1:
+      return "1.5.1";
   default:
     return "Unknown";
   }
@@ -1434,9 +1439,31 @@ void CCECBusScan::WaitUntilIdle(void)
   }
 }
 
-bool CCECProcessor::StartBootloader(void)
+bool CCECProcessor::StartBootloader(const char *strPort /* = NULL */)
 {
-  return m_communication->StartBootloader();
+  if (!m_communication && strPort)
+  {
+    bool bReturn(false);
+    IAdapterCommunication *comm = new CUSBCECAdapterCommunication(this, strPort);
+    CTimeout timeout(10000);
+    int iConnectTry(0);
+    while (timeout.TimeLeft() > 0 && (bReturn = comm->Open(NULL, (timeout.TimeLeft() / CEC_CONNECT_TRIES)), true) == false)
+    {
+      CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry);
+      comm->Close();
+      Sleep(500);
+    }
+    if (comm->IsOpen())
+    {
+      bReturn = comm->StartBootloader();
+      delete comm;
+    }
+    return bReturn;
+  }
+  else
+  {
+    return m_communication->StartBootloader();
+  }
 }
 
 bool CCECProcessor::PingAdapter(void)
@@ -1559,6 +1586,10 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
   m_configuration.bPowerOffScreensaver = configuration->bPowerOffScreensaver;
   m_configuration.bPowerOffOnStandby   = configuration->bPowerOffOnStandby;
 
+  // client version 1.5.1
+  if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_1)
+    m_configuration.bSendInactiveSource = configuration->bSendInactiveSource;
+
   // ensure that there is at least 1 device type set
   if (m_configuration.deviceTypes.IsEmpty())
     m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
@@ -1572,6 +1603,11 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
     else
       return SetHDMIPort(m_configuration.baseDevice, m_configuration.iHDMIPort);
   }
+  else if (m_configuration.bActivateSource == 1 && IsRunning() && !IsActiveSource(m_logicalAddresses.primary))
+  {
+    // activate the source if we're not already the active source
+    SetActiveSource(m_configuration.deviceTypes.types[0]);
+  }
 
   return true;
 }
@@ -1597,6 +1633,10 @@ bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration)
   configuration->bPowerOffScreensaver = m_configuration.bPowerOffScreensaver;
   configuration->bPowerOffOnStandby   = m_configuration.bPowerOffOnStandby;
 
+  // client version 1.5.1
+  if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_1)
+    configuration->bSendInactiveSource = m_configuration.bSendInactiveSource;
+
   return true;
 }