working on win32 uwp! and libremidi update

This commit is contained in:
Sebastian @ HfG
2024-10-28 19:24:18 +01:00
parent 06cb6d8319
commit 1e3755148c
106 changed files with 8474 additions and 2198 deletions
@@ -2,6 +2,7 @@
#include <libremidi/backends/alsa_seq/config.hpp>
#include <libremidi/backends/alsa_seq/helpers.hpp>
#include <libremidi/backends/linux/helpers.hpp>
#include <libremidi/detail/midi_api.hpp>
#include <libremidi/detail/observer.hpp>
#include <alsa/asoundlib.h>
@@ -26,6 +27,7 @@ template <typename ConfigurationImpl>
class observer_impl
: public observer_api
, public alsa_data
, public error_handler
{
public:
struct
@@ -40,7 +42,11 @@ public:
using namespace std::literals;
if (int err = init_client(configuration); err < 0)
{
throw driver_error("observer_alsa: snd_seq_open failed");
libremidi_handle_error(
this->configuration,
"error creating ALSA sequencer client "
"object.");
return;
}
if (!configuration.has_callbacks())
@@ -65,7 +71,8 @@ public:
*this, "libremidi-observe", caps, SND_SEQ_PORT_TYPE_APPLICATION, false);
if (err < 0)
{
throw driver_error("observer: ALSA error creating port.");
libremidi_handle_error(this->configuration, "error creating ALSA sequencer port.");
return;
}
}
@@ -75,7 +82,8 @@ public:
= snd.seq.connect_from(seq, vport, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_ANNOUNCE);
if (err < 0)
{
throw driver_error("observer_alsa: snd_seq_connect_from failed");
libremidi_handle_error(this->configuration, "error connecting to ALSA sequencer.");
return;
}
}
}
@@ -98,9 +106,13 @@ public:
const auto tp = snd.seq.port_info_get_type(pinfo);
bool ok = this->configuration.track_any;
static constexpr auto virtual_port
= SND_SEQ_PORT_TYPE_SOFTWARE | SND_SEQ_PORT_TYPE_SYNTHESIZER;
if ((tp & SND_SEQ_PORT_TYPE_HARDWARE) && this->configuration.track_hardware)
ok = true;
else if ((tp & SND_SEQ_PORT_TYPE_SOFTWARE) && this->configuration.track_virtual)
else if ((tp & virtual_port) && this->configuration.track_virtual)
ok = true;
if (!ok)
return {};
@@ -271,9 +283,12 @@ public:
// Start the listening thread
thread = std::thread{[this] {
auto& snd = alsa_data::snd;
const auto period
= std::chrono::duration_cast<std::chrono::milliseconds>(this->configuration.poll_period)
.count();
for (;;)
{
int err = poll(descriptors_.data(), descriptors_.size(), -1);
int err = poll(descriptors_.data(), descriptors_.size(), period);
if (err >= 0)
{
// We got our stop-thread signal