Skip to content

Commit

Permalink
Improved use of cmd arg name.
Browse files Browse the repository at this point in the history
Removed some really unused setting vars
  • Loading branch information
davidmoreno committed Dec 21, 2023
1 parent df26e40 commit b7f7977
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 24 deletions.
4 changes: 2 additions & 2 deletions cli/rtpmidid-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,13 @@ def get_local_name(self, data):
type_ = safe_get(data, "type")
if type_.startswith("local:"):
return safe_get(data, "name")
return safe_get(data, "peer", "local", "name")
return ""

def get_remote_name(self, data):
type_ = safe_get(data, "type")
if type_.startswith("network:"):
return safe_get(data, "name")
return safe_get(data, "peer", "remote", "name")
return ""

##
## Top level components
Expand Down
2 changes: 1 addition & 1 deletion default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ port=5004
# ports for each connection. If you want to not have an alsa_announce
# section, comment it out or delete it.
[alsa_announce]
# Name for the ALSA connection so that when a conneciton is made, an rtpmidi
# Name for the ALSA connection so that when a connection is made, an rtpmidi
# is announced.
name=Network Export

Expand Down
4 changes: 1 addition & 3 deletions src/argv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ void parse_argv(int argc, char **argv) {

settings.rtpmidi_announces.begin()->name = value;
settings.alsa_announces.begin()->name = value;
settings.alsa_name = value;
});
arguments.emplace_back( //
"--alsa-name", //
Expand Down Expand Up @@ -206,9 +207,6 @@ void parse_argv(int argc, char **argv) {
}
}

if (settings.rtpmidid_name == "") {
settings.rtpmidid_name = get_hostname();
}
DEBUG("settings after argument parsing: {}", settings);
}

Expand Down
2 changes: 0 additions & 2 deletions src/control_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ std::vector<control_socket_ns::command_t> commands{
{"settings",
{
{"alsa_name", rtpmididns::settings.alsa_name},
{"rtpmidid_name", rtpmididns::settings.rtpmidid_name},
{"rtpmidid_port", rtpmididns::settings.rtpmidid_port},
{"control_filename", rtpmididns::settings.control_filename} //
}},
{"router", control.router->status()} //
Expand Down
2 changes: 1 addition & 1 deletion src/network_rtpmidi_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ network_rtpmidi_peer_t::~network_rtpmidi_peer_t() {}

void network_rtpmidi_peer_t::send_midi(midipeer_id_t from,
const mididata_t &data) {
DEBUG("Send midi: {}", data.size());
// DEBUG("Send midi: {}", data.size());
peer->send_midi(data);
};

Expand Down
17 changes: 7 additions & 10 deletions src/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ namespace rtpmididns {
struct settings_t {
std::string alsa_name = "rtpmidid";
bool alsa_network = true;
std::string rtpmidid_name = "";
std::string rtpmidid_port = "5004";
std::string control_filename = "/var/run/rtpmidid/control.sock";

// Datas a read from the ini file
Expand Down Expand Up @@ -137,13 +135,12 @@ template <>
struct fmt::formatter<rtpmididns::settings_t> : formatter<std::string_view> {
auto format(const rtpmididns::settings_t &data, format_context &ctx) {

return fmt::format_to(
ctx.out(),
"[settings_t alsa_name: {} alsa_network: {} rtpmidid_name: {} "
"rtpmidid_port: {} control_filename: {} rtpmidi_announces: {} "
"alsa_announces: {} connect_to: {}]",
data.alsa_name, data.alsa_network, data.rtpmidid_name,
data.rtpmidid_port, data.control_filename, data.rtpmidi_announces,
data.alsa_announces, data.connect_to);
return fmt::format_to(ctx.out(),
"[settings_t alsa_name: {} alsa_network: {} "
"control_filename: {} rtpmidi_announces: {} "
"alsa_announces: {} connect_to: {}]",
data.alsa_name, data.alsa_network,
data.control_filename, data.rtpmidi_announces,
data.alsa_announces, data.connect_to);
}
};
9 changes: 4 additions & 5 deletions tests/test_midirouter2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void test_send_receive_messages() {
uint8_t test_client_id;
{
rtpmididns::settings.alsa_name = "rtpmidid-test";
rtpmididns::settings.rtpmidid_name = "rtpmidid-test";
rtpmididns::settings.rtpmidid_port = "60004";
// rtpmididns::settings.rtpmidid_name = "rtpmidid-test";
// rtpmididns::settings.rtpmidid_port = "60004";

auto aseq =
std::make_shared<rtpmididns::aseq_t>(rtpmididns::settings.alsa_name);
Expand All @@ -56,8 +56,7 @@ void test_send_receive_messages() {
rtpmididns::settings.alsa_name, aseq));

router->add_peer(rtpmididns::make_network_rtpmidi_multi_listener(
rtpmididns::settings.rtpmidid_name, rtpmididns::settings.rtpmidid_port,
aseq));
"rtpmidid-test", "60004", aseq));
}

// Now I prepare another local port that will be use dfor communication,
Expand Down Expand Up @@ -140,7 +139,7 @@ void test_send_receive_messages() {
uint8_t device_id = aseq->find_device(rtpmididns::settings.alsa_name);

auto rtppeer_client_b = rtpmidid::rtpclient_t("RTPPEER B");
rtppeer_client_b.connect_to("localhost", rtpmididns::settings.rtpmidid_port);
rtppeer_client_b.connect_to("localhost", "60004");
poller_wait_until([&rtppeer_client_b]() {
return rtppeer_client_b.peer.status ==
rtpmidid::rtppeer_t::status_e::CONNECTED;
Expand Down

0 comments on commit b7f7977

Please sign in to comment.