alsa-seq: add an option to disable longname in MIDI ports

Untested yet

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>
This commit is contained in:
Dmitry Sharshakov 2022-09-10 20:55:05 +03:00 committed by Wim Taymans
parent ea646c2d98
commit 3b89e6f369
3 changed files with 9 additions and 3 deletions

View file

@ -62,6 +62,8 @@ extern "C" {
#define SPA_KEY_API_ALSA_USE_UCM "api.alsa.use-ucm" /**< if UCM should be used */ #define SPA_KEY_API_ALSA_USE_UCM "api.alsa.use-ucm" /**< if UCM should be used */
#define SPA_KEY_API_ALSA_IGNORE_DB "api.alsa.ignore-dB" /**< if decibel info should be ignored */ #define SPA_KEY_API_ALSA_IGNORE_DB "api.alsa.ignore-dB" /**< if decibel info should be ignored */
#define SPA_KEY_API_ALSA_OPEN_UCM "api.alsa.open.ucm" /**< if UCM should be opened card */ #define SPA_KEY_API_ALSA_OPEN_UCM "api.alsa.open.ucm" /**< if UCM should be opened card */
#define SPA_KEY_API_ALSA_DISABLE_LONGNAME \
"api.alsa.disable-longname" /**< if card long name should not be passed to MIDI port */
/** info from alsa card_info */ /** info from alsa card_info */
#define SPA_KEY_API_ALSA_CARD_ID "api.alsa.card.id" /**< id from card_info */ #define SPA_KEY_API_ALSA_CARD_ID "api.alsa.card.id" /**< id from card_info */

View file

@ -48,6 +48,7 @@ static void reset_props(struct props *props)
{ {
strncpy(props->device, DEFAULT_DEVICE, sizeof(props->device)); strncpy(props->device, DEFAULT_DEVICE, sizeof(props->device));
strncpy(props->clock_name, DEFAULT_CLOCK_NAME, sizeof(props->clock_name)); strncpy(props->clock_name, DEFAULT_CLOCK_NAME, sizeof(props->clock_name));
props->disable_longname = 0;
} }
static int impl_node_enum_params(void *object, int seq, static int impl_node_enum_params(void *object, int seq,
@ -261,10 +262,10 @@ static void emit_port_info(struct seq_state *this, struct seq_port *port, bool f
snd_seq_get_any_client_info(this->sys.hndl, snd_seq_get_any_client_info(this->sys.hndl,
port->addr.client, client_info); port->addr.client, client_info);
int card_id = snd_seq_client_info_get_card(client_info); int card_id;
// Failed to obtain card number (software device) // Failed to obtain card number (software device) or disabled
if (card_id < 0) { if (this->props.disable_longname || (card_id = snd_seq_client_info_get_card(client_info)) < 0) {
snprintf(name, sizeof(name), "%s:(%s_%d) %s", snprintf(name, sizeof(name), "%s:(%s_%d) %s",
snd_seq_client_info_get_name(client_info), snd_seq_client_info_get_name(client_info),
port->direction == SPA_DIRECTION_OUTPUT ? "capture" : "playback", port->direction == SPA_DIRECTION_OUTPUT ? "capture" : "playback",
@ -950,6 +951,8 @@ impl_init(const struct spa_handle_factory *factory,
} else if (spa_streq(k, "clock.name")) { } else if (spa_streq(k, "clock.name")) {
spa_scnprintf(this->props.clock_name, spa_scnprintf(this->props.clock_name,
sizeof(this->props.clock_name), "%s", s); sizeof(this->props.clock_name), "%s", s);
} else if (spa_streq(k, SPA_KEY_API_ALSA_DISABLE_LONGNAME)) {
this->props.disable_longname = spa_atob(s);
} }
} }

View file

@ -52,6 +52,7 @@ extern "C" {
struct props { struct props {
char device[64]; char device[64];
char clock_name[64]; char clock_name[64];
bool disable_longname;
}; };
#define MAX_EVENT_SIZE 1024 #define MAX_EVENT_SIZE 1024