From 7d86ecadc400123c2613f8726ad064c325985cf8 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Fri, 14 Nov 2025 23:26:13 -0400 Subject: [PATCH] livoxGen1: Rn attachedDataProducers=>attachedStimulusProducers Also compare producers only by device selector and not by the rest of their stored DASpec. --- stimBuffApis/livoxGen1/livoxGen1.cpp | 31 +++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/stimBuffApis/livoxGen1/livoxGen1.cpp b/stimBuffApis/livoxGen1/livoxGen1.cpp index 483ef52..041b6ba 100644 --- a/stimBuffApis/livoxGen1/livoxGen1.cpp +++ b/stimBuffApis/livoxGen1/livoxGen1.cpp @@ -28,19 +28,22 @@ const SmoCallbacks* smoHooksPtr = nullptr; static SmoThreadingModelDesc smoThreadingModelDesc; // Local collection of stimulus producers -static std::vector> attachedDataProducers; +static std::vector> attachedStimulusProducers; // Get stimulus producer by device attachment spec static std::shared_ptr -getDataProducer(const std::shared_ptr& spec) +getStimulusProducer( + const std::shared_ptr& spec + ) { - for (const auto& dataProducer : attachedDataProducers) + for (const auto& stimProducer : attachedStimulusProducers) { // Compare device selectors to find matching buffer - if (dataProducer->deviceAttachmentSpec->deviceSelector - == spec->deviceSelector) + if (livoxProto1::comms::deviceIdentifiersEqual( + stimProducer->deviceAttachmentSpec->deviceSelector, + spec->deviceSelector)) { - return dataProducer; + return stimProducer; } } @@ -202,7 +205,7 @@ public: context->stimProducer = pcloudDataProducer; context->deviceTmp->nAttachedStimBuffs++; - attachedDataProducers.push_back(pcloudDataProducer); + attachedStimulusProducers.push_back(pcloudDataProducer); pcloudDataProducer->start(); @@ -342,10 +345,10 @@ public: // Remove stimulus producer from collection before destroying device context->stimProducer->device->nAttachedStimBuffs--; auto it = std::find( - attachedDataProducers.begin(), attachedDataProducers.end(), + attachedStimulusProducers.begin(), attachedStimulusProducers.end(), context->stimProducer); - if (it != attachedDataProducers.end()) - { attachedDataProducers.erase(it); } + if (it != attachedStimulusProducers.end()) + { attachedStimulusProducers.erase(it); } (*livoxProto1.livoxProto1_destroyDeviceReq)( context->stimProducer->device, @@ -367,7 +370,7 @@ public: /** NOTE: * There's a decent argument for falling through here and still - * removing the stimulus producer from attachedDataProducers. + * removing the stimulus producer from attachedStimulusProducers. */ context->callOriginalCb(false, context->spec); return; @@ -490,7 +493,7 @@ extern "C" int livoxGen1_initializeInd(void) extern "C" int livoxGen1_finalizeInd(void) { - attachedDataProducers.clear(); + attachedStimulusProducers.clear(); // Call LivoxProto1 library exit function if (livoxProto1.livoxProto1_exit) { @@ -520,7 +523,7 @@ extern "C" void livoxGen1_attachDeviceReq( // Check if stimulus producer already exists in the collection auto pcloudDataProducer = std::static_pointer_cast( - getDataProducer(desc)); + getStimulusProducer(desc)); if (pcloudDataProducer) { @@ -651,7 +654,7 @@ extern "C" void livoxGen1_detachDeviceReq( { // Check if stimulus producer exists in the collection auto stimProducer = std::static_pointer_cast( - getDataProducer(desc)); + getStimulusProducer(desc)); if (!stimProducer) {