mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
audio_backend: Get name of standard device directly, without unnecessary enum StandardDeviceName
The StandardDeviceName enum was misleadingly *not* the name - the name only came from get_standard_device_name. Instead, simplify things, and just use two different trivial getters.
This commit is contained in:
parent
29e71b5c82
commit
a3ac3c7201
9 changed files with 53 additions and 62 deletions
|
|
@ -1146,7 +1146,7 @@ EngineControl::get_default_device (const string& current_device_name,
|
|||
using namespace ARDOUR;
|
||||
|
||||
string default_device_name =
|
||||
AudioBackend::get_standard_device_name (AudioBackend::DeviceDefault);
|
||||
AudioBackend::get_default_device_name ();
|
||||
|
||||
vector<string>::const_iterator i;
|
||||
|
||||
|
|
@ -1158,7 +1158,7 @@ EngineControl::get_default_device (const string& current_device_name,
|
|||
}
|
||||
|
||||
string none_device_name =
|
||||
AudioBackend::get_standard_device_name (AudioBackend::DeviceNone);
|
||||
AudioBackend::get_none_device_name ();
|
||||
|
||||
// Use the first device that isn't "None"
|
||||
for (i = available_devices.begin (); i != available_devices.end (); ++i) {
|
||||
|
|
@ -1581,7 +1581,7 @@ EngineControl::input_device_changed ()
|
|||
|
||||
std::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance ()->current_backend ();
|
||||
if (backend && backend->match_input_output_devices_or_none ()) {
|
||||
const std::string& dev_none = ARDOUR::AudioBackend::get_standard_device_name (ARDOUR::AudioBackend::DeviceNone);
|
||||
const std::string& dev_none = ARDOUR::AudioBackend::get_none_device_name ();
|
||||
|
||||
if (get_output_device_name () != dev_none && get_input_device_name () != dev_none && get_input_device_name () != get_output_device_name ()) {
|
||||
block_changed_signals ();
|
||||
|
|
@ -1603,7 +1603,7 @@ EngineControl::output_device_changed ()
|
|||
DEBUG_ECONTROL ("output_device_changed");
|
||||
std::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance ()->current_backend ();
|
||||
if (backend && backend->match_input_output_devices_or_none ()) {
|
||||
const std::string& dev_none = ARDOUR::AudioBackend::get_standard_device_name (ARDOUR::AudioBackend::DeviceNone);
|
||||
const std::string& dev_none = ARDOUR::AudioBackend::get_none_device_name ();
|
||||
|
||||
if (get_input_device_name () != dev_none && get_input_device_name () != dev_none && get_input_device_name () != get_output_device_name ()) {
|
||||
block_changed_signals ();
|
||||
|
|
|
|||
|
|
@ -131,12 +131,8 @@ public:
|
|||
|
||||
static std::string get_error_string (ErrorCode);
|
||||
|
||||
enum StandardDeviceName {
|
||||
DeviceNone,
|
||||
DeviceDefault
|
||||
};
|
||||
|
||||
static std::string get_standard_device_name (StandardDeviceName);
|
||||
static std::string get_none_device_name ();
|
||||
static std::string get_default_device_name ();
|
||||
|
||||
/** Return the AudioBackendInfo object from which this backend
|
||||
* was constructed.
|
||||
|
|
@ -232,7 +228,7 @@ public:
|
|||
* of allowing one to be "None".
|
||||
*
|
||||
* ie. Input Device must match Output Device, except if either of them
|
||||
* is get_standard_device_name (DeviceNone).
|
||||
* is get_none_device_name ().
|
||||
*/
|
||||
virtual bool match_input_output_devices_or_none () const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -100,15 +100,15 @@ AudioBackend::get_error_string (ErrorCode error_code)
|
|||
}
|
||||
|
||||
std::string
|
||||
AudioBackend::get_standard_device_name (StandardDeviceName device_name)
|
||||
AudioBackend::get_none_device_name ()
|
||||
{
|
||||
switch (device_name) {
|
||||
case DeviceNone:
|
||||
return _("None");
|
||||
case DeviceDefault:
|
||||
return _("Default");
|
||||
}
|
||||
return std::string();
|
||||
return _("None");
|
||||
}
|
||||
|
||||
std::string
|
||||
AudioBackend::get_default_device_name ()
|
||||
{
|
||||
return _("Default");
|
||||
}
|
||||
|
||||
} // namespace ARDOUR
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ AlsaAudioBackend::enumerate_input_devices () const
|
|||
_input_audio_device_status.clear ();
|
||||
std::map<std::string, std::string> devices;
|
||||
get_alsa_audio_device_names (devices, HalfDuplexIn);
|
||||
_input_audio_device_status.push_back (DeviceStatus (get_standard_device_name (DeviceNone), true));
|
||||
_input_audio_device_status.push_back (DeviceStatus (get_none_device_name (), true));
|
||||
for (std::map<std::string, std::string>::const_iterator i = devices.begin (); i != devices.end (); ++i) {
|
||||
if (_input_audio_device == "") {
|
||||
_input_audio_device = i->first;
|
||||
|
|
@ -145,7 +145,7 @@ AlsaAudioBackend::enumerate_output_devices () const
|
|||
_output_audio_device_status.clear ();
|
||||
std::map<std::string, std::string> devices;
|
||||
get_alsa_audio_device_names (devices, HalfDuplexOut);
|
||||
_output_audio_device_status.push_back (DeviceStatus (get_standard_device_name (DeviceNone), true));
|
||||
_output_audio_device_status.push_back (DeviceStatus (get_none_device_name (), true));
|
||||
for (std::map<std::string, std::string>::const_iterator i = devices.begin (); i != devices.end (); ++i) {
|
||||
if (_output_audio_device == "") {
|
||||
_output_audio_device = i->first;
|
||||
|
|
@ -159,11 +159,11 @@ std::vector<float>
|
|||
AlsaAudioBackend::available_sample_rates2 (const std::string& input_device, const std::string& output_device) const
|
||||
{
|
||||
std::vector<float> sr;
|
||||
if (input_device == get_standard_device_name (DeviceNone) && output_device == get_standard_device_name (DeviceNone)) {
|
||||
if (input_device == get_none_device_name () && output_device == get_none_device_name ()) {
|
||||
return sr;
|
||||
} else if (input_device == get_standard_device_name (DeviceNone)) {
|
||||
} else if (input_device == get_none_device_name ()) {
|
||||
sr = available_sample_rates (output_device);
|
||||
} else if (output_device == get_standard_device_name (DeviceNone)) {
|
||||
} else if (output_device == get_none_device_name ()) {
|
||||
sr = available_sample_rates (input_device);
|
||||
} else {
|
||||
std::vector<float> sr_in = available_sample_rates (input_device);
|
||||
|
|
@ -178,7 +178,7 @@ AlsaAudioBackend::available_sample_rates (const std::string& device) const
|
|||
{
|
||||
ALSADeviceInfo* nfo = NULL;
|
||||
std::vector<float> sr;
|
||||
if (device == get_standard_device_name (DeviceNone)) {
|
||||
if (device == get_none_device_name ()) {
|
||||
return sr;
|
||||
}
|
||||
if (device == _input_audio_device && _input_audio_device_info.valid) {
|
||||
|
|
@ -202,11 +202,11 @@ std::vector<uint32_t>
|
|||
AlsaAudioBackend::available_buffer_sizes2 (const std::string& input_device, const std::string& output_device) const
|
||||
{
|
||||
std::vector<uint32_t> bs;
|
||||
if (input_device == get_standard_device_name (DeviceNone) && output_device == get_standard_device_name (DeviceNone)) {
|
||||
if (input_device == get_none_device_name () && output_device == get_none_device_name ()) {
|
||||
return bs;
|
||||
} else if (input_device == get_standard_device_name (DeviceNone)) {
|
||||
} else if (input_device == get_none_device_name ()) {
|
||||
bs = available_buffer_sizes (output_device);
|
||||
} else if (output_device == get_standard_device_name (DeviceNone)) {
|
||||
} else if (output_device == get_none_device_name ()) {
|
||||
bs = available_buffer_sizes (input_device);
|
||||
} else {
|
||||
std::vector<uint32_t> bs_in = available_buffer_sizes (input_device);
|
||||
|
|
@ -221,7 +221,7 @@ AlsaAudioBackend::available_buffer_sizes (const std::string& device) const
|
|||
{
|
||||
ALSADeviceInfo* nfo = NULL;
|
||||
std::vector<uint32_t> bs;
|
||||
if (device == get_standard_device_name (DeviceNone)) {
|
||||
if (device == get_none_device_name ()) {
|
||||
return bs;
|
||||
}
|
||||
if (device == _input_audio_device && _input_audio_device_info.valid) {
|
||||
|
|
@ -262,7 +262,7 @@ AlsaAudioBackend::available_period_sizes (const std::string& driver, const std::
|
|||
ps.push_back (2);
|
||||
|
||||
ALSADeviceInfo* nfo = NULL;
|
||||
if (device == get_standard_device_name (DeviceNone)) {
|
||||
if (device == get_none_device_name ()) {
|
||||
return ps;
|
||||
}
|
||||
|
||||
|
|
@ -301,7 +301,7 @@ AlsaAudioBackend::set_input_device_name (const std::string& d)
|
|||
}
|
||||
_input_audio_device = d;
|
||||
|
||||
if (d == get_standard_device_name (DeviceNone)) {
|
||||
if (d == get_none_device_name ()) {
|
||||
_input_audio_device_info.valid = false;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ AlsaAudioBackend::set_output_device_name (const std::string& d)
|
|||
|
||||
_output_audio_device = d;
|
||||
|
||||
if (d == get_standard_device_name (DeviceNone)) {
|
||||
if (d == get_none_device_name ()) {
|
||||
_output_audio_device_info.valid = false;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -369,7 +369,7 @@ AlsaAudioBackend::set_device_name (const std::string& d)
|
|||
bool
|
||||
AlsaAudioBackend::can_measure_systemic_latency () const
|
||||
{
|
||||
return _input_audio_device == _output_audio_device && _input_audio_device != get_standard_device_name (DeviceNone);
|
||||
return _input_audio_device == _output_audio_device && _input_audio_device != get_none_device_name ();
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -524,10 +524,10 @@ AlsaAudioBackend::update_systemic_midi_latencies ()
|
|||
std::string
|
||||
AlsaAudioBackend::device_name () const
|
||||
{
|
||||
if (_input_audio_device != get_standard_device_name (DeviceNone)) {
|
||||
if (_input_audio_device != get_none_device_name ()) {
|
||||
return _input_audio_device;
|
||||
}
|
||||
if (_output_audio_device != get_standard_device_name (DeviceNone)) {
|
||||
if (_output_audio_device != get_none_device_name ()) {
|
||||
return _output_audio_device;
|
||||
}
|
||||
return "";
|
||||
|
|
@ -611,7 +611,7 @@ AlsaAudioBackend::midi_device_info (std::string const name) const
|
|||
}
|
||||
}
|
||||
|
||||
assert (_midi_driver_option != get_standard_device_name (DeviceNone));
|
||||
assert (_midi_driver_option != get_none_device_name ());
|
||||
|
||||
std::map<std::string, std::string> devices;
|
||||
if (_midi_driver_option == _("ALSA raw devices")) {
|
||||
|
|
@ -635,7 +635,7 @@ AlsaAudioBackend::enumerate_midi_options () const
|
|||
if (_midi_options.empty ()) {
|
||||
_midi_options.push_back (_("ALSA raw devices"));
|
||||
_midi_options.push_back (_("ALSA sequencer"));
|
||||
_midi_options.push_back (get_standard_device_name (DeviceNone));
|
||||
_midi_options.push_back (get_none_device_name ());
|
||||
}
|
||||
return _midi_options;
|
||||
}
|
||||
|
|
@ -661,7 +661,7 @@ AlsaAudioBackend::enumerate_midi_devices () const
|
|||
int
|
||||
AlsaAudioBackend::set_midi_option (const std::string& opt)
|
||||
{
|
||||
if (opt != get_standard_device_name (DeviceNone) && opt != _("ALSA raw devices") && opt != _("ALSA sequencer")) {
|
||||
if (opt != get_none_device_name () && opt != _("ALSA raw devices") && opt != _("ALSA sequencer")) {
|
||||
return -1;
|
||||
}
|
||||
if (_run && _midi_driver_option != opt) {
|
||||
|
|
@ -797,7 +797,7 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
|||
|
||||
std::map<std::string, std::string> devices;
|
||||
|
||||
if (_input_audio_device == get_standard_device_name (DeviceNone) && _output_audio_device == get_standard_device_name (DeviceNone)) {
|
||||
if (_input_audio_device == get_none_device_name () && _output_audio_device == get_none_device_name ()) {
|
||||
PBD::error << _("AlsaAudioBackend: At least one of input or output device needs to be set.");
|
||||
return AudioDeviceInvalidError;
|
||||
}
|
||||
|
|
@ -808,7 +808,7 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
|||
if (_input_audio_device != _output_audio_device) {
|
||||
std::string input_audio_device (_input_audio_device);
|
||||
std::string output_audio_device (_output_audio_device);
|
||||
if (_input_audio_device != get_standard_device_name (DeviceNone) && _output_audio_device != get_standard_device_name (DeviceNone)) {
|
||||
if (_input_audio_device != get_none_device_name () && _output_audio_device != get_none_device_name ()) {
|
||||
/* Different devices for In + Out.
|
||||
* Ideally use input as clock source, and resample output.
|
||||
* But when using separate devices, input is usually one (or more)
|
||||
|
|
@ -817,15 +817,15 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
|||
*/
|
||||
if (getenv ("ARDOUR_ALSA_CLK")) {
|
||||
slave_device = _output_audio_device;
|
||||
output_audio_device = get_standard_device_name (DeviceNone); //XXX
|
||||
output_audio_device = get_none_device_name (); // XXX
|
||||
slave_duplex = AudioSlave::HalfDuplexOut;
|
||||
} else {
|
||||
slave_device = _input_audio_device;
|
||||
input_audio_device = get_standard_device_name (DeviceNone); //XXX
|
||||
input_audio_device = get_none_device_name (); // XXX
|
||||
slave_duplex = AudioSlave::HalfDuplexIn;
|
||||
}
|
||||
}
|
||||
if (input_audio_device != get_standard_device_name (DeviceNone)) {
|
||||
if (input_audio_device != get_none_device_name ()) {
|
||||
get_alsa_audio_device_names (devices, HalfDuplexIn);
|
||||
audio_device = input_audio_device;
|
||||
duplex = 1;
|
||||
|
|
@ -1466,7 +1466,7 @@ AlsaAudioBackend::register_system_midi_ports (const std::string device)
|
|||
{
|
||||
std::map<std::string, std::string> devices;
|
||||
|
||||
if (_midi_driver_option == get_standard_device_name (DeviceNone)) {
|
||||
if (_midi_driver_option == get_none_device_name ()) {
|
||||
return 0;
|
||||
} else if (_midi_driver_option == _("ALSA raw devices")) {
|
||||
get_alsa_rawmidi_device_names (devices);
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ CoreAudioBackend::enumerate_input_devices () const
|
|||
std::map<size_t, std::string> devices;
|
||||
_pcmio->input_device_list(devices);
|
||||
|
||||
_input_audio_device_status.push_back (DeviceStatus (get_standard_device_name(DeviceNone), true));
|
||||
_input_audio_device_status.push_back (DeviceStatus (get_none_device_name (), true));
|
||||
for (std::map<size_t, std::string>::const_iterator i = devices.begin (); i != devices.end(); ++i) {
|
||||
if (_input_audio_device == "") _input_audio_device = i->second;
|
||||
_input_audio_device_status.push_back (DeviceStatus (i->second, true));
|
||||
|
|
@ -193,7 +193,7 @@ CoreAudioBackend::enumerate_output_devices () const
|
|||
std::map<size_t, std::string> devices;
|
||||
_pcmio->output_device_list(devices);
|
||||
|
||||
_output_audio_device_status.push_back (DeviceStatus (get_standard_device_name(DeviceNone), true));
|
||||
_output_audio_device_status.push_back (DeviceStatus (get_none_device_name (), true));
|
||||
for (std::map<size_t, std::string>::const_iterator i = devices.begin (); i != devices.end(); ++i) {
|
||||
if (_output_audio_device == "") _output_audio_device = i->second;
|
||||
_output_audio_device_status.push_back (DeviceStatus (i->second, true));
|
||||
|
|
@ -417,7 +417,7 @@ CoreAudioBackend::enumerate_midi_options () const
|
|||
{
|
||||
if (_midi_options.empty()) {
|
||||
_midi_options.push_back (_("CoreMidi"));
|
||||
_midi_options.push_back (get_standard_device_name(DeviceNone));
|
||||
_midi_options.push_back (get_none_device_name ());
|
||||
}
|
||||
return _midi_options;
|
||||
}
|
||||
|
|
@ -425,7 +425,7 @@ CoreAudioBackend::enumerate_midi_options () const
|
|||
int
|
||||
CoreAudioBackend::set_midi_option (const std::string& opt)
|
||||
{
|
||||
if (opt != get_standard_device_name(DeviceNone) && opt != _("CoreMidi")) {
|
||||
if (opt != get_none_device_name () && opt != _("CoreMidi")) {
|
||||
return -1;
|
||||
}
|
||||
_midi_driver_option = opt;
|
||||
|
|
|
|||
|
|
@ -428,7 +428,7 @@ PortAudioBackend::enumerate_midi_options () const
|
|||
{
|
||||
if (_midi_options.empty()) {
|
||||
_midi_options.push_back (winmme_driver_name);
|
||||
_midi_options.push_back (get_standard_device_name(DeviceNone));
|
||||
_midi_options.push_back (get_none_device_name ());
|
||||
}
|
||||
return _midi_options;
|
||||
}
|
||||
|
|
@ -436,7 +436,7 @@ PortAudioBackend::enumerate_midi_options () const
|
|||
int
|
||||
PortAudioBackend::set_midi_option (const std::string& opt)
|
||||
{
|
||||
if (opt != get_standard_device_name(DeviceNone) && opt != winmme_driver_name) {
|
||||
if (opt != get_none_device_name () && opt != winmme_driver_name) {
|
||||
return -1;
|
||||
}
|
||||
DEBUG_MIDI (string_compose ("Setting midi option to %1\n", opt));
|
||||
|
|
@ -1220,7 +1220,7 @@ PortAudioBackend::register_system_audio_ports()
|
|||
int
|
||||
PortAudioBackend::register_system_midi_ports (std::string const& device)
|
||||
{
|
||||
if (_midi_driver_option == get_standard_device_name(DeviceNone)) {
|
||||
if (_midi_driver_option == get_none_device_name ()) {
|
||||
DEBUG_MIDI("No MIDI backend selected, not system midi ports available\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -484,9 +484,9 @@ void
|
|||
PortAudioIO::add_none_devices ()
|
||||
{
|
||||
_input_devices.insert(std::pair<int, paDevice*>(
|
||||
DeviceNone, new paDevice(AudioBackend::get_standard_device_name(AudioBackend::DeviceNone), 0, 0)));
|
||||
DeviceNone, new paDevice (AudioBackend::get_none_device_name (), 0, 0)));
|
||||
_output_devices.insert(std::pair<int, paDevice*>(
|
||||
DeviceNone, new paDevice(AudioBackend::get_standard_device_name(AudioBackend::DeviceNone), 0, 0)));
|
||||
DeviceNone, new paDevice (AudioBackend::get_none_device_name (), 0, 0)));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -499,12 +499,12 @@ PortAudioIO::add_default_devices ()
|
|||
const PaDeviceInfo* nfo_o = Pa_GetDeviceInfo(get_default_output_device());
|
||||
if (nfo_i && nfo_o) {
|
||||
_input_devices.insert (std::pair<int, paDevice*> (DeviceDefault,
|
||||
new paDevice(AudioBackend::get_standard_device_name(AudioBackend::DeviceDefault),
|
||||
new paDevice(AudioBackend::get_default_device_name (),
|
||||
nfo_i->maxInputChannels,
|
||||
nfo_o->maxOutputChannels
|
||||
)));
|
||||
_output_devices.insert (std::pair<int, paDevice*> (DeviceDefault,
|
||||
new paDevice(AudioBackend::get_standard_device_name(AudioBackend::DeviceDefault),
|
||||
new paDevice(AudioBackend::get_default_device_name (),
|
||||
nfo_i->maxInputChannels,
|
||||
nfo_o->maxOutputChannels
|
||||
)));
|
||||
|
|
|
|||
|
|
@ -34,11 +34,6 @@ public:
|
|||
PortAudioIO (void);
|
||||
~PortAudioIO (void);
|
||||
|
||||
enum StandardDevices {
|
||||
DeviceNone = -2,
|
||||
DeviceDefault = -1
|
||||
};
|
||||
|
||||
void host_api_list (std::vector<std::string>&);
|
||||
bool set_host_api (const std::string& host_api_name);
|
||||
std::string get_host_api () const { return _host_api_name; }
|
||||
|
|
|
|||
|
|
@ -482,7 +482,7 @@ std::vector<std::string>
|
|||
PulseAudioBackend::enumerate_midi_options () const
|
||||
{
|
||||
std::vector<std::string> midi_options;
|
||||
midi_options.push_back (get_standard_device_name (DeviceNone));
|
||||
midi_options.push_back (get_none_device_name ());
|
||||
return midi_options;
|
||||
}
|
||||
|
||||
|
|
@ -501,7 +501,7 @@ PulseAudioBackend::set_midi_option (const std::string& opt)
|
|||
std::string
|
||||
PulseAudioBackend::midi_option () const
|
||||
{
|
||||
return get_standard_device_name (DeviceNone);
|
||||
return get_none_device_name ();
|
||||
}
|
||||
|
||||
/* External control app */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue