LibCecSharp: better handling of callbacks
[deb_libcec.git] / src / lib / LibCEC.cpp
index 331b11d3b7cbfedd485a56c3d1787446dd3b0ca6..8838ff4157b48591a864082c436df100e9961e96 100644 (file)
@@ -102,16 +102,24 @@ bool CLibCEC::Open(const char *strPort, uint32_t iTimeoutMs /* = CEC_DEFAULT_CON
 
 void CLibCEC::Close(void)
 {
+  if (!m_cec)
+    return;
+
   // unregister all clients
-  UnregisterClients();
+  m_cec->UnregisterClients();
 
   // close the connection
-  if (m_cec)
-    m_cec->Close();
+  m_cec->Close();
 }
 
 int8_t CLibCEC::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */)
 {
+  if (!CUSBCECAdapterDetection::CanAutodetect())
+  {
+    AddLog(CEC_LOG_WARNING, "libCEC has not been compiled with adapter detection code for this target, so the path to the COM port has to be provided to libCEC");
+    return 0;
+  }
+
   return CUSBCECAdapterDetection::FindAdapters(deviceList, iBufSize, strDevicePath);
 }