repositories
/
deb_libcec.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bump version numbers to 1.7.0 and updated changelog
[deb_libcec.git]
/
src
/
lib
/
CECProcessor.cpp
diff --git
a/src/lib/CECProcessor.cpp
b/src/lib/CECProcessor.cpp
index df04a237edba78ba755928757ed72c6f0590a1bb..0012a53d289f52591cb398f4c1bf1d152a68a120 100644
(file)
--- a/
src/lib/CECProcessor.cpp
+++ b/
src/lib/CECProcessor.cpp
@@
-42,15
+42,18
@@
#include "implementations/CECCommandHandler.h"
#include "LibCEC.h"
#include "CECClient.h"
#include "implementations/CECCommandHandler.h"
#include "LibCEC.h"
#include "CECClient.h"
+#include "CECTypeUtils.h"
#include "platform/util/timeutils.h"
#include "platform/util/timeutils.h"
+#include "platform/util/util.h"
using namespace CEC;
using namespace std;
using namespace PLATFORM;
#define CEC_PROCESSOR_SIGNAL_WAIT_TIME 1000
using namespace CEC;
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),
CCECProcessor::CCECProcessor(CLibCEC *libcec) :
m_bInitialised(false),
@@
-66,7
+69,7
@@
CCECProcessor::CCECProcessor(CLibCEC *libcec) :
CCECProcessor::~CCECProcessor(void)
{
Close();
CCECProcessor::~CCECProcessor(void)
{
Close();
-
delete m_busDevices
;
+
DELETE_AND_NULL(m_busDevices)
;
}
bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = CEC_SERIAL_DEFAULT_BAUDRATE */, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */)
}
bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = CEC_SERIAL_DEFAULT_BAUDRATE */, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */)
@@
-98,21
+101,13
@@
void CCECProcessor::Close(void)
StopThread();
// close the connection
StopThread();
// close the connection
- if (m_communication)
- {
- delete m_communication;
- m_communication = NULL;
- }
+ DELETE_AND_NULL(m_communication);
}
void CCECProcessor::ResetMembers(void)
{
// close the connection
}
void CCECProcessor::ResetMembers(void)
{
// close the connection
- if (m_communication)
- {
- delete m_communication;
- m_communication = NULL;
- }
+ DELETE_AND_NULL(m_communication);
// reset the other members to the initial state
m_iStandardLineTimeout = 3;
// reset the other members to the initial state
m_iStandardLineTimeout = 3;
@@
-203,6
+198,19
@@
void CCECProcessor::ReplaceHandlers(void)
it->second->ReplaceHandler(true);
}
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);
bool CCECProcessor::OnCommandReceived(const cec_command &command)
{
return m_inBuffer.Push(command);
@@
-213,6
+221,7
@@
void *CCECProcessor::Process(void)
m_libcec->AddLog(CEC_LOG_DEBUG, "processor thread started");
cec_command command;
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())
// as long as we're not being stopped and the connection is open
while (!IsStopped() && m_communication->IsOpen())
@@
-228,6
+237,13
@@
void *CCECProcessor::Process(void)
// check if we need to replace handlers
ReplaceHandlers();
// 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);
+ }
}
}
}
}
@@
-514,7
+530,7
@@
bool CCECProcessor::StartBootloader(const char *strPort /* = NULL */)
if (comm->IsOpen())
{
bReturn = comm->StartBootloader();
if (comm->IsOpen())
{
bReturn = comm->StartBootloader();
-
delete comm
;
+
DELETE_AND_NULL(comm)
;
}
return bReturn;
}
}
return bReturn;
}