X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FCECProcessor.cpp;h=96e82ce626ff4f23f3e3287b0ead0cd26f2797df;hb=be54289b785d3318dd644223cacb9f281f3e2d3d;hp=2391ca7e411d9b8d32c7fc060e7adef96f1003fa;hpb=30a09f32c9fb0c3d56e3a4e8da58a04fd4c3756f;p=deb_libcec.git diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 2391ca7..96e82ce 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -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; @@ -181,16 +181,15 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint return bReturn; } - uint64_t iNow = GetTimeMs(); - uint64_t iTarget = iTimeoutMs > 0 ? iNow + iTimeoutMs : iNow + CEC_DEFAULT_TRANSMIT_WAIT; + CTimeout timeout(iTimeoutMs > 0 ? iTimeoutMs : CEC_DEFAULT_TRANSMIT_WAIT); /* open a new connection */ unsigned iConnectTry(0); - while (iNow < iTarget && (bReturn = m_communication->Open(this, iTimeoutMs)) == false) + 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); - iNow = GetTimeMs(); + m_communication->Close(); + CEvent::Sleep(1000); } if (bReturn) @@ -1373,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"; } @@ -1386,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"; } @@ -1436,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) @@ -1561,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); @@ -1574,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; } @@ -1599,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; }