libremidi update to v5.4.3 and added virtual midi out as default
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <libremidi/backends/linux/dylib_loader.hpp>
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
#include <alsa/asoundlib.h> // IWYU pragma: export
|
||||
|
||||
#if defined(SND_LIB_VERSION)
|
||||
#if __has_include(<alsa/rawmidi.h>) && SND_LIB_VERSION >= ((1 << 16) | (2 << 8) | 6)
|
||||
@@ -13,9 +13,13 @@
|
||||
#if __has_include(<alsa/ump.h>) && SND_LIB_VERSION >= ((1 << 16) | (2 << 8) | 10)
|
||||
#define LIBREMIDI_ALSA_HAS_UMP 1
|
||||
#endif
|
||||
|
||||
#if __has_include(<alsa/ump.h>) && SND_LIB_VERSION >= ((1 << 16) | (2 << 8) | 14)
|
||||
#define LIBREMIDI_ALSA_HAS_UMP_SEQ_EVENTS 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace libremidi
|
||||
NAMESPACE_LIBREMIDI
|
||||
{
|
||||
|
||||
struct libasound
|
||||
@@ -241,6 +245,7 @@ struct libasound
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, client_id)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, client_info_get_client)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, client_info_get_name)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, client_info_get_card)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, client_info_set_client)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, client_info_sizeof)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, close)
|
||||
@@ -277,6 +282,7 @@ struct libasound
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, port_info_sizeof)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, port_subscribe_free)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, port_subscribe_malloc)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, port_subscribe_sizeof)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, port_subscribe_set_dest)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, port_subscribe_set_sender)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, port_subscribe_set_time_real)
|
||||
@@ -291,6 +297,12 @@ struct libasound
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, set_queue_tempo)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, subscribe_port)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, unsubscribe_port)
|
||||
|
||||
#if LIBREMIDI_ALSA_HAS_UMP
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, set_client_midi_version)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, get_ump_endpoint_info)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, get_ump_block_info)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool available{true};
|
||||
@@ -298,6 +310,7 @@ struct libasound
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, client_id)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, client_info_get_client)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, client_info_get_name)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, client_info_get_card)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, client_info_set_client)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, client_info_sizeof)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, close)
|
||||
@@ -334,6 +347,7 @@ struct libasound
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, port_info_sizeof)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, port_subscribe_free)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, port_subscribe_malloc)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, port_subscribe_sizeof)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, port_subscribe_set_dest)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, port_subscribe_set_sender)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, port_subscribe_set_time_real)
|
||||
@@ -350,6 +364,12 @@ struct libasound
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, subscribe_port)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, unsubscribe_port)
|
||||
|
||||
#if LIBREMIDI_ALSA_HAS_UMP
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, set_client_midi_version)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, get_ump_endpoint_info)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, get_ump_block_info)
|
||||
#endif
|
||||
|
||||
#if LIBREMIDI_ALSA_HAS_UMP
|
||||
struct ump_t
|
||||
{
|
||||
@@ -360,7 +380,6 @@ struct libasound
|
||||
available = false;
|
||||
return;
|
||||
}
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq, set_client_midi_version)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq_ump, event_input)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq_ump, event_output)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_seq_ump, event_output_direct)
|
||||
@@ -368,10 +387,10 @@ struct libasound
|
||||
|
||||
bool available{true};
|
||||
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq, set_client_midi_version)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq_ump, event_input)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq_ump, event_output)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_seq_ump, event_output_direct)
|
||||
|
||||
} ump;
|
||||
#endif
|
||||
} seq{library};
|
||||
@@ -387,39 +406,98 @@ struct libasound
|
||||
return;
|
||||
}
|
||||
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_get_name)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_sizeof)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, close)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_name)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_sizeof)
|
||||
// Core UMP functions
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, open)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, poll_descriptors)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, poll_descriptors_count)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, poll_descriptors_revents)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, close)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, rawmidi)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, rawmidi_params)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, rawmidi_params_current)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, read)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, tread)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, write)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, poll_descriptors)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, poll_descriptors_count)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, poll_descriptors_revents)
|
||||
|
||||
// Endpoint info functions
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_sizeof)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_card)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_device)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_flags)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_protocol_caps)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_protocol)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_num_blocks)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_version)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_manufacturer_id)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_family_id)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_model_id)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_sw_revision)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_name)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, endpoint_info_get_product_id)
|
||||
|
||||
// Block info functions
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_sizeof)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_set_block_id)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_get_block_id)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_get_active)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_get_flags)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_get_direction)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_get_first_group)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_get_num_groups)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_get_midi_ci_version)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_get_sysex8_streams)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_get_ui_hint)
|
||||
LIBREMIDI_SYMBOL_INIT(snd_ump, block_info_get_name)
|
||||
}
|
||||
|
||||
bool available{true};
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_get_name)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_sizeof)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, close)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_name)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_sizeof)
|
||||
|
||||
// Core UMP functions
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, open)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, poll_descriptors)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, poll_descriptors_count)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, poll_descriptors_revents)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, close)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, rawmidi)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, rawmidi_params)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, rawmidi_params_current)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, read)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, tread)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, write)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, poll_descriptors)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, poll_descriptors_count)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, poll_descriptors_revents)
|
||||
|
||||
// Endpoint info functions
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_sizeof)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_card)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_device)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_flags)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_protocol_caps)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_protocol)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_num_blocks)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_version)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_manufacturer_id)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_family_id)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_model_id)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_sw_revision)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_name)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, endpoint_info_get_product_id)
|
||||
|
||||
// Block info functions
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_sizeof)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_set_block_id)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_get_block_id)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_get_active)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_get_flags)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_get_direction)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_get_first_group)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_get_num_groups)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_get_midi_ci_version)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_get_sysex8_streams)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_get_ui_hint)
|
||||
LIBREMIDI_SYMBOL_DEF(snd_ump, block_info_get_name)
|
||||
} ump{library};
|
||||
#endif
|
||||
};
|
||||
@@ -447,6 +525,8 @@ struct libasound
|
||||
#define snd_seq_client_info_alloca(ptr) snd_dylib_alloca(ptr, seq, client_info)
|
||||
#undef snd_seq_port_info_alloca
|
||||
#define snd_seq_port_info_alloca(ptr) snd_dylib_alloca(ptr, seq, port_info)
|
||||
#undef snd_seq_port_subscribe_alloca
|
||||
#define snd_seq_port_subscribe_alloca(ptr) snd_dylib_alloca(ptr, seq, port_subscribe)
|
||||
#undef snd_seq_queue_tempo_alloca
|
||||
#define snd_seq_queue_tempo_alloca(ptr) snd_dylib_alloca(ptr, seq, queue_tempo)
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#pragma once
|
||||
#include <libremidi/config.hpp>
|
||||
#if __has_include(<dlfcn.h>)
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace libremidi
|
||||
NAMESPACE_LIBREMIDI
|
||||
{
|
||||
class dylib_loader
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace libremidi
|
||||
NAMESPACE_LIBREMIDI
|
||||
{
|
||||
struct eventfd_notifier
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <pipewire/pipewire.h>
|
||||
|
||||
namespace libremidi
|
||||
NAMESPACE_LIBREMIDI
|
||||
{
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
@@ -12,6 +12,8 @@ namespace libremidi
|
||||
class libpipewire
|
||||
{
|
||||
public:
|
||||
decltype(&::pw_get_library_version) get_library_version{};
|
||||
|
||||
decltype(&::pw_init) init{};
|
||||
decltype(&::pw_deinit) deinit{};
|
||||
|
||||
@@ -67,12 +69,12 @@ public:
|
||||
bool available{true};
|
||||
|
||||
private:
|
||||
dylib_loader library;
|
||||
dylib_loader m_library;
|
||||
|
||||
libpipewire()
|
||||
: library("libpipewire-0.3.so.0")
|
||||
: m_library("libpipewire-0.3.so.0")
|
||||
{
|
||||
if (!library)
|
||||
if (!m_library)
|
||||
{
|
||||
available = false;
|
||||
return;
|
||||
@@ -81,52 +83,59 @@ private:
|
||||
// in terms of regex:
|
||||
// decltype\(&::([a-z_]+)\) [a-z_]+{};
|
||||
// \1 = library.symbol<decltype(&::\1)>("\1");
|
||||
init = library.symbol<decltype(&::pw_init)>("pw_init");
|
||||
deinit = library.symbol<decltype(&::pw_deinit)>("pw_deinit");
|
||||
get_library_version
|
||||
= m_library.symbol<decltype(&::pw_get_library_version)>("pw_get_library_version");
|
||||
|
||||
context_new = library.symbol<decltype(&::pw_context_new)>("pw_context_new");
|
||||
context_connect = library.symbol<decltype(&::pw_context_connect)>("pw_context_connect");
|
||||
context_destroy = library.symbol<decltype(&::pw_context_destroy)>("pw_context_destroy");
|
||||
init = m_library.symbol<decltype(&::pw_init)>("pw_init");
|
||||
deinit = m_library.symbol<decltype(&::pw_deinit)>("pw_deinit");
|
||||
|
||||
core_disconnect = library.symbol<decltype(&::pw_core_disconnect)>("pw_core_disconnect");
|
||||
context_new = m_library.symbol<decltype(&::pw_context_new)>("pw_context_new");
|
||||
context_connect = m_library.symbol<decltype(&::pw_context_connect)>("pw_context_connect");
|
||||
context_destroy = m_library.symbol<decltype(&::pw_context_destroy)>("pw_context_destroy");
|
||||
|
||||
core_disconnect = m_library.symbol<decltype(&::pw_core_disconnect)>("pw_core_disconnect");
|
||||
|
||||
proxy_add_listener
|
||||
= library.symbol<decltype(&::pw_proxy_add_listener)>("pw_proxy_add_listener");
|
||||
proxy_destroy = library.symbol<decltype(&::pw_proxy_destroy)>("pw_proxy_destroy");
|
||||
= m_library.symbol<decltype(&::pw_proxy_add_listener)>("pw_proxy_add_listener");
|
||||
proxy_destroy = m_library.symbol<decltype(&::pw_proxy_destroy)>("pw_proxy_destroy");
|
||||
|
||||
main_loop_new = library.symbol<decltype(&::pw_main_loop_new)>("pw_main_loop_new");
|
||||
main_loop_destroy = library.symbol<decltype(&::pw_main_loop_destroy)>("pw_main_loop_destroy");
|
||||
main_loop_quit = library.symbol<decltype(&::pw_main_loop_quit)>("pw_main_loop_quit");
|
||||
main_loop_run = library.symbol<decltype(&::pw_main_loop_run)>("pw_main_loop_run");
|
||||
main_loop_new = m_library.symbol<decltype(&::pw_main_loop_new)>("pw_main_loop_new");
|
||||
main_loop_destroy
|
||||
= m_library.symbol<decltype(&::pw_main_loop_destroy)>("pw_main_loop_destroy");
|
||||
main_loop_quit = m_library.symbol<decltype(&::pw_main_loop_quit)>("pw_main_loop_quit");
|
||||
main_loop_run = m_library.symbol<decltype(&::pw_main_loop_run)>("pw_main_loop_run");
|
||||
main_loop_get_loop
|
||||
= library.symbol<decltype(&::pw_main_loop_get_loop)>("pw_main_loop_get_loop");
|
||||
= m_library.symbol<decltype(&::pw_main_loop_get_loop)>("pw_main_loop_get_loop");
|
||||
|
||||
properties_new = library.symbol<decltype(&::pw_properties_new)>("pw_properties_new");
|
||||
properties_free = library.symbol<decltype(&::pw_properties_free)>("pw_properties_free");
|
||||
properties_get = library.symbol<decltype(&::pw_properties_get)>("pw_properties_get");
|
||||
properties_new = m_library.symbol<decltype(&::pw_properties_new)>("pw_properties_new");
|
||||
properties_free = m_library.symbol<decltype(&::pw_properties_free)>("pw_properties_free");
|
||||
properties_get = m_library.symbol<decltype(&::pw_properties_get)>("pw_properties_get");
|
||||
|
||||
filter_new_simple = library.symbol<decltype(&::pw_filter_new_simple)>("pw_filter_new_simple");
|
||||
filter_new_simple
|
||||
= m_library.symbol<decltype(&::pw_filter_new_simple)>("pw_filter_new_simple");
|
||||
filter_get_node_id
|
||||
= library.symbol<decltype(&::pw_filter_get_node_id)>("pw_filter_get_node_id");
|
||||
= m_library.symbol<decltype(&::pw_filter_get_node_id)>("pw_filter_get_node_id");
|
||||
filter_get_properties
|
||||
= library.symbol<decltype(&::pw_filter_get_properties)>("pw_filter_get_properties");
|
||||
filter_add_port = library.symbol<decltype(&::pw_filter_add_port)>("pw_filter_add_port");
|
||||
= m_library.symbol<decltype(&::pw_filter_get_properties)>("pw_filter_get_properties");
|
||||
filter_add_port = m_library.symbol<decltype(&::pw_filter_add_port)>("pw_filter_add_port");
|
||||
filter_remove_port
|
||||
= library.symbol<decltype(&::pw_filter_remove_port)>("pw_filter_remove_port");
|
||||
filter_update_properties
|
||||
= library.symbol<decltype(&::pw_filter_update_properties)>("pw_filter_update_properties");
|
||||
= m_library.symbol<decltype(&::pw_filter_remove_port)>("pw_filter_remove_port");
|
||||
filter_update_properties = m_library.symbol<decltype(&::pw_filter_update_properties)>(
|
||||
"pw_filter_update_properties");
|
||||
filter_update_params
|
||||
= library.symbol<decltype(&::pw_filter_update_params)>("pw_filter_update_params");
|
||||
filter_get_time = library.symbol<decltype(&::pw_filter_get_time)>("pw_filter_get_time");
|
||||
filter_destroy = library.symbol<decltype(&::pw_filter_destroy)>("pw_filter_destroy");
|
||||
filter_connect = library.symbol<decltype(&::pw_filter_connect)>("pw_filter_connect");
|
||||
= m_library.symbol<decltype(&::pw_filter_update_params)>("pw_filter_update_params");
|
||||
filter_get_time = m_library.symbol<decltype(&::pw_filter_get_time)>("pw_filter_get_time");
|
||||
filter_destroy = m_library.symbol<decltype(&::pw_filter_destroy)>("pw_filter_destroy");
|
||||
filter_connect = m_library.symbol<decltype(&::pw_filter_connect)>("pw_filter_connect");
|
||||
filter_get_dsp_buffer
|
||||
= library.symbol<decltype(&::pw_filter_get_dsp_buffer)>("pw_filter_get_dsp_buffer");
|
||||
= m_library.symbol<decltype(&::pw_filter_get_dsp_buffer)>("pw_filter_get_dsp_buffer");
|
||||
filter_dequeue_buffer
|
||||
= library.symbol<decltype(&::pw_filter_dequeue_buffer)>("pw_filter_dequeue_buffer");
|
||||
= m_library.symbol<decltype(&::pw_filter_dequeue_buffer)>("pw_filter_dequeue_buffer");
|
||||
filter_queue_buffer
|
||||
= library.symbol<decltype(&::pw_filter_queue_buffer)>("pw_filter_queue_buffer");
|
||||
filter_flush = library.symbol<decltype(&::pw_filter_flush)>("pw_filter_flush");
|
||||
= m_library.symbol<decltype(&::pw_filter_queue_buffer)>("pw_filter_queue_buffer");
|
||||
filter_flush = m_library.symbol<decltype(&::pw_filter_flush)>("pw_filter_flush");
|
||||
|
||||
assert(get_library_version);
|
||||
|
||||
assert(init);
|
||||
assert(deinit);
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#pragma once
|
||||
#include <libremidi/backends/linux/dylib_loader.hpp>
|
||||
#include <libremidi/backends/linux/helpers.hpp>
|
||||
#include <libremidi/observer_configuration.hpp>
|
||||
|
||||
#include <libudev.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <optional>
|
||||
|
||||
namespace libremidi
|
||||
NAMESPACE_LIBREMIDI
|
||||
{
|
||||
|
||||
struct libudev
|
||||
@@ -25,12 +27,28 @@ struct libudev
|
||||
|
||||
LIBREMIDI_SYMBOL_INIT(udev, device_get_action)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, device_get_subsystem)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, device_get_property_value)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, device_new_from_syspath)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, device_get_parent_with_subsystem_devtype)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, device_unref)
|
||||
|
||||
LIBREMIDI_SYMBOL_INIT(udev, monitor_enable_receiving)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, monitor_get_fd)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, monitor_new_from_netlink)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, monitor_receive_device)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, monitor_unref)
|
||||
|
||||
LIBREMIDI_SYMBOL_INIT(udev, enumerate_new)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, enumerate_unref)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, enumerate_add_match_is_initialized)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, enumerate_add_match_subsystem)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, enumerate_add_match_sysname)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, enumerate_scan_devices)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, enumerate_get_list_entry)
|
||||
|
||||
LIBREMIDI_SYMBOL_INIT(udev, list_entry_get_name)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, list_entry_get_next)
|
||||
|
||||
LIBREMIDI_SYMBOL_INIT2(udev, new, create)
|
||||
LIBREMIDI_SYMBOL_INIT(udev, unref)
|
||||
}
|
||||
@@ -46,12 +64,28 @@ struct libudev
|
||||
|
||||
LIBREMIDI_SYMBOL_DEF(udev, device_get_action)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, device_get_subsystem)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, device_new_from_syspath)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, device_get_property_value)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, device_get_parent_with_subsystem_devtype)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, device_unref)
|
||||
|
||||
LIBREMIDI_SYMBOL_DEF(udev, monitor_enable_receiving)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, monitor_get_fd)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, monitor_new_from_netlink)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, monitor_receive_device)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, monitor_unref)
|
||||
|
||||
LIBREMIDI_SYMBOL_DEF(udev, enumerate_new)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, enumerate_unref)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, enumerate_add_match_is_initialized)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, enumerate_add_match_subsystem)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, enumerate_add_match_sysname)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, enumerate_scan_devices)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, enumerate_get_list_entry)
|
||||
|
||||
LIBREMIDI_SYMBOL_DEF(udev, list_entry_get_name)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, list_entry_get_next)
|
||||
|
||||
LIBREMIDI_SYMBOL_DEF2(udev, new, create)
|
||||
LIBREMIDI_SYMBOL_DEF(udev, unref)
|
||||
};
|
||||
@@ -89,4 +123,107 @@ struct udev_helper
|
||||
udev_monitor* monitor{};
|
||||
};
|
||||
|
||||
struct udev_enumerator
|
||||
{
|
||||
explicit udev_enumerator(const udev_helper& h)
|
||||
: helper{h}
|
||||
{
|
||||
auto& udev = helper.udev;
|
||||
auto& instance = helper.instance;
|
||||
enumerator = udev.enumerate_new(instance);
|
||||
assert(enumerator);
|
||||
}
|
||||
|
||||
~udev_enumerator()
|
||||
{
|
||||
auto& udev = helper.udev;
|
||||
udev.enumerate_unref(enumerator);
|
||||
}
|
||||
|
||||
const udev_helper& helper;
|
||||
udev_enumerate* enumerator{};
|
||||
operator udev_enumerate*() const noexcept { return enumerator; }
|
||||
};
|
||||
|
||||
struct udev_soundcard_info
|
||||
{
|
||||
container_identifier container;
|
||||
device_identifier path;
|
||||
transport_type type{};
|
||||
std::string vendor;
|
||||
std::string product;
|
||||
std::string serial;
|
||||
};
|
||||
|
||||
inline udev_soundcard_info get_udev_soundcard_info(const udev_helper& helper, int card)
|
||||
{
|
||||
auto& udev = helper.udev;
|
||||
udev_enumerator e{helper};
|
||||
udev.enumerate_add_match_subsystem(e, "sound");
|
||||
udev.enumerate_add_match_sysname(e, ("controlC" + std::to_string(card)).c_str());
|
||||
if (udev.enumerate_scan_devices(e) != 0)
|
||||
return {};
|
||||
|
||||
for (auto entry = udev.enumerate_get_list_entry(e); entry;
|
||||
entry = udev.list_entry_get_next(entry))
|
||||
{
|
||||
auto path = udev.list_entry_get_name(entry);
|
||||
if (!path)
|
||||
continue;
|
||||
|
||||
auto dev = udev.device_new_from_syspath(helper.instance, path);
|
||||
if (!dev)
|
||||
continue;
|
||||
|
||||
const auto usb_device
|
||||
= udev.device_get_parent_with_subsystem_devtype(dev, "usb", "usb_device");
|
||||
const auto pci_device = udev.device_get_parent_with_subsystem_devtype(dev, "pci", nullptr);
|
||||
|
||||
transport_type type = transport_type::hardware;
|
||||
if (usb_device)
|
||||
type = (transport_type)(type | transport_type::usb);
|
||||
else if (pci_device)
|
||||
type = (transport_type)(type | transport_type::pci);
|
||||
|
||||
auto id_path = udev.device_get_property_value(dev, "ID_PATH");
|
||||
if (!id_path)
|
||||
id_path = "";
|
||||
|
||||
auto read_property = [&](const char* property) {
|
||||
auto res = udev.device_get_property_value(dev, property);
|
||||
if (!res)
|
||||
res = "";
|
||||
if (strlen(res) == 0)
|
||||
{
|
||||
if (usb_device)
|
||||
{
|
||||
res = udev.device_get_property_value(usb_device, property);
|
||||
if (!res)
|
||||
res = "";
|
||||
}
|
||||
else if (pci_device)
|
||||
{
|
||||
res = udev.device_get_property_value(pci_device, property);
|
||||
if (!res)
|
||||
res = "";
|
||||
}
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
auto id_vendor = read_property("ID_VENDOR_FROM_DATABASE");
|
||||
auto id_product = read_property("ID_MODEL_FROM_DATABASE");
|
||||
auto id_serial = read_property("ID_SERIAL");
|
||||
auto ret = udev_soundcard_info{
|
||||
.container = id_path,
|
||||
.path = path,
|
||||
.type = type,
|
||||
.vendor = id_vendor,
|
||||
.product = id_product,
|
||||
.serial = id_serial};
|
||||
udev.device_unref(dev);
|
||||
return ret;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user