Skip to content

Commit

Permalink
Added rawmidi to argv
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmoreno committed Oct 21, 2024
1 parent 89cadc8 commit 81a3043
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/argv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,18 @@ static std::vector<argument_t> 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) {
Expand Down
10 changes: 8 additions & 2 deletions src/hwautoannounce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ HwAutoAnnounce::HwAutoAnnounce(std::shared_ptr<aseq_t> 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());
}
});
});

Expand Down
10 changes: 10 additions & 0 deletions tests/test_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 81a3043

Please sign in to comment.