implement pretty-name set-property for ALSA and Dummy

This commit is contained in:
Robin Gareus 2016-04-17 18:22:21 +02:00
parent 1f43878050
commit 10140a8e68
5 changed files with 76 additions and 0 deletions

View File

@ -1243,6 +1243,20 @@ AlsaAudioBackend::get_port_property (PortHandle port, const std::string& key, st
return -1;
}
int
AlsaAudioBackend::set_port_property (PortHandle port, const std::string& key, const std::string& value, const std::string& type)
{
if (!valid_port (port)) {
PBD::warning << _("AlsaBackend::set_port_property: Invalid Port(s)") << endmsg;
return -1;
}
if (key == "http://jackaudio.org/metadata/pretty-name" && type.empty ()) {
static_cast<AlsaPort*>(port)->set_pretty_name (value);
return 0;
}
return -1;
}
PortEngine::PortHandle
AlsaAudioBackend::get_port_by_name (const std::string& name) const
{

View File

@ -266,7 +266,9 @@ class AlsaAudioBackend : public AudioBackend {
int set_port_name (PortHandle, const std::string&);
std::string get_port_name (PortHandle) const;
PortHandle get_port_by_name (const std::string&) const;
int get_port_property (PortHandle, const std::string& key, std::string& value, std::string& type) const;
int set_port_property (PortHandle, const std::string& key, const std::string& value, const std::string& type);
int get_ports (const std::string& port_name_pattern, DataType type, PortFlags flags, std::vector<std::string>&) const;

View File

@ -659,6 +659,38 @@ DummyAudioBackend::get_port_name (PortEngine::PortHandle port) const
return static_cast<DummyPort*>(port)->name ();
}
int
DummyAudioBackend::get_port_property (PortHandle port, const std::string& key, std::string& value, std::string& type) const
{
if (!valid_port (port)) {
PBD::warning << _("DummyBackend::get_port_property: Invalid Port(s)") << endmsg;
return -1;
}
if (key == "http://jackaudio.org/metadata/pretty-name") {
type = "";
value = static_cast<DummyPort*>(port)->pretty_name ();
if (!value.empty()) {
return 0;
}
}
return -1;
}
int
DummyAudioBackend::set_port_property (PortHandle port, const std::string& key, const std::string& value, const std::string& type)
{
if (!valid_port (port)) {
PBD::warning << _("DummyBackend::set_port_property: Invalid Port(s)") << endmsg;
return -1;
}
if (key == "http://jackaudio.org/metadata/pretty-name" && type.empty ()) {
static_cast<DummyPort*>(port)->set_pretty_name (value);
return 0;
}
return -1;
}
PortEngine::PortHandle
DummyAudioBackend::get_port_by_name (const std::string& name) const
{
@ -843,6 +875,7 @@ DummyAudioBackend::register_system_ports()
_system_midi_in.push_back (static_cast<DummyMidiPort*>(p));
if (_midi_mode == MidiGenerator) {
static_cast<DummyMidiPort*>(p)->setup_generator (i % NUM_MIDI_EVENT_GENERATORS, _samplerate);
static_cast<DummyMidiPort*>(p)->set_pretty_name (DummyMidiData::sequence_names[i % NUM_MIDI_EVENT_GENERATORS]);
}
}
@ -854,6 +887,17 @@ DummyAudioBackend::register_system_ports()
if (!p) return -1;
set_latency_range (p, true, lr);
_system_midi_out.push_back (static_cast<DummyMidiPort*>(p));
if (_device == _("Loopback") && _midi_mode == MidiToAudio) {
std::stringstream ss;
ss << "Midi2Audio";
for (int apc = 0; apc < (int)_system_inputs.size(); ++apc) {
if ((apc % m_out) + 1 == i) {
ss << " >" << (apc + 1);
}
}
static_cast<DummyMidiPort*>(p)->set_pretty_name (ss.str());
}
}
return 0;
}

View File

@ -72,9 +72,11 @@ class DummyPort {
virtual ~DummyPort ();
const std::string& name () const { return _name; }
const std::string& pretty_name () const { return _pretty_name; }
PortFlags flags () const { return _flags; }
int set_name (const std::string &name) { _name = name; return 0; }
int set_pretty_name (const std::string &name) { _pretty_name = name; return 0; }
virtual DataType type () const = 0;
@ -115,6 +117,7 @@ class DummyPort {
private:
DummyAudioBackend &_dummy_backend;
std::string _name;
std::string _pretty_name;
const PortFlags _flags;
LatencyRange _capture_latency_range;
LatencyRange _playback_latency_range;
@ -321,6 +324,9 @@ class DummyAudioBackend : public AudioBackend {
std::string get_port_name (PortHandle) const;
PortHandle get_port_by_name (const std::string&) const;
int get_port_property (PortHandle, const std::string& key, std::string& value, std::string& type) const;
int set_port_property (PortHandle, const std::string& key, const std::string& value, const std::string& type);
int get_ports (const std::string& port_name_pattern, DataType type, PortFlags flags, std::vector<std::string>&) const;
DataType port_data_type (PortHandle) const;

View File

@ -770,6 +770,16 @@ static const MIDISequence *sequences[] = {
s0, s1, s2, s3, s4, s5, s6
};
static const char *sequence_names[] = {
"Short Sequence",
"Cmaj7, all channels",
"Note Sweep, chan 1",
"Velocity Sweep, chan 1",
"Sustain Pedal Test",
"CCs only",
"Nonsense, Dups"
};
}} // namespace
#define NUM_MIDI_EVENT_GENERATORS (sizeof (ARDOUR::DummyMidiData::sequences) / sizeof(ARDOUR::DummyMidiData::MIDISequence*))