added bQuickScan param to DetectDevices(), so we don't try to open a connection each...
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 26 Feb 2013 22:30:33 +0000 (23:30 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 26 Feb 2013 22:49:32 +0000 (23:49 +0100)
include/cec.h
include/cecc.h
src/lib/LibCEC.cpp
src/lib/LibCEC.h
src/lib/LibCECC.cpp
src/lib/adapter/AdapterFactory.cpp
src/lib/adapter/Pulse-Eight/USBCECAdapterDetection.cpp

index b2f232fa07ab5560667154ace2f2d52e33bbc681..ebfaf488f16d4b8d6e9bdcfa6b8764cf5c03888f 100644 (file)
@@ -453,9 +453,10 @@ namespace CEC
      * @param deviceList The vector to store device descriptors in.
      * @param iBufSize The size of the deviceList buffer.
      * @param strDevicePath Optional device path. Only adds device descriptors that match the given device path.
+     * @param bQuickScan True to do a "quick scan", which will not open a connection to the adapter. Firmware version information and the exact device type will be missing
      * @return The number of devices that were found, or -1 when an error occured.
      */
-    virtual int8_t DetectAdapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath = NULL) = 0;
+    virtual int8_t DetectAdapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath = NULL, bool bQuickScan = false) = 0;
 
   };
 };
index ac1c541e8576314e6afa12d45ad12413b5d90ac9..0aca0b7683a811efe671e72293656a4c77c529fc 100644 (file)
@@ -285,9 +285,9 @@ extern DECLSPEC uint8_t cec_audio_unmute(void);
 extern DECLSPEC uint8_t cec_audio_get_status(void);
 
 #ifdef __cplusplus
-extern DECLSPEC int8_t cec_detect_adapters(CEC::cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath);
+extern DECLSPEC int8_t cec_detect_adapters(CEC::cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath, int bQuickScan);
 #else
-extern DECLSPEC int8_t cec_detect_adapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath);
+extern DECLSPEC int8_t cec_detect_adapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath, int bQuickScan);
 #endif
 
 #ifdef __cplusplus
index c04283d1871a7e8b76b34767b9211e32ac95fb5f..c24b4ed96e7d2ffcd8cb93fdbc7051d3325a0d30 100644 (file)
@@ -560,17 +560,20 @@ uint8_t CLibCEC::AudioStatus(void)
   return m_client ? m_client->AudioStatus() : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
 }
 
-int8_t CLibCEC::DetectAdapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */)
+int8_t CLibCEC::DetectAdapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */, bool bQuickScan /* = false */)
 {
   int8_t iAdaptersFound = CAdapterFactory(this).DetectAdapters(deviceList, iBufSize, strDevicePath);
-  for (int8_t iPtr = 0; iPtr < iAdaptersFound; iPtr++)
+  if (!bQuickScan)
   {
-    libcec_configuration config;
-    GetDeviceInformation(deviceList[iPtr].strComName, &config);
-    deviceList[iPtr].iFirmwareVersion   = config.iFirmwareVersion;
-    deviceList[iPtr].iPhysicalAddress   = config.iPhysicalAddress;
-    deviceList[iPtr].iFirmwareBuildDate = config.iFirmwareBuildDate;
-    deviceList[iPtr].adapterType        = config.adapterType;
+    for (int8_t iPtr = 0; iPtr < iAdaptersFound; iPtr++)
+    {
+      libcec_configuration config;
+      GetDeviceInformation(deviceList[iPtr].strComName, &config);
+      deviceList[iPtr].iFirmwareVersion   = config.iFirmwareVersion;
+      deviceList[iPtr].iPhysicalAddress   = config.iPhysicalAddress;
+      deviceList[iPtr].iFirmwareBuildDate = config.iFirmwareBuildDate;
+      deviceList[iPtr].adapterType        = config.adapterType;
+    }
   }
   return iAdaptersFound;
 }
index 385b74574ba701698e46c766b5367df733296bfd..3a312c00d4be7aea42bd98b5d61024713ab290c4 100644 (file)
@@ -52,7 +52,7 @@ namespace CEC
       void Close(void);
       bool EnableCallbacks(void *cbParam, ICECCallbacks *callbacks);
       int8_t FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath = NULL);
-      int8_t DetectAdapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath = NULL);
+      int8_t DetectAdapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath = NULL, bool bQuickScan = false);
       bool PingAdapter(void);
       bool StartBootloader(void);
 
index b73596e368bd04f08717c2ad4e6af54fccc92b8b..8309c3c60d0318b2137ca516c2d4a4884a61e2f8 100644 (file)
@@ -408,10 +408,10 @@ uint8_t cec_audio_get_status(void)
   return cec_parser ? cec_parser->AudioStatus() : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
 }
 
