cec: don't send a 'disconnected' alert when the close method is called
authorLars Op den Kamp <lars@opdenkamp.eu>
Fri, 11 May 2012 07:54:37 +0000 (09:54 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Fri, 11 May 2012 07:54:37 +0000 (09:54 +0200)
src/lib/adapter/USBCECAdapterCommunication.cpp

index 680918d3f427e9098487e81912164ef5ea9ea7fb..5c2653ade2c67070cfd5d02cddda73e3aac9372c 100644 (file)
@@ -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