From 81a3043a837018145f7e7c44783248bea49082f0 Mon Sep 17 00:00:00 2001 From: David Moreno Date: Mon, 21 Oct 2024 23:21:21 +0200 Subject: [PATCH] Added rawmidi to argv --- src/argv.cpp | 12 ++++++++++++ src/hwautoannounce.cpp | 10 ++++++++-- tests/test_settings.cpp | 10 ++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/argv.cpp b/src/argv.cpp index 1ef5934..4f035a1 100644 --- a/src/argv.cpp +++ b/src/argv.cpp @@ -175,6 +175,18 @@ static std::vector setup_arguments(settings_t *settings) { settings->rtpmidi_discover.name_positive_regex = std::regex(value); } }); + arguments.emplace_back( // + "--rawmidi", + "Connects to a rawmidi device. For example `/dev/snd/midiC1D0`", + [settings](const std::string &value) { + if (value.size() == 0) { + ERROR("Empty rawmidi device. Doing nothing."); + return; + } + settings->rawmidi.emplace_back(); + settings->rawmidi.back().device = value; + settings->rawmidi.back().name = rtpmididns::split(value, '/').back(); + }); arguments.emplace_back( // "--version", // "Show version", [settings](const std::string &value) { diff --git a/src/hwautoannounce.cpp b/src/hwautoannounce.cpp index 6291bc1..e824065 100644 --- a/src/hwautoannounce.cpp +++ b/src/hwautoannounce.cpp @@ -45,8 +45,14 @@ HwAutoAnnounce::HwAutoAnnounce(std::shared_ptr aseq, // {}:{} // ", // device_name, port_name, device_id, port_id); - added_port_announcement(device_name, type, - aseq_t::port_t{device_id, port_id}); + try { + added_port_announcement(device_name, type, + aseq_t::port_t{device_id, port_id}); + + } catch (const std::exception &e) { + ERROR("Error adding port announcement {}:{} {}:{} exception={}", + device_name, port_name, device_id, port_id, e.what()); + } }); }); diff --git a/tests/test_settings.cpp b/tests/test_settings.cpp index b6b0708..9896c54 100644 --- a/tests/test_settings.cpp +++ b/tests/test_settings.cpp @@ -174,6 +174,16 @@ void test_argv(void) { "--version", }, &settings); + + settings.rawmidi.clear(); + + // Bugfixes + rtpmididns::parse_argv( + { + "--rawmidi=", + }, + &settings); + ASSERT_EQUAL(settings.rawmidi.size(), 0); } int main(int argc, char **argv) {