aboutsummaryrefslogtreecommitdiffstats
path: root/daemon/src/device_connection.h
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2025-07-24 10:34:13 +0200
committerEddy Pedroni <epedroni@pm.me>2025-07-24 10:34:13 +0200
commit5a40f51085e2132bf91eccdd37e1a8dabe588efd (patch)
treeebd455ce36539cc1ad00e977b0b7cbc095780939 /daemon/src/device_connection.h
parent49880b85de3d18f21792b9333571a396975697a0 (diff)
Rough implementation of autoconnect
Diffstat (limited to 'daemon/src/device_connection.h')
-rw-r--r--daemon/src/device_connection.h32
1 files changed, 3 insertions, 29 deletions
diff --git a/daemon/src/device_connection.h b/daemon/src/device_connection.h
index 17e354d..a2af8cc 100644
--- a/daemon/src/device_connection.h
+++ b/daemon/src/device_connection.h
@@ -41,39 +41,13 @@ struct Device_Connection : public Sender
}
void
- open()
- {
- if (!open_port(midi_in, device_name))
- {
- std::cerr << "Input port not found for device " << device_name << "\n";
- }
-
- if (!open_port(midi_out, device_name))
- {
- std::cerr << "Output port not found for device " << device_name << "\n";
- }
- }
-
- void
- close()
+ reconnect(std::size_t port)
{
midi_in.closePort();
midi_out.closePort();
- }
-private:
- bool
- open_port(RtMidi & midi, std::string const & name)
- {
- for (std::size_t i = 0; i < midi.getPortCount(); ++i)
- {
- if (midi.getPortName(i).contains(name))
- {
- midi.openPort(i);
- return true;
- }
- }
- return false;
+ midi_in.openPort(port);
+ midi_out.openPort(port);
}
};