From 814a902fdf90a8532fb6bcb540755f7502ebab12 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 14 May 2012 22:04:12 +0200 Subject: [PATCH] close the port connection if a command couldn't be written. this will trigger an alert in the reader thread, and exit that thread --- src/lib/adapter/USBCECAdapterCommunication.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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 -- 2.34.1