From: Lars Op den Kamp Date: Fri, 11 May 2012 07:54:37 +0000 (+0200) Subject: cec: don't send a 'disconnected' alert when the close method is called X-Git-Tag: upstream/2.2.0~1^2~28^2~24 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2fbffb2596a25784888e439918acb1698fd538c4;p=deb_libcec.git cec: don't send a 'disconnected' alert when the close method is called --- diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index 680918d..5c2653a 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -188,10 +188,6 @@ void CUSBCECAdapterCommunication::Close(void) /* close and delete the com port connection */ if (m_port) m_port->Close(); - - libcec_parameter param; - param.paramData = NULL; param.paramType = CEC_PARAMETER_TYPE_UNKOWN; - LIB_CEC->Alert(CEC_ALERT_CONNECTION_LOST, param); } cec_adapter_message_state CUSBCECAdapterCommunication::Write(const cec_command &data, bool &bRetry, uint8_t iLineTimeout) @@ -224,7 +220,13 @@ void *CUSBCECAdapterCommunication::Process(void) { /* read from the serial port */ if (!ReadFromDevice(50, 5)) + { + libcec_parameter param; + param.paramData = NULL; param.paramType = CEC_PARAMETER_TYPE_UNKOWN; + LIB_CEC->Alert(CEC_ALERT_CONNECTION_LOST, param); + break; + } /* TODO sleep 5 ms so other threads can get a lock */ Sleep(5); @@ -384,7 +386,13 @@ CCECAdapterMessage *CUSBCECAdapterCommunication::SendCommand(cec_adapter_message if (!m_adapterMessageQueue->Write(output)) { 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(); + } return output; } else