libremidi update to v5.4.3 and added virtual midi out as default

This commit is contained in:
Sebastian
2026-06-23 00:05:41 +02:00
parent dc0003232a
commit 51cd271b6f
166 changed files with 8135 additions and 2009 deletions
+33 -30
View File
@@ -5,11 +5,12 @@
#include <unordered_set>
namespace libremidi
NAMESPACE_LIBREMIDI
{
class observer_jack final
: public observer_api
, private jack_client
, public jack_midi1
, private error_handler
{
public:
@@ -48,8 +49,7 @@ public:
void initial_callback()
{
{
const char** ports
= jack_get_ports(client, nullptr, JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput);
const char** ports = jack_get_ports(client, nullptr, port_type, JackPortIsOutput);
if (ports != nullptr)
{
@@ -70,7 +70,8 @@ public:
{
seen_input_ports.insert(ports[i]);
if (this->configuration.input_added && configuration.notify_in_constructor)
this->configuration.input_added(to_port_info<true>(client, port));
this->configuration.input_added(
to_port_info<true, libremidi::API::JACK_MIDI>(client, port));
}
i++;
}
@@ -80,8 +81,7 @@ public:
}
{
const char** ports
= jack_get_ports(client, nullptr, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput);
const char** ports = jack_get_ports(client, nullptr, port_type, JackPortIsInput);
if (ports != nullptr)
{
@@ -102,7 +102,8 @@ public:
{
seen_output_ports.insert(ports[i]);
if (this->configuration.output_added && configuration.notify_in_constructor)
this->configuration.output_added(to_port_info<false>(client, port));
this->configuration.output_added(
to_port_info<false, libremidi::API::JACK_MIDI>(client, port));
}
i++;
}
@@ -119,7 +120,7 @@ public:
if (reg)
{
std::string_view type = jack_port_type(port);
if (type != JACK_DEFAULT_MIDI_TYPE)
if (type != port_type)
return;
bool physical = flags & JackPortIsPhysical;
@@ -139,13 +140,15 @@ public:
{
seen_input_ports.insert(name);
if (this->configuration.input_added)
this->configuration.input_added(to_port_info<true>(client, port));
this->configuration.input_added(
to_port_info<true, libremidi::API::JACK_MIDI>(client, port));
}
else if (flags & JackPortIsInput)
{
seen_output_ports.insert(name);
if (this->configuration.output_added)
this->configuration.output_added(to_port_info<false>(client, port));
this->configuration.output_added(
to_port_info<false, libremidi::API::JACK_MIDI>(client, port));
}
}
else
@@ -153,13 +156,15 @@ public:
if (auto it = seen_input_ports.find(name); it != seen_input_ports.end())
{
if (this->configuration.input_removed)
this->configuration.input_removed(to_port_info<true>(client, port));
this->configuration.input_removed(
to_port_info<true, libremidi::API::JACK_MIDI>(client, port));
seen_input_ports.erase(it);
}
if (auto it = seen_output_ports.find(name); it != seen_output_ports.end())
{
if (this->configuration.output_removed)
this->configuration.output_removed(to_port_info<false>(client, port));
this->configuration.output_removed(
to_port_info<false, libremidi::API::JACK_MIDI>(client, port));
seen_output_ports.erase(it);
}
}
@@ -172,39 +177,37 @@ public:
if (!configuration.has_callbacks())
return;
jack_set_port_registration_callback(
this->client,
+[](jack_port_id_t p, int r, void* arg) {
auto& self = *(observer_jack*)arg;
if (auto port = jack_port_by_id(self.client, p))
{
self.on_port_callback(port, r != 0);
}
},
this);
jack_set_port_registration_callback(this->client, +[](jack_port_id_t p, int r, void* arg) {
auto& self = *(observer_jack*)arg;
if (auto port = jack_port_by_id(self.client, p))
{
self.on_port_callback(port, r != 0);
}
}, this);
jack_set_port_rename_callback(
this->client,
+[](jack_port_id_t p, const char* /*old_name*/, const char* /*new_name*/, void* arg) {
const auto& self = *static_cast<observer_jack*>(arg);
const auto& self = *static_cast<observer_jack*>(arg);
auto port = jack_port_by_id(self.client, p);
if (!port)
return;
},
this);
auto port = jack_port_by_id(self.client, p);
if (!port)
return;
}, this);
}
libremidi::API get_current_api() const noexcept override { return libremidi::API::JACK_MIDI; }
std::vector<libremidi::input_port> get_input_ports() const noexcept override
{
return get_ports<true>(this->client, nullptr, JackPortIsOutput);
return get_ports<true, libremidi::API::JACK_MIDI>(
this->client, nullptr, port_type, JackPortIsOutput, false);
}
std::vector<libremidi::output_port> get_output_ports() const noexcept override
{
return get_ports<false>(this->client, nullptr, JackPortIsInput);
return get_ports<false, libremidi::API::JACK_MIDI>(
this->client, nullptr, port_type, JackPortIsInput, false);
}
~observer_jack()