X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FCECProcessor.cpp;h=0012a53d289f52591cb398f4c1bf1d152a68a120;hb=34fe491f051387fa870da9459ce53892f7bb03ab;hp=016d88c8e517933129ad120fe19c8661a28c83f7;hpb=c9d154855efd508e1a4225841616504087f88e6e;p=deb_libcec.git diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 016d88c..0012a53 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -42,6 +42,7 @@ #include "implementations/CECCommandHandler.h" #include "LibCEC.h" #include "CECClient.h" +#include "CECTypeUtils.h" #include "platform/util/timeutils.h" #include "platform/util/util.h" @@ -50,8 +51,9 @@ using namespace std; using namespace PLATFORM; #define CEC_PROCESSOR_SIGNAL_WAIT_TIME 1000 +#define ACTIVE_SOURCE_CHECK_TIMEOUT 10000 -#define ToString(x) m_libcec->ToString(x) +#define ToString(x) CCECTypeUtils::ToString(x) CCECProcessor::CCECProcessor(CLibCEC *libcec) : m_bInitialised(false), @@ -146,9 +148,6 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint m_libcec->AddLog(CEC_LOG_NOTICE, "connection opened"); - // always start by setting the ackmask to 0, to clear previous values - SetAckMask(0); - // mark as initialised SetCECInitialised(true); @@ -199,6 +198,19 @@ void CCECProcessor::ReplaceHandlers(void) it->second->ReplaceHandler(true); } +void CCECProcessor::CheckPendingActiveSource(void) +{ + if (!CECInitialised()) + return; + + // check each device + for (CECDEVICEMAP::iterator it = m_busDevices->Begin(); it != m_busDevices->End(); it++) + { + if (it->second->GetHandler()->ActiveSourcePending()) + it->second->ActivateSource(); + } +} + bool CCECProcessor::OnCommandReceived(const cec_command &command) { return m_inBuffer.Push(command); @@ -209,6 +221,7 @@ void *CCECProcessor::Process(void) m_libcec->AddLog(CEC_LOG_DEBUG, "processor thread started"); cec_command command; + CTimeout activeSourceCheck(ACTIVE_SOURCE_CHECK_TIMEOUT); // as long as we're not being stopped and the connection is open while (!IsStopped() && m_communication->IsOpen()) @@ -224,6 +237,13 @@ void *CCECProcessor::Process(void) // check if we need to replace handlers ReplaceHandlers(); + + // check whether we need to activate a source, if it failed before + if (activeSourceCheck.TimeLeft() == 0) + { + CheckPendingActiveSource(); + activeSourceCheck.Init(ACTIVE_SOURCE_CHECK_TIMEOUT); + } } }