X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fadapter%2FAdapterFactory.cpp;h=1596cfd1aeebb07d414e8eb74eba9e692555b628;hb=e7fd53c8e125db215629cdc557c45e2e875d02cc;hp=02b6200e1616674964f34af5459cc9955ffe6a22;hpb=ab2ab9ee1ac85713acdd5c29f1c35a5992fae214;p=deb_libcec.git diff --git a/src/lib/adapter/AdapterFactory.cpp b/src/lib/adapter/AdapterFactory.cpp index 02b6200..1596cfd 100644 --- a/src/lib/adapter/AdapterFactory.cpp +++ b/src/lib/adapter/AdapterFactory.cpp @@ -56,6 +56,18 @@ using namespace std; using namespace CEC; int8_t CAdapterFactory::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */) +{ + cec_adapter_descriptor devices[iBufSize]; + int8_t iReturn = DetectAdapters(devices, iBufSize, strDevicePath); + for (int8_t iPtr = 0; iPtr < iReturn; iPtr++) + { + strncpy(deviceList[iPtr].comm, devices[iPtr].strComName, sizeof(deviceList[iPtr].comm)); + strncpy(deviceList[iPtr].path, devices[iPtr].strComPath, sizeof(deviceList[iPtr].path)); + } + return iReturn; +} + +int8_t CAdapterFactory::DetectAdapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */) { int8_t iAdaptersFound(0); @@ -75,8 +87,11 @@ int8_t CAdapterFactory::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, if (iAdaptersFound < iBufSize && CRPiCECAdapterDetection::FindAdapter() && (!strDevicePath || !strcmp(strDevicePath, CEC_RPI_VIRTUAL_COM))) { - snprintf(deviceList[iAdaptersFound].path, 1024, CEC_RPI_VIRTUAL_PATH); - snprintf(deviceList[iAdaptersFound++].comm, 1024, CEC_RPI_VIRTUAL_COM); + snprintf(deviceList[iAdaptersFound].strComPath, sizeof(deviceList[iAdaptersFound].strComPath), CEC_RPI_VIRTUAL_PATH); + snprintf(deviceList[iAdaptersFound].strComName, sizeof(deviceList[iAdaptersFound].strComName), CEC_RPI_VIRTUAL_COM); + deviceList[iAdaptersFound].iVendorId = RPI_ADAPTER_VID; + deviceList[iAdaptersFound].iProductId = RPI_ADAPTER_PID; + iAdaptersFound++; } #endif @@ -84,8 +99,11 @@ int8_t CAdapterFactory::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, if (iAdaptersFound < iBufSize && CTDA995xCECAdapterDetection::FindAdapter() && (!strDevicePath || !strcmp(strDevicePath, CEC_TDA995x_VIRTUAL_COM))) { - snprintf(deviceList[iAdaptersFound].path, 1024, CEC_TDA995x_PATH); - snprintf(deviceList[iAdaptersFound++].comm, 1024, CEC_TDA995x_VIRTUAL_COM); + snprintf(deviceList[iAdaptersFound].path, sizeof(deviceList[iAdaptersFound].strComPath), CEC_TDA995x_PATH); + snprintf(deviceList[iAdaptersFound].comm, sizeof(deviceList[iAdaptersFound].strComName), CEC_TDA995x_VIRTUAL_COM); + deviceList[iAdaptersFound].iVendorId = TDA995X_ADAPTER_VID; + deviceList[iAdaptersFound].iProductId = TDA995X_ADAPTER_PID; + iAdaptersFound++; } #endif