repositories
/
deb_libcec.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
63047ed
)
cec: retry 'activate source' every 10 seconds if it failed
author
Lars Op den Kamp
<lars@opdenkamp.eu>
Thu, 31 May 2012 21:06:42 +0000
(23:06 +0200)
committer
Lars Op den Kamp
<lars@opdenkamp.eu>
Thu, 31 May 2012 21:09:29 +0000
(23:09 +0200)
src/lib/CECProcessor.cpp
patch
|
blob
|
blame
|
history
src/lib/CECProcessor.h
patch
|
blob
|
blame
|
history
src/lib/implementations/CECCommandHandler.cpp
patch
|
blob
|
blame
|
history
src/lib/implementations/CECCommandHandler.h
patch
|
blob
|
blame
|
history
diff --git
a/src/lib/CECProcessor.cpp
b/src/lib/CECProcessor.cpp
index 11076ecb78d191dfabdb80341a0a124af90be085..fe40990553d2a4ea2dc278e70cda437262f2c666 100644
(file)
--- a/
src/lib/CECProcessor.cpp
+++ b/
src/lib/CECProcessor.cpp
@@
-51,6
+51,7
@@
using namespace std;
using namespace PLATFORM;
#define CEC_PROCESSOR_SIGNAL_WAIT_TIME 1000
using namespace PLATFORM;
#define CEC_PROCESSOR_SIGNAL_WAIT_TIME 1000
+#define ACTIVE_SOURCE_CHECK_TIMEOUT 10000
#define ToString(x) CCECTypeUtils::ToString(x)
#define ToString(x) CCECTypeUtils::ToString(x)
@@
-200,6
+201,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);
@@
-210,6
+224,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())
@@
-225,6
+240,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);
+ }
}
}
}
}
diff --git
a/src/lib/CECProcessor.h
b/src/lib/CECProcessor.h
index 5f496d2631558506045e645ecf450e4ba37c5995..04d84f55ee2f5edab2997a5aec3d51a5df25d316 100644
(file)
--- a/
src/lib/CECProcessor.h
+++ b/
src/lib/CECProcessor.h
@@
-134,6
+134,7
@@
namespace CEC
void SetCECInitialised(bool bSetTo = true);
void ReplaceHandlers(void);
void SetCECInitialised(bool bSetTo = true);
void ReplaceHandlers(void);
+ void CheckPendingActiveSource(void);
bool PhysicalAddressInUse(uint16_t iPhysicalAddress);
bool SetAckMask(uint16_t iMask);
bool PhysicalAddressInUse(uint16_t iPhysicalAddress);
bool SetAckMask(uint16_t iMask);
diff --git
a/src/lib/implementations/CECCommandHandler.cpp
b/src/lib/implementations/CECCommandHandler.cpp
index 6ffc4ac980db71cdfbdbd42cfd577084426e0e00..3627c4e38a1e5421f4fb8fc93730a30d34b13f39 100644
(file)
--- a/
src/lib/implementations/CECCommandHandler.cpp
+++ b/
src/lib/implementations/CECCommandHandler.cpp
@@
-56,7
+56,8
@@
CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice) :
m_bHandlerInited(false),
m_bOPTSendDeckStatusUpdateOnActiveSource(false),
m_vendorId(CEC_VENDOR_UNKNOWN),
m_bHandlerInited(false),
m_bOPTSendDeckStatusUpdateOnActiveSource(false),
m_vendorId(CEC_VENDOR_UNKNOWN),
- m_waitForResponse(new CWaitForResponse)
+ m_waitForResponse(new CWaitForResponse),
+ m_bActiveSourcePending(false)
{
}
{
}
@@
-1056,16
+1057,27
@@
bool CCECCommandHandler::ActivateSource(void)
if (m_busDevice->IsActiveSource() &&
m_busDevice->IsHandledByLibCEC())
{
if (m_busDevice->IsActiveSource() &&
m_busDevice->IsHandledByLibCEC())
{
+ {
+ CLockObject lock(m_mutex);
+ m_bActiveSourcePending = false;
+ }
+
m_busDevice->SetPowerStatus(CEC_POWER_STATUS_ON);
m_busDevice->SetMenuState(CEC_MENU_STATE_ACTIVATED);
m_busDevice->SetPowerStatus(CEC_POWER_STATUS_ON);
m_busDevice->SetMenuState(CEC_MENU_STATE_ACTIVATED);
- m_busDevice->TransmitImageViewOn();
- m_busDevice->TransmitActiveSource();
- m_busDevice->TransmitMenuState(CECDEVICE_TV);
+ if (!m_busDevice->TransmitImageViewOn() ||
+ !m_busDevice->TransmitActiveSource() ||
+ !m_busDevice->TransmitMenuState(CECDEVICE_TV))
+ {
+ CLockObject lock(m_mutex);
+ m_bActiveSourcePending = true;
+ return false;
+ }
CCECPlaybackDevice *playbackDevice = m_busDevice->AsPlaybackDevice();
if (playbackDevice && SendDeckStatusUpdateOnActiveSource())
playbackDevice->TransmitDeckStatus(CECDEVICE_TV);
CCECPlaybackDevice *playbackDevice = m_busDevice->AsPlaybackDevice();
if (playbackDevice && SendDeckStatusUpdateOnActiveSource())
playbackDevice->TransmitDeckStatus(CECDEVICE_TV);
+
m_bHandlerInited = true;
}
return true;
m_bHandlerInited = true;
}
return true;
@@
-1075,3
+1087,9
@@
void CCECCommandHandler::SignalOpcode(cec_opcode opcode)
{
m_waitForResponse->Received(opcode);
}
{
m_waitForResponse->Received(opcode);
}
+
+bool CCECCommandHandler::ActiveSourcePending(void)
+{
+ CLockObject lock(m_mutex);
+ return m_bActiveSourcePending;
+}
diff --git
a/src/lib/implementations/CECCommandHandler.h
b/src/lib/implementations/CECCommandHandler.h
index 1bced84ff8fc469b17a004aa70891233913a1f78..6e0121fdee49886dc4b3db09b47465d8175aa9e6 100644
(file)
--- a/
src/lib/implementations/CECCommandHandler.h
+++ b/
src/lib/implementations/CECCommandHandler.h
@@
-162,6
+162,8
@@
namespace CEC
virtual void SignalOpcode(cec_opcode opcode);
virtual void SignalOpcode(cec_opcode opcode);
+ virtual bool ActiveSourcePending(void);
+
protected:
virtual bool HandleActiveSource(const cec_command &command);
virtual bool HandleDeckControl(const cec_command &command);
protected:
virtual bool HandleActiveSource(const cec_command &command);
virtual bool HandleDeckControl(const cec_command &command);
@@
-218,5
+220,7
@@
namespace CEC
bool m_bOPTSendDeckStatusUpdateOnActiveSource;
cec_vendor_id m_vendorId;
CWaitForResponse *m_waitForResponse;
bool m_bOPTSendDeckStatusUpdateOnActiveSource;
cec_vendor_id m_vendorId;
CWaitForResponse *m_waitForResponse;
+ bool m_bActiveSourcePending;
+ PLATFORM::CMutex m_mutex;
};
};
};
};