From: Lars Op den Kamp Date: Mon, 14 May 2012 20:04:12 +0000 (+0200) Subject: close the port connection if a command couldn't be written. this will trigger an... X-Git-Tag: upstream/2.2.0~1^2~28^2~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=814a902fdf90a8532fb6bcb540755f7502ebab12;p=deb_libcec.git close the port connection if a command couldn't be written. this will trigger an alert in the reader thread, and exit that thread --- diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index 08ae62c..70eddb8 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -386,7 +386,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 +399,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