CCECInputBuffer(void) : m_bHasData(false) {}
virtual ~CCECInputBuffer(void)
{
+ Broadcast();
+ }
+
+ void Broadcast(void)
+ {
+ PLATFORM::CLockObject lock(m_mutex);
+ m_bHasData = true;
m_condition.Broadcast();
}
SetCECInitialised(false);
// stop the processor
+ StopThread(-1);
+ m_inBuffer.Broadcast();
StopThread();
// close the connection
if (m_inBuffer.Pop(command, CEC_PROCESSOR_SIGNAL_WAIT_TIME))
ProcessCommand(command);
- if (CECInitialised())
+ if (CECInitialised() && !IsStopped())
{
// check clients for keypress timeouts
m_libcec->CheckKeypressTimeout();
void CLibCEC::UnregisterClients(void)
{
- if (m_cec)
+ if (m_cec && m_cec->IsRunning())
m_cec->UnregisterClients();
m_clients.clear();
}
/* TODO sleep 5 ms so other threads can get a lock */
- Sleep(5);
+ if (!IsStopped())
+ Sleep(5);
}
m_adapterMessageQueue->Clear();
CLockObject lock(m_mutex);
if (m_iScheduleEepromWrite > 0)
m_com->LIB_CEC->AddLog(CEC_LOG_WARNING, "write thread stopped while a write was queued");
+ m_bWrite = true;
m_condition.Signal();
}
StopThread();
if ((m_iScheduleEepromWrite > 0 && m_iScheduleEepromWrite < GetTimeMs()) ||
m_condition.Wait(m_mutex, m_bWrite, 100))
{
+ if (IsStopped())
+ break;
m_bWrite = false;
if (m_com->m_commands->WriteEEPROM())
{
CCECAdapterMessageQueue::~CCECAdapterMessageQueue(void)
{
+ StopThread(-1);
Clear();
- StopThread(0);
+ StopThread();
delete m_incomingAdapterMessage;
}
CLockObject lock(m_mutex);
while (!m_buffer.empty())
m_buffer.pop();
+ m_bHasMessages = true;
m_condition.Broadcast();
}
}
// pop the first item
+ m_bHasMessages = !m_buffer.empty();
if (!m_buffer.empty())
{
entry = m_buffer.front();
m_buffer.pop();
- m_bHasMessages = !m_buffer.empty();
bReturn = true;
}
return bReturn;