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

◆ close_device()

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

Close a previously opened device.

Parameters
device_idDevice identifier

Implements MayaFlux::Core::IInputBackend.

Definition at line 252 of file MIDIBackend.cpp.

253{
254 std::lock_guard lock(m_devices_mutex);
255
256 auto it = m_open_devices.find(device_id);
257 if (it == m_open_devices.end()) {
258 return;
259 }
260
261 it->second->active.store(false);
262 if (it->second->midi_in) {
263 try {
264 it->second->midi_in->closePort();
265 } catch (const RtMidiError& error) {
267 "Error closing MIDI port {}: {}", it->second->info.name, error.getMessage());
268 }
269 }
270
272 "Closed MIDI port {}: {}", device_id, it->second->info.name);
273
274 m_open_devices.erase(it);
275}
#define MF_INFO(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
std::unordered_map< uint32_t, std::shared_ptr< MIDIPortState > > m_open_devices
@ InputBackend
Input device backend (HID, MIDI, OSC)
void error(Component component, Context context, std::source_location location, std::string_view message)
Log an error message and optionally throw an exception.
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, MayaFlux::Journal::InputBackend, m_devices_mutex, m_open_devices, MF_INFO, and MF_WARN.