X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FCECProcessor.cpp;h=095fb63335fed7322d71506df85d607abe9f1caf;hb=5347b94bbd7455453754fd79b6aaa64aa368ce59;hp=5000e047b81d824f2ad39302fbbf529ee85dd3f1;hpb=e69d8f191784c77c156ffec90db50767f91421e3;p=deb_libcec.git diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 5000e04..095fb63 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -132,7 +132,10 @@ CCECProcessor::~CCECProcessor(void) Close(); for (unsigned int iPtr = 0; iPtr < 16; iPtr++) + { delete m_busDevices[iPtr]; + m_busDevices[iPtr] = NULL; + } } void CCECProcessor::Close(void) @@ -157,7 +160,7 @@ void CCECProcessor::Close(void) } } -bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint32_t iTimeoutMs) +bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint32_t iTimeoutMs, bool bStartListening /* = true */) { bool bReturn(false); Close(); @@ -184,7 +187,7 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint /* open a new connection */ unsigned iConnectTry(0); - while (timeout.TimeLeft() > 0 && (bReturn = m_communication->Open(this, (timeout.TimeLeft() / CEC_CONNECT_TRIES))) == false) + while (timeout.TimeLeft() > 0 && (bReturn = m_communication->Open(this, (timeout.TimeLeft() / CEC_CONNECT_TRIES), false, bStartListening)) == false) { CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry); m_communication->Close(); @@ -453,23 +456,27 @@ void CCECProcessor::ReplaceHandlers(void) bool CCECProcessor::OnCommandReceived(const cec_command &command) { - ParseCommand(command); - return true; + return m_inBuffer.Push(command); } void *CCECProcessor::Process(void) { CLibCEC::AddLog(CEC_LOG_DEBUG, "processor thread started"); + cec_command command; + command.Clear(); + while (!IsStopped() && m_communication->IsOpen()) { + if (m_inBuffer.Pop(command, 500)) + ParseCommand(command); + if (IsInitialised()) { ReplaceHandlers(); m_controller->CheckKeypressTimeout(); } - Sleep(5); } return NULL; @@ -571,6 +578,12 @@ bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort, { bool bReturn(false); + // limit the HDMI port range to 1-15 + if (iPort < 1) + iPort = 1; + if (iPort > 15) + iPort = 15; + { CLockObject lock(m_mutex); m_configuration.baseDevice = iBaseDevice; @@ -1599,6 +1612,7 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration) // just copy these m_configuration.clientVersion = configuration->clientVersion; + m_configuration.bUseTVMenuLanguage = configuration->bUseTVMenuLanguage; m_configuration.bActivateSource = configuration->bActivateSource; m_configuration.bGetSettingsFromROM = configuration->bGetSettingsFromROM; m_configuration.powerOffDevices = configuration->powerOffDevices; @@ -1682,3 +1696,16 @@ void CCECProcessor::RescanActiveDevices(void) for (unsigned int iPtr = 0; iPtr < 16; iPtr++) m_busDevices[iPtr]->GetStatus(true); } + +bool CCECProcessor::GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs /* = 10000 */) +{ + if (!OpenConnection(strPort, 38400, iTimeoutMs, false)) + return false; + + config->iFirmwareVersion = m_communication->GetFirmwareVersion(); + config->iPhysicalAddress = m_communication->GetPhysicalAddress(); + + delete m_communication; + m_communication = NULL; + return true; +}