#define ToString(x) CCECTypeUtils::ToString(x)
+CCECStandbyProtection::CCECStandbyProtection(CCECProcessor* processor) :
+ m_processor(processor) {}
+CCECStandbyProtection::~CCECStandbyProtection(void) {}
+
+void* CCECStandbyProtection::Process(void)
+{
+ int64_t last = GetTimeMs();
+ int64_t next;
+ while (!IsStopped())
+ {
+ PLATFORM::CEvent::Sleep(1000);
+
+ next = GetTimeMs();
+
+ // reset the connection if the clock changed
+ if (next < last || next - last > 10000)
+ {
+ libcec_parameter param;
+ param.paramData = NULL; param.paramType = CEC_PARAMETER_TYPE_UNKOWN;
+ m_processor->GetLib()->Alert(CEC_ALERT_CONNECTION_LOST, param);
+ break;
+ }
+
+ last = next;
+ }
+ return NULL;
+}
+
CCECProcessor::CCECProcessor(CLibCEC *libcec) :
m_bInitialised(false),
m_communication(NULL),
m_iLastTransmission(0),
m_bMonitor(true),
m_addrAllocator(NULL),
- m_bStallCommunication(false)
+ m_bStallCommunication(false),
+ m_connCheck(NULL)
{
m_busDevices = new CCECDeviceMap(this);
}
SetCECInitialised(false);
// stop the processor
+ DELETE_AND_NULL(m_connCheck);
StopThread(-1);
m_inBuffer.Broadcast();
StopThread();
{
m_libcec->AddLog(CEC_LOG_DEBUG, "processor thread started");
+ if (!m_connCheck)
+ m_connCheck = new CCECStandbyProtection(this);
+ m_connCheck->CreateThread();
+
cec_command command; command.Clear();
CTimeout activeSourceCheck(ACTIVE_SOURCE_CHECK_INTERVAL);
CTimeout tvPresentCheck(TV_PRESENT_CHECK_INTERVAL);
class CCECTV;
class CCECClient;
class CCECProcessor;
+ class CCECStandbyProtection;
class CCECAllocateLogicalAddress : public PLATFORM::CThread
{
bool m_bMonitor;
CCECAllocateLogicalAddress* m_addrAllocator;
bool m_bStallCommunication;
+ CCECStandbyProtection* m_connCheck;
+ };
+
+ class CCECStandbyProtection : public PLATFORM::CThread
+ {
+ public:
+ CCECStandbyProtection(CCECProcessor* processor);
+ virtual ~CCECStandbyProtection(void);
+ void* Process(void);
+
+ private:
+ CCECProcessor* m_processor;
};
};
{
LIB_CEC->AddLog(CEC_LOG_DEBUG, "error writing command '%s' to serial port '%s': %s", CCECAdapterMessage::ToString(message->Message()), m_port->GetName().c_str(), m_port->GetError().c_str());
message->state = ADAPTER_MESSAGE_STATE_ERROR;
- // this will trigger an alert in the reader thread
- m_port->Close();
+ // let the higher level close the port
return false;
}
if (m_port->GetErrorNumber())
{
LIB_CEC->AddLog(CEC_LOG_ERROR, "error reading from serial port: %s", m_port->GetError().c_str());
- m_port->Close();
+ // let the higher level close the port
return false;
}
}
/* failed to ping the adapter 3 times in a row. something must be wrong with the connection */
m_com->LIB_CEC->AddLog(CEC_LOG_ERROR, "failed to ping the adapter 3 times in a row. closing the connection.");
m_com->StopThread(false);
+
+ libcec_parameter param;
+ param.paramData = NULL; param.paramType = CEC_PARAMETER_TYPE_UNKOWN;
+ m_com->LIB_CEC->Alert(CEC_ALERT_CONNECTION_LOST, param);
+
break;
}
}