* Set MIDI port pretty names on macOS * Set MIDI port pretty names on Windows * Set MIDI port pretty names on Linux/alsarawmidi * Update alsarawmidi port naming to match CoreMIDI and WinMME * Rename PortSetPrettyNameProperty to PortSetDeviceName * Set hardware property to MIDI port namestags/v1.9.13
@@ -34,6 +34,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
#include "JackChannel.h" | |||
#include "JackError.h" | |||
extern const char* JACK_METADATA_HARDWARE; | |||
extern const char* JACK_METADATA_PRETTY_NAME; | |||
namespace Jack | |||
{ | |||
@@ -1071,6 +1074,25 @@ int JackEngine::PortRename(int refnum, jack_port_id_t port, const char* name) | |||
return 0; | |||
} | |||
int JackEngine::PortSetDeviceName(jack_port_id_t port, const char* pretty_name) | |||
{ | |||
static const char* type = "text/plain"; | |||
jack_uuid_t uuid = jack_port_uuid_generate(port); | |||
int res = fMetadata.SetProperty(NULL, uuid, JACK_METADATA_HARDWARE, pretty_name, type); | |||
if (res == -1) { | |||
return -1; | |||
} | |||
char *v, *t; | |||
res = fMetadata.GetProperty(uuid, JACK_METADATA_PRETTY_NAME, &v, &t); | |||
if (res == -1) { | |||
res = fMetadata.SetProperty(NULL, uuid, JACK_METADATA_PRETTY_NAME, pretty_name, type); | |||
} | |||
return res; | |||
} | |||
//-------------------- | |||
// Session management | |||
//-------------------- | |||
@@ -138,6 +138,8 @@ class SERVER_EXPORT JackEngine : public JackLockAble | |||
int PortRename(int refnum, jack_port_id_t port, const char* name); | |||
int PortSetDeviceName(jack_port_id_t port, const char* pretty_name); | |||
int ComputeTotalLatencies(); | |||
int PropertyChangeNotify(jack_uuid_t subject, const char* key,jack_property_change_t change); | |||
@@ -48,12 +48,6 @@ extern "C" | |||
LIB_EXPORT int jack_get_client_pid (const char *name); | |||
// Metadata API | |||
LIB_EXPORT const char* JACK_METADATA_PRETTY_NAME = "http://jackaudio.org/metadata/pretty-name"; | |||
LIB_EXPORT const char* JACK_METADATA_HARDWARE = "http://jackaudio.org/metadata/hardware"; | |||
LIB_EXPORT const char* JACK_METADATA_CONNECTED = "http://jackaudio.org/metadata/connected"; | |||
LIB_EXPORT const char* JACK_METADATA_PORT_GROUP = "http://jackaudio.org/metadata/port-group"; | |||
LIB_EXPORT const char* JACK_METADATA_ICON_SMALL = "http://jackaudio.org/metadata/icon-small"; | |||
LIB_EXPORT const char* JACK_METADATA_ICON_LARGE = "http://jackaudio.org/metadata/icon-large"; | |||
LIB_EXPORT int jack_set_property(jack_client_t*, jack_uuid_t subject, const char* key, const char* value, const char* type); | |||
LIB_EXPORT int jack_get_property(jack_uuid_t subject, const char* key, char** value, char** type); | |||
@@ -246,6 +246,14 @@ class SERVER_EXPORT JackLockedEngine | |||
CATCH_EXCEPTION_RETURN | |||
} | |||
int PortSetDeviceName(int refnum, jack_port_id_t port, const char* pretty_name) | |||
{ | |||
TRY_CALL | |||
JackLock lock(&fEngine); | |||
return (fEngine.CheckClient(refnum)) ? fEngine.PortSetDeviceName(port, pretty_name) : -1; | |||
CATCH_EXCEPTION_RETURN | |||
} | |||
int ComputeTotalLatencies() | |||
{ | |||
TRY_CALL | |||
@@ -25,6 +25,14 @@ | |||
#include <limits.h> | |||
LIB_EXPORT const char* JACK_METADATA_PRETTY_NAME = "http://jackaudio.org/metadata/pretty-name"; | |||
LIB_EXPORT const char* JACK_METADATA_HARDWARE = "http://jackaudio.org/metadata/hardware"; | |||
LIB_EXPORT const char* JACK_METADATA_CONNECTED = "http://jackaudio.org/metadata/connected"; | |||
LIB_EXPORT const char* JACK_METADATA_PORT_GROUP = "http://jackaudio.org/metadata/port-group"; | |||
LIB_EXPORT const char* JACK_METADATA_ICON_SMALL = "http://jackaudio.org/metadata/icon-small"; | |||
LIB_EXPORT const char* JACK_METADATA_ICON_LARGE = "http://jackaudio.org/metadata/icon-large"; | |||
namespace Jack | |||
{ | |||
@@ -80,6 +80,8 @@ JackALSARawMidiDriver::Attach() | |||
port = fGraphManager->GetPort(index); | |||
port->SetAlias(alias); | |||
port->SetLatencyRange(JackCaptureLatency, &latency_range); | |||
fEngine->PortSetDeviceName(fClientControl.fRefNum, index, | |||
input_port->GetDeviceName()); | |||
fCapturePortList[i] = index; | |||
jack_info("JackALSARawMidiDriver::Attach - input port registered " | |||
@@ -106,6 +108,8 @@ JackALSARawMidiDriver::Attach() | |||
port = fGraphManager->GetPort(index); | |||
port->SetAlias(alias); | |||
port->SetLatencyRange(JackPlaybackLatency, &latency_range); | |||
fEngine->PortSetDeviceName(fClientControl.fRefNum, index, | |||
output_port->GetDeviceName()); | |||
fPlaybackPortList[i] = index; | |||
jack_info("JackALSARawMidiDriver::Attach - output port registered " | |||
@@ -405,6 +409,7 @@ JackALSARawMidiDriver::Open(bool capturing, bool playing, int in_channels, | |||
} | |||
size_t num_inputs = 0; | |||
size_t num_outputs = 0; | |||
const char *client_name = fClientControl.fName; | |||
if (potential_inputs) { | |||
try { | |||
input_ports = new JackALSARawMidiInputPort *[potential_inputs]; | |||
@@ -428,7 +433,7 @@ JackALSARawMidiDriver::Open(bool capturing, bool playing, int in_channels, | |||
for (size_t i = 0; i < potential_inputs; i++) { | |||
snd_rawmidi_info_t *info = in_info_list.at(i); | |||
try { | |||
input_ports[num_inputs] = new JackALSARawMidiInputPort(info, i); | |||
input_ports[num_inputs] = new JackALSARawMidiInputPort(client_name, info, i); | |||
num_inputs++; | |||
} catch (std::exception& e) { | |||
jack_error("JackALSARawMidiDriver::Open - while creating new " | |||
@@ -439,7 +444,7 @@ JackALSARawMidiDriver::Open(bool capturing, bool playing, int in_channels, | |||
for (size_t i = 0; i < potential_outputs; i++) { | |||
snd_rawmidi_info_t *info = out_info_list.at(i); | |||
try { | |||
output_ports[num_outputs] = new JackALSARawMidiOutputPort(info, i); | |||
output_ports[num_outputs] = new JackALSARawMidiOutputPort(client_name, info, i); | |||
num_outputs++; | |||
} catch (std::exception& e) { | |||
jack_error("JackALSARawMidiDriver::Open - while creating new " | |||
@@ -26,11 +26,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
using Jack::JackALSARawMidiInputPort; | |||
JackALSARawMidiInputPort::JackALSARawMidiInputPort(snd_rawmidi_info_t *info, | |||
JackALSARawMidiInputPort::JackALSARawMidiInputPort(const char* client_name, | |||
snd_rawmidi_info_t *info, | |||
size_t index, | |||
size_t max_bytes, | |||
size_t max_messages): | |||
JackALSARawMidiPort(info, index, POLLIN) | |||
JackALSARawMidiPort(client_name, info, index, POLLIN) | |||
{ | |||
alsa_event = 0; | |||
jack_event = 0; | |||
@@ -41,7 +41,9 @@ namespace Jack { | |||
public: | |||
JackALSARawMidiInputPort(snd_rawmidi_info_t *info, size_t index, | |||
JackALSARawMidiInputPort(const char* client_name, | |||
snd_rawmidi_info_t *info, | |||
size_t index, | |||
size_t max_bytes=4096, | |||
size_t max_messages=1024); | |||
@@ -25,12 +25,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
using Jack::JackALSARawMidiOutputPort; | |||
JackALSARawMidiOutputPort::JackALSARawMidiOutputPort(snd_rawmidi_info_t *info, | |||
JackALSARawMidiOutputPort::JackALSARawMidiOutputPort(const char* client_name, | |||
snd_rawmidi_info_t *info, | |||
size_t index, | |||
size_t max_bytes_per_poll, | |||
size_t max_bytes, | |||
size_t max_messages): | |||
JackALSARawMidiPort(info, index, POLLOUT) | |||
JackALSARawMidiPort(client_name, info, index, POLLOUT) | |||
{ | |||
alsa_event = 0; | |||
read_queue = new JackMidiBufferReadQueue(); | |||
@@ -40,7 +40,9 @@ namespace Jack { | |||
public: | |||
JackALSARawMidiOutputPort(snd_rawmidi_info_t *info, size_t index, | |||
JackALSARawMidiOutputPort(const char* client_name, | |||
snd_rawmidi_info_t *info, | |||
size_t index, | |||
size_t max_bytes_per_poll=3, | |||
size_t max_bytes=4096, | |||
size_t max_messages=1024); | |||
@@ -27,7 +27,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
using Jack::JackALSARawMidiPort; | |||
JackALSARawMidiPort::JackALSARawMidiPort(snd_rawmidi_info_t *info, | |||
JackALSARawMidiPort::JackALSARawMidiPort(const char *client_name, snd_rawmidi_info_t *info, | |||
size_t index, unsigned short io_mask) | |||
{ | |||
int card = snd_rawmidi_info_get_card(info); | |||
@@ -36,20 +36,21 @@ JackALSARawMidiPort::JackALSARawMidiPort(snd_rawmidi_info_t *info, | |||
char device_id[32]; | |||
snprintf(device_id, sizeof(device_id), "hw:%d,%d,%d", card, device, | |||
subdevice); | |||
const char* driver_name = snd_rawmidi_info_get_name(info); | |||
const char *alias_suffix; | |||
const char *error_message; | |||
snd_rawmidi_t **in; | |||
const char *name_prefix; | |||
const char *port_name; | |||
snd_rawmidi_t **out; | |||
if (snd_rawmidi_info_get_stream(info) == SND_RAWMIDI_STREAM_OUTPUT) { | |||
alias_suffix = "out"; | |||
in = 0; | |||
name_prefix = "system:midi_playback_"; | |||
port_name = "playback_"; | |||
out = &rawmidi; | |||
} else { | |||
alias_suffix = "in"; | |||
in = &rawmidi; | |||
name_prefix = "system:midi_capture_"; | |||
port_name = "capture_"; | |||
out = 0; | |||
} | |||
const char *func; | |||
@@ -114,9 +115,10 @@ JackALSARawMidiPort::JackALSARawMidiPort(snd_rawmidi_info_t *info, | |||
goto close; | |||
} | |||
snprintf(alias, sizeof(alias), "system:%d-%d %s %d %s", card + 1, | |||
device + 1, snd_rawmidi_info_get_name(info), subdevice + 1, | |||
device + 1, driver_name, subdevice + 1, | |||
alias_suffix); | |||
snprintf(name, sizeof(name), "%s%zu", name_prefix, index + 1); | |||
snprintf(name, sizeof(name), "%s:%s%zu", client_name, port_name, index + 1); | |||
strncpy(device_name, driver_name, sizeof(device_name) - 1); | |||
this->io_mask = io_mask; | |||
return; | |||
free_params: | |||
@@ -178,6 +180,12 @@ JackALSARawMidiPort::GetName() | |||
return name; | |||
} | |||
const char * | |||
JackALSARawMidiPort::GetDeviceName() | |||
{ | |||
return device_name; | |||
} | |||
int | |||
JackALSARawMidiPort::GetPollDescriptorCount() | |||
{ | |||
@@ -37,6 +37,7 @@ namespace Jack { | |||
int fds[2]; | |||
unsigned short io_mask; | |||
char name[REAL_JACK_PORT_NAME_SIZE+1]; | |||
char device_name[REAL_JACK_PORT_NAME_SIZE+1]; | |||
struct pollfd *queue_poll_fd; | |||
protected: | |||
@@ -60,8 +61,8 @@ namespace Jack { | |||
public: | |||
JackALSARawMidiPort(snd_rawmidi_info_t *info, size_t index, | |||
unsigned short io_mask); | |||
JackALSARawMidiPort(const char *client_name, snd_rawmidi_info_t *info, | |||
size_t index, unsigned short io_mask); | |||
virtual | |||
~JackALSARawMidiPort(); | |||
@@ -72,6 +73,9 @@ namespace Jack { | |||
const char * | |||
GetName(); | |||
const char * | |||
GetDeviceName(); | |||
int | |||
GetPollDescriptorCount(); | |||
@@ -372,6 +372,8 @@ JackCoreMidiDriver::Attach() | |||
port = fGraphManager->GetPort(index); | |||
port->SetAlias(port_obj->GetAlias()); | |||
port->SetLatencyRange(JackCaptureLatency, &latency_range); | |||
fEngine->PortSetDeviceName(fClientControl.fRefNum, index, | |||
port_obj->GetDeviceName()); | |||
fCapturePortList[i] = index; | |||
} | |||
@@ -390,6 +392,8 @@ JackCoreMidiDriver::Attach() | |||
port = fGraphManager->GetPort(index); | |||
port->SetAlias(port_obj->GetAlias()); | |||
port->SetLatencyRange(JackCaptureLatency, &latency_range); | |||
fEngine->PortSetDeviceName(fClientControl.fRefNum, index, | |||
port_obj->GetDeviceName()); | |||
fCapturePortList[num_physical_inputs + i] = index; | |||
} | |||
@@ -415,6 +419,8 @@ JackCoreMidiDriver::Attach() | |||
port = fGraphManager->GetPort(index); | |||
port->SetAlias(port_obj->GetAlias()); | |||
port->SetLatencyRange(JackPlaybackLatency, &latency_range); | |||
fEngine->PortSetDeviceName(fClientControl.fRefNum, index, | |||
port_obj->GetDeviceName()); | |||
fPlaybackPortList[i] = index; | |||
} | |||
@@ -434,6 +440,8 @@ JackCoreMidiDriver::Attach() | |||
port = fGraphManager->GetPort(index); | |||
port->SetAlias(port_obj->GetAlias()); | |||
port->SetLatencyRange(JackPlaybackLatency, &latency_range); | |||
fEngine->PortSetDeviceName(fClientControl.fRefNum, index, | |||
port_obj->GetDeviceName()); | |||
fPlaybackPortList[num_physical_outputs + i] = index; | |||
} | |||
@@ -33,6 +33,7 @@ namespace Jack { | |||
char alias[REAL_JACK_PORT_NAME_SIZE+1]; | |||
char name[REAL_JACK_PORT_NAME_SIZE+1]; | |||
char device_name[REAL_JACK_PORT_NAME_SIZE+1]; | |||
bool initialized; | |||
protected: | |||
@@ -62,7 +63,10 @@ namespace Jack { | |||
const char * | |||
GetName(); | |||
const char * | |||
GetDeviceName(); | |||
static bool IsInternalPort(MIDIObjectRef port_aux); | |||
}; | |||
@@ -65,6 +65,13 @@ JackCoreMidiPort::GetName() | |||
return name; | |||
} | |||
const char * | |||
JackCoreMidiPort::GetDeviceName() | |||
{ | |||
assert(initialized); | |||
return device_name; | |||
} | |||
void | |||
JackCoreMidiPort::Initialize(const char *alias_name, const char *client_name, | |||
const char *driver_name, int index, | |||
@@ -96,6 +103,7 @@ JackCoreMidiPort::Initialize(const char *alias_name, const char *client_name, | |||
} | |||
snprintf(name, sizeof(name), "%s:%s_%d", client_name, | |||
is_output ? "playback" : "capture", num); | |||
strncpy(device_name, endpoint_name, sizeof(device_name) - 1); | |||
this->endpoint = endpoint; | |||
initialized = true; | |||
} |
@@ -71,6 +71,8 @@ JackWinMMEDriver::Attach() | |||
port = fGraphManager->GetPort(index); | |||
port->SetAlias(input_port->GetAlias()); | |||
port->SetLatencyRange(JackCaptureLatency, &latency_range); | |||
fEngine->PortSetDeviceName(fClientControl.fRefNum, index, | |||
input_port->GetDeviceName()); | |||
fCapturePortList[i] = index; | |||
} | |||
@@ -95,6 +97,8 @@ JackWinMMEDriver::Attach() | |||
port = fGraphManager->GetPort(index); | |||
port->SetAlias(output_port->GetAlias()); | |||
port->SetLatencyRange(JackPlaybackLatency, &latency_range); | |||
fEngine->PortSetDeviceName(fClientControl.fRefNum, index, | |||
output_port->GetDeviceName()); | |||
fPlaybackPortList[i] = index; | |||
} | |||
@@ -424,22 +428,3 @@ extern "C" | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
/* | |||
jack_connect system:midi_capture_1 system_midi:playback_1 | |||
jack_connect system:midi_capture_1 system_midi:playback_2 | |||
jack_connect system:midi_capture_1 system_midi:playback_1 | |||
jack_connect system:midi_capture_1 system_midi:playback_1 | |||
jack_connect system:midi_capture_1 system_midi:playback_1 | |||
jack_connect system_midi:capture_1 system:midi_playback_1 | |||
jack_connect system_midi:capture_2 system:midi_playback_1 | |||
jack_connect system_midi:capture_1 system_midi:playback_1 | |||
*/ | |||
@@ -92,6 +92,7 @@ JackWinMMEInputPort::JackWinMMEInputPort(const char *alias_name, | |||
snprintf(alias, sizeof(alias) - 1, "%s:%s:in%d", alias_name, name_tmp, | |||
index + 1); | |||
snprintf(name, sizeof(name) - 1, "%s:capture_%d", client_name, index + 1); | |||
strncpy(device_name, name_tmp, sizeof(device_name) - 1); | |||
jack_event = 0; | |||
started = false; | |||
write_queue_ptr.release(); | |||
@@ -87,6 +87,7 @@ JackWinMMEOutputPort::JackWinMMEOutputPort(const char *alias_name, | |||
snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", alias_name, name_tmp, | |||
index + 1); | |||
snprintf(name, sizeof(name) - 1, "%s:playback_%d", client_name, index + 1); | |||
strncpy(device_name, name_tmp, sizeof(device_name) - 1); | |||
read_queue_ptr.release(); | |||
thread_queue_ptr.release(); | |||
thread_ptr.release(); | |||
@@ -18,7 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
*/ | |||
#include <memory> | |||
#include <stdexcept> | |||
#include <stdexcept> | |||
#include <stdio.h> | |||
#include "JackWinMMEPort.h" | |||
@@ -48,6 +48,12 @@ JackWinMMEPort::GetName() | |||
return name; | |||
} | |||
const char * | |||
JackWinMMEPort::GetDeviceName() | |||
{ | |||
return device_name; | |||
} | |||
void | |||
JackWinMMEPort::GetOSErrorString(LPTSTR text) | |||
{ | |||
@@ -33,6 +33,7 @@ namespace Jack { | |||
char alias[REAL_JACK_PORT_NAME_SIZE+1]; | |||
char name[REAL_JACK_PORT_NAME_SIZE+1]; | |||
char device_name[REAL_JACK_PORT_NAME_SIZE+1]; | |||
public: | |||
@@ -46,6 +47,9 @@ namespace Jack { | |||
const char * | |||
GetName(); | |||
const char * | |||
GetDeviceName(); | |||
void | |||
GetOSErrorString(LPTSTR text); | |||