CLockObject lock(m_mutex);
if (m_communication)
{
- CLibCEC::AddLog(CEC_LOG_ERROR, "existing connection handler found");
- return bReturn;
+ CLibCEC::AddLog(CEC_LOG_WARNING, "existing connection handler found, deleting it");
+ m_communication->Close();
+ delete m_communication;
}
m_communication = new CUSBCECAdapterCommunication(this, strPort, iBaudRate);
}
if (m_communication)
+ {
m_communication->Close();
+ delete m_communication;
+ m_communication = NULL;
+ }
return NULL;
}
CUSBCECAdapterCommunication::~CUSBCECAdapterCommunication(void)
{
Close();
-
- if (m_port)
- {
- delete m_port;
- m_port = NULL;
- }
}
bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = 10000 */)
if (m_outBuffer.Pop(msg))
msg->condition.Broadcast();
+ if (m_port)
+ {
+ delete m_port;
+ m_port = NULL;
+ }
+
return NULL;
}