for (unsigned int iPtr = CECDEVICE_TV; iPtr < CECDEVICE_BROADCAST; iPtr++)
m_bWaitingForAck[iPtr] = false;
m_port = new CSerialPort(strPort, iBaudRate);
+ m_commands = new CUSBCECAdapterCommands(this);
}
CUSBCECAdapterCommunication::~CUSBCECAdapterCommunication(void)
DELETE_AND_NULL(m_port);
}
+void CUSBCECAdapterCommunication::ResetMessageQueue(void)
+{
+ DELETE_AND_NULL(m_adapterMessageQueue);
+ m_adapterMessageQueue = new CCECAdapterMessageQueue(this);
+ m_adapterMessageQueue->CreateThread();
+}
+
bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */, bool bSkipChecks /* = false */, bool bStartListening /* = true */)
{
bool bConnectionOpened(false);
return true;
}
- /* adapter commands */
- if (!m_commands)
- m_commands = new CUSBCECAdapterCommands(this);
-
- if (!m_adapterMessageQueue)
- {
- m_adapterMessageQueue = new CCECAdapterMessageQueue(this);
- m_adapterMessageQueue->CreateThread();
- }
+ ResetMessageQueue();
/* try to open the connection */
CStdString strError;
ClearInputBytes();
}
+ // always start by setting the ackmask to 0, to clear previous values
+ SetAckMask(0);
+
if (!CreateThread())
{
bConnectionOpened = false;
bool CUSBCECAdapterCommunication::SetAckMask(uint16_t iMask)
{
- if (m_iAckMask == iMask)
- return true;
+ {
+ CLockObject lock(m_mutex);
+ if (m_iAckMask == iMask)
+ return true;
+ }
if (IsOpen() && m_commands->SetAckMask(iMask))
{
+ CLockObject lock(m_mutex);
m_iAckMask = iMask;
return true;
}
uint16_t CUSBCECAdapterCommunication::GetAckMask(void)
{
+ CLockObject lock(m_mutex);
return m_iAckMask;
}
*/
void MarkAsWaiting(const cec_logical_address dest);
+ /*!
+ * @brief Clear and reset the message queue.
+ */
+ void ResetMessageQueue(void);
+
PLATFORM::ISocket * m_port; /**< the com port connection */
PLATFORM::CMutex m_mutex; /**< mutex for changes in this class */
uint8_t m_iLineTimeout; /**< the current line timeout on the CEC line */