livoxGen1: Rn attachedDataProducers=>attachedStimulusProducers
Also compare producers only by device selector and not by the rest of their stored DASpec.
This commit is contained in:
@@ -28,19 +28,22 @@ const SmoCallbacks* smoHooksPtr = nullptr;
|
||||
static SmoThreadingModelDesc smoThreadingModelDesc;
|
||||
|
||||
// Local collection of stimulus producers
|
||||
static std::vector<std::shared_ptr<StimulusProducer>> attachedDataProducers;
|
||||
static std::vector<std::shared_ptr<StimulusProducer>> attachedStimulusProducers;
|
||||
|
||||
// Get stimulus producer by device attachment spec
|
||||
static std::shared_ptr<StimulusProducer>
|
||||
getDataProducer(const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec)
|
||||
getStimulusProducer(
|
||||
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& 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<PcloudDataProducer>(
|
||||
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<PcloudDataProducer>(
|
||||
getDataProducer(desc));
|
||||
getStimulusProducer(desc));
|
||||
|
||||
if (!stimProducer)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user