using namespace PLATFORM;
#define CEC_PROCESSOR_SIGNAL_WAIT_TIME 1000
+#define ACTIVE_SOURCE_CHECK_TIMEOUT 10000
#define ToString(x) CCECTypeUtils::ToString(x)
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);
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())
// 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);
+ }
}
}
void SetCECInitialised(bool bSetTo = true);
void ReplaceHandlers(void);
+ void CheckPendingActiveSource(void);
bool PhysicalAddressInUse(uint16_t iPhysicalAddress);
bool SetAckMask(uint16_t iMask);
m_bHandlerInited(false),
m_bOPTSendDeckStatusUpdateOnActiveSource(false),
m_vendorId(CEC_VENDOR_UNKNOWN),
- m_waitForResponse(new CWaitForResponse)
+ m_waitForResponse(new CWaitForResponse),
+ m_bActiveSourcePending(false)
{
}
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->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);
+
m_bHandlerInited = true;
}
return true;
{
m_waitForResponse->Received(opcode);
}
+
+bool CCECCommandHandler::ActiveSourcePending(void)
+{
+ CLockObject lock(m_mutex);
+ return m_bActiveSourcePending;
+}
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);
bool m_bOPTSendDeckStatusUpdateOnActiveSource;
cec_vendor_id m_vendorId;
CWaitForResponse *m_waitForResponse;
+ bool m_bActiveSourcePending;
+ PLATFORM::CMutex m_mutex;
};
};