cec: display a warning message if libCEC was not compiled with adapter detection...
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 13 Jun 2012 08:02:01 +0000 (10:02 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 13 Jun 2012 08:02:01 +0000 (10:02 +0200)
src/lib/LibCEC.cpp
src/lib/adapter/USBCECAdapterDetection.cpp
src/lib/adapter/USBCECAdapterDetection.h

index 56ece65b08d706d7275b6f04fd696ccd1482511e..8838ff4157b48591a864082c436df100e9961e96 100644 (file)
@@ -114,6 +114,12 @@ void CLibCEC::Close(void)
 
 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);
 }
 
index 8775b4e55bbb2444c8b9a841e3e57f0e3748773f..78b2760a3b43f369759debd7ca136416ef25d280 100644 (file)
@@ -115,6 +115,15 @@ bool FindComPort(CStdString &strLocation)
 }
 #endif
 
+bool CUSBCECAdapterDetection::CanAutodetect(void)
+{
+#if defined(__APPLE__) || defined(HAVE_LIBUDEV) || defined(__WINDOWS__) || defined(__FreeBSD__)
+  return true;
+#else
+  return false;
+#endif
+}
+
 uint8_t CUSBCECAdapterDetection::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */)
 {
   uint8_t iFound(0);
index 9be3a579346dda4ef177203070591358c9352a9f..9b6c624322c0b8fac152bf928e6221d36d504786 100644 (file)
@@ -38,6 +38,7 @@ namespace CEC
   class CUSBCECAdapterDetection
   {
   public:
-    static uint8_t FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath = NULL); 
+    static uint8_t FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath = NULL);
+    static bool    CanAutodetect(void);
   };
 };