X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fadapter%2FPulse-Eight%2FUSBCECAdapterCommunication.cpp;h=1be07c51fbb385e224a7fa5ec1ff0c2cb40515f9;hb=9be2206f155d4cff55d816e80d6275844cc33b3b;hp=07255a79c84fa5c52500d0da6362a048c95c3e1e;hpb=16f47961800432dbdd5b3ead717908f383d26d6b;p=deb_libcec.git diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.cpp b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.cpp index 07255a7..1be07c5 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.cpp @@ -304,6 +304,7 @@ bool CUSBCECAdapterCommunication::HandlePoll(const CCECAdapterMessage &msg) m_lastPollDestination = msg.Destination(); if (msg.Destination() < CECDEVICE_BROADCAST) { + CLockObject waitingLock(m_waitingMutex); if (!m_bWaitingForAck[msg.Destination()] && !msg.IsEOM()) { if (m_callback) @@ -328,7 +329,7 @@ void CUSBCECAdapterCommunication::MarkAsWaiting(const cec_logical_address dest) /* mark as waiting for an ack from the destination */ if (dest < CECDEVICE_BROADCAST) { - CLockObject lock(m_mutex); + CLockObject waitingLock(m_waitingMutex); m_bWaitingForAck[dest] = true; } } @@ -382,8 +383,7 @@ bool CUSBCECAdapterCommunication::WriteToDevice(CCECAdapterMessage *message) { 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; } @@ -416,7 +416,7 @@ bool CUSBCECAdapterCommunication::ReadFromDevice(uint32_t iTimeout, size_t iSize 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; } } @@ -710,7 +710,7 @@ void *CAdapterPingThread::Process(void) /* send a ping to the adapter */ bool bPinged(false); int iFailedCounter(0); - while (!bPinged && iFailedCounter < 3) + while (!bPinged && iFailedCounter < 3 && !IsStopped()) { if (!m_com->PingAdapter()) { @@ -724,11 +724,16 @@ void *CAdapterPingThread::Process(void) } } - if (iFailedCounter == 3) + if (iFailedCounter == 3 && !IsStopped()) { /* 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; } }