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

◆ add_reader()

uint64_t MayaFlux::Core::SerialInputBackend::add_reader ( uint32_t device_id,
SerialSpec spec,
ReaderCallback callback )

Read a device's bytes a second way and hand the values to callback.

Returns
A token for remove_reader(), or 0 for an unknown device or a reading.

Unlike a view, it is not listed as a device and does not go to the input callback. It stays attached when the device is closed and opened again, and runs on the link's thread. Values carry the id of the device.

Definition at line 525 of file SerialInputBackend.cpp.

526{
527 if (!m_initialized.load() || !callback) {
528 return 0;
529 }
530
531 bool known = false;
532 if (const auto roster = m_roster.read()) {
533 const auto it = roster->entries.find(device_id);
534 known = it != roster->entries.end() && it->second.parent == 0;
535 }
536 if (!known) {
537 return 0;
538 }
539
540 const uint64_t token = add_record(device_id, device_id, std::move(spec), std::move(callback));
541 attach_readers(device_id, get_device(device_id));
542 return token;
543}
uint64_t add_record(uint32_t device_id, uint32_t stamp, SerialSpec spec, ReaderCallback callback)
std::shared_ptr< SerialDevice > get_device(uint32_t device_id) const
The open device, or null.
void attach_readers(uint32_t device_id, const std::shared_ptr< SerialDevice > &device)
Memory::SnapshotCell< Roster > m_roster

References add_reader(), add_record(), attach_readers(), get_device(), m_initialized, and m_roster.

Referenced by add_reader(), and MayaFlux::Core::InputSubsystem::register_backend_service().

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