-int8_t cec_detect_adapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */)
+int8_t cec_detect_adapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath, int bQuickScan)
 {
   if (cec_parser)
-    return cec_parser->DetectAdapters(deviceList, iBufSize, strDevicePath);
+    return cec_parser->DetectAdapters(deviceList, iBufSize, strDevicePath, bQuickScan);
   return -1;
 }
 
index ded3b6fc7dc5c7c9c075321b066bb989a14587dd..ae906428de81c095be46d0a9c04c8138d0fcbfa1 100644 (file)
@@ -91,6 +91,7 @@ int8_t CAdapterFactory::DetectAdapters(cec_adapter_descriptor *deviceList, uint8
     snprintf(deviceList[iAdaptersFound].strComName, sizeof(deviceList[iAdaptersFound].strComName), CEC_RPI_VIRTUAL_COM);
     deviceList[iAdaptersFound].iVendorId = RPI_ADAPTER_VID;
     deviceList[iAdaptersFound].iProductId = RPI_ADAPTER_PID;
+    deviceList[iAdaptersFound].adapterType = ADAPTERTYPE_RPI;
     iAdaptersFound++;
   }
 #endif
@@ -103,6 +104,7 @@ int8_t CAdapterFactory::DetectAdapters(cec_adapter_descriptor *deviceList, uint8
     snprintf(deviceList[iAdaptersFound].comm, sizeof(deviceList[iAdaptersFound].strComName), CEC_TDA995x_VIRTUAL_COM);
     deviceList[iAdaptersFound].iVendorId = TDA995X_ADAPTER_VID;
     deviceList[iAdaptersFound].iProductId = TDA995X_ADAPTER_PID;
+    deviceList[iAdaptersFound].adapterType = ADAPTERTYPE_TDA995x;
     iAdaptersFound++;
   }
 #endif
index 40b57d1ae5a8ca3219b07a16bdb3fdd537a56717..456350f17177ead54003673841a83df551533106 100644 (file)
@@ -268,6 +268,7 @@ uint8_t CUSBCECAdapterDetection::FindAdapters(cec_adapter_descriptor *deviceList
                 snprintf(deviceList[iFound].strComName, sizeof(deviceList[iFound].strComName), "%s", bsdPath);
                 deviceList[iFound].iVendorId = iVendor;
                 deviceList[iFound].iProductId = iProduct;
+                deviceList[iFound].adapterType = ADAPTERTYPE_P8_EXTERNAL; // will be overridden when not doing a "quick scan" by the actual type
                 iFound++;
               }
             }
@@ -320,6 +321,7 @@ uint8_t CUSBCECAdapterDetection::FindAdapters(cec_adapter_descriptor *deviceList
           snprintf(deviceList[iFound].strComName, sizeof(deviceList[iFound].strComName), "%s", strComm.c_str());
           deviceList[iFound].iVendorId = iVendor;
           deviceList[iFound].iProductId = iProduct;
+          deviceList[iFound].adapterType = ADAPTERTYPE_P8_EXTERNAL; // will be overridden when not doing a "quick scan" by the actual type
           iFound++;
         }
       }
@@ -417,6 +419,7 @@ uint8_t CUSBCECAdapterDetection::FindAdapters(cec_adapter_descriptor *deviceList
         snprintf(deviceList[iFound].strComPath, sizeof(deviceList[iFound].strComPath), "%s", devicedetailData->DevicePath);
         deviceList[iFound].iVendorId = iVendor;
         deviceList[iFound].iProductId = iProduct;
+        deviceList[iFound].adapterType = ADAPTERTYPE_P8_EXTERNAL; // will be overridden when not doing a "quick scan" by the actual type
         iFound++;
       }
     }
@@ -425,6 +428,7 @@ uint8_t CUSBCECAdapterDetection::FindAdapters(cec_adapter_descriptor *deviceList
       snprintf(deviceList[iFound].strComPath, sizeof(deviceList[iFound].strComPath), "%s", devicedetailData->DevicePath);
       deviceList[iFound].iVendorId = iVendor;
       deviceList[iFound].iProductId = iProduct;
+      deviceList[iFound].adapterType = ADAPTERTYPE_P8_EXTERNAL; // will be overridden when not doing a "quick scan" by the actual type
       iFound++;
     }
   }
@@ -443,6 +447,7 @@ uint8_t CUSBCECAdapterDetection::FindAdapters(cec_adapter_descriptor *deviceList
       snprintf(deviceList[iFound].strComName, sizeof(deviceList[iFound].strComName), "%s", devicePath);
       deviceList[iFound].iVendorId = CEC_VID;
       deviceList[iFound].iProductId = CEC_VID;
+      deviceList[iFound].adapterType = ADAPTERTYPE_P8_EXTERNAL; // will be overridden when not doing a "quick scan" by the actual type
       iFound++;
     }
   }