MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ close_device()

void MayaFlux::Core::SerialInputBackend::close_device ( uint32_t device_id)
overridevirtual

Close a previously opened device.

Parameters
device_idDevice identifier

Implements MayaFlux::Core::IInputBackend.

Definition at line 338 of file SerialInputBackend.cpp.

339{
340 bool is_view = false;
341 if (const auto roster = m_roster.read()) {
342 const auto it = roster->entries.find(device_id);
343 is_view = it != roster->entries.end() && it->second.parent != 0;
344 }
345 if (is_view) {
346 detach_view(device_id);
347 return;
348 }
349
350 std::shared_ptr<SerialDevice> device;
351 m_roster.update([&](Roster& roster) {
352 device.reset();
353 const auto it = roster.entries.find(device_id);
354 if (it == roster.entries.end() || !it->second.device) {
355 return false;
356 }
357 Entry changed = it->second;
358 device = std::move(changed.device);
359 changed.device.reset();
360 roster.entries.insert_or_assign(device_id, std::move(changed));
361 return true;
362 });
363
364 if (device) {
365 device->close();
366 }
367}
Memory::SnapshotCell< Roster > m_roster

References close_device(), detach_view(), MayaFlux::Core::SerialInputBackend::Entry::device, MayaFlux::Core::SerialInputBackend::Roster::entries, and m_roster.

Referenced by close_device().

Here is the call graph for this function:
Here is the caller graph for this function: