Browse Source

Rework pretty-name metadata.

The rawmidi and seqmidi pretty-name metadata now uses the same Jack1
port name as the 1st alias, without the alsa_midi: prefix.
pull/945/head
Albert Graef 1 year ago
parent
commit
c3b6d566af
2 changed files with 14 additions and 7 deletions
  1. +7
    -3
      linux/alsa/alsa_rawmidi.c
  2. +7
    -4
      linux/alsa/alsa_seqmidi.c

+ 7
- 3
linux/alsa/alsa_rawmidi.c View File

@@ -441,6 +441,7 @@ inline int midi_port_open_jack(alsa_rawmidi_t *midi, midi_port_t *port, int type
type | JackPortIsPhysical | JackPortIsTerminal, 0); type | JackPortIsPhysical | JackPortIsTerminal, 0);


// Like in alsa_seqmidi.c, use the Jack1 port name as alias. -ag // Like in alsa_seqmidi.c, use the Jack1 port name as alias. -ag
const char *prefix = "alsa_midi:";
const char* device_name = port->device_name; const char* device_name = port->device_name;
const char* port_name = port->subdev_name; const char* port_name = port->subdev_name;
const char *type_name = (type & JackPortIsOutput) ? "out" : "in"; const char *type_name = (type & JackPortIsOutput) ? "out" : "in";
@@ -448,13 +449,15 @@ inline int midi_port_open_jack(alsa_rawmidi_t *midi, midi_port_t *port, int type
/* entire client name is part of the port name so don't replicate it */ /* entire client name is part of the port name so don't replicate it */
snprintf (name, snprintf (name,
sizeof(name), sizeof(name),
"alsa_midi:%s (%s)",
"%s%s (%s)",
prefix,
port_name, port_name,
type_name); type_name);
} else { } else {
snprintf (name, snprintf (name,
sizeof(name), sizeof(name),
"alsa_midi:%s %s (%s)",
"%s%s %s (%s)",
prefix,
device_name, device_name,
port_name, port_name,
type_name); type_name);
@@ -472,7 +475,8 @@ inline int midi_port_open_jack(alsa_rawmidi_t *midi, midi_port_t *port, int type
// we just ignore the given alias argument, and use the Jack1 // we just ignore the given alias argument, and use the Jack1
// port name from above instead -ag // port name from above instead -ag
jack_port_set_alias(port->jack, name); jack_port_set_alias(port->jack, name);
jack_port_set_default_metadata(port->jack, port->device_name);
// Pretty-name metadata is the same as alias without the prefix.
jack_port_set_default_metadata (port->jack, name+strlen(prefix));
} }


return port->jack == NULL; return port->jack == NULL;


+ 7
- 4
linux/alsa/alsa_seqmidi.c View File

@@ -512,6 +512,7 @@ port_t* port_create(alsa_seqmidi_t *self, int type, snd_seq_addr_t addr, const s
goto failed; goto failed;


// First alias: Jack1-compatible port name. -ag // First alias: Jack1-compatible port name. -ag
const char *prefix = "alsa_midi:";
const char *device_name = snd_seq_client_info_get_name(client_info); const char *device_name = snd_seq_client_info_get_name(client_info);
const char* port_name = snd_seq_port_info_get_name (info); const char* port_name = snd_seq_port_info_get_name (info);
const char* type_name = jack_caps & JackPortIsOutput ? "out" : "in"; const char* type_name = jack_caps & JackPortIsOutput ? "out" : "in";
@@ -520,13 +521,15 @@ port_t* port_create(alsa_seqmidi_t *self, int type, snd_seq_addr_t addr, const s
/* entire client name is part of the port name so don't replicate it */ /* entire client name is part of the port name so don't replicate it */
snprintf (port->name, snprintf (port->name,
sizeof(port->name), sizeof(port->name),
"alsa_midi:%s (%s)",
"%s%s (%s)",
prefix,
port_name, port_name,
type_name); type_name);
} else { } else {
snprintf (port->name, snprintf (port->name,
sizeof(port->name), sizeof(port->name),
"alsa_midi:%s %s (%s)",
"%s%s %s (%s)",
prefix,
device_name, device_name,
port_name, port_name,
type_name); type_name);
@@ -540,7 +543,8 @@ port_t* port_create(alsa_seqmidi_t *self, int type, snd_seq_addr_t addr, const s
} }


jack_port_set_alias (port->jack_port, port->name); jack_port_set_alias (port->jack_port, port->name);
jack_port_set_default_metadata (port->jack_port, device_name);
// Pretty-name metadata is the same as first alias without the prefix.
jack_port_set_default_metadata (port->jack_port, port->name+strlen(prefix));


// Second alias: Strip the alsa_midi prefix, so that devices appear // Second alias: Strip the alsa_midi prefix, so that devices appear
// under their ALSA names. Use the ALSA port names (without device // under their ALSA names. Use the ALSA port names (without device
@@ -562,7 +566,6 @@ port_t* port_create(alsa_seqmidi_t *self, int type, snd_seq_addr_t addr, const s
} }


jack_port_set_alias (port->jack_port, port->name); jack_port_set_alias (port->jack_port, port->name);
jack_port_set_default_metadata (port->jack_port, device_name);


if (type == PORT_INPUT) if (type == PORT_INPUT)
err = alsa_connect_from(self, port->remote.client, port->remote.port); err = alsa_connect_from(self, port->remote.client, port->remote.port);


Loading…
Cancel
Save