X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fadapter%2FUSBCECAdapterCommunication.cpp;h=801ebc509550fda47fe1b80dff0dce9cca77befc;hb=65108638b4d86198e03bc709a8a51a4658aef160;hp=08ae62c701e681250a4948d59b16ccd908269ddc;hpb=cc938f166e50b0c9e4fdccf55e0a8cffb2c56602;p=deb_libcec.git diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index 08ae62c..801ebc5 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -341,7 +341,8 @@ 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; - Close(); + // this will trigger an alert in the reader thread + m_port->Close(); return false; } @@ -386,7 +387,7 @@ bool CUSBCECAdapterCommunication::ReadFromDevice(uint32_t iTimeout, size_t iSize CCECAdapterMessage *CUSBCECAdapterCommunication::SendCommand(cec_adapter_messagecode msgCode, CCECAdapterMessage ¶ms, bool bIsRetry /* = false */) { - if (!m_port->IsOpen() || !m_adapterMessageQueue) + if (!IsOpen() || !m_adapterMessageQueue) return NULL; /* create the adapter message for this command */ @@ -399,14 +400,9 @@ CCECAdapterMessage *CUSBCECAdapterCommunication::SendCommand(cec_adapter_message /* write the command */ if (!m_adapterMessageQueue->Write(output)) { + // this will trigger an alert in the reader thread if (output->state == ADAPTER_MESSAGE_STATE_ERROR) - { - libcec_parameter param; - param.paramData = NULL; param.paramType = CEC_PARAMETER_TYPE_UNKOWN; - LIB_CEC->Alert(CEC_ALERT_CONNECTION_LOST, param); - - Close(); - } + m_port->Close(); return output; } else @@ -491,7 +487,7 @@ bool CUSBCECAdapterCommunication::StartBootloader(void) { if (m_port->IsOpen() && m_commands->StartBootloader()) { - Close(); + m_port->Close(); return true; } return false;