From 29e71b5c8210e4b0f16241505a72e3ca21cf324e Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sun, 20 Oct 2024 22:42:07 +0200 Subject: [PATCH 1/5] typo: Fix peridod - also in lua `set_peridod_size` --- gtk2_ardour/engine_dialog.cc | 2 +- libs/ardour/ardour/audio_backend.h | 2 +- libs/ardour/luabindings.cc | 2 +- libs/backends/alsa/alsa_audiobackend.cc | 2 +- libs/backends/alsa/alsa_audiobackend.h | 2 +- libs/backends/jack/jack_audiobackend.cc | 2 +- libs/backends/jack/jack_audiobackend.h | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index 34200b53c1b..e0966b41bbc 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -2489,7 +2489,7 @@ EngineControl::push_state_to_backend (bool start) error << string_compose (_("Cannot set buffer size to %1"), get_buffer_size ()) << endmsg; return 1; } - if (change_nperiods && backend->set_peridod_size (get_nperiods ())) { + if (change_nperiods && backend->set_period_size (get_nperiods ())) { error << string_compose (_("Cannot set periods to %1"), get_nperiods ()) << endmsg; return 1; } diff --git a/libs/ardour/ardour/audio_backend.h b/libs/ardour/ardour/audio_backend.h index e7cba2ed59d..14d614ac90c 100644 --- a/libs/ardour/ardour/audio_backend.h +++ b/libs/ardour/ardour/audio_backend.h @@ -291,7 +291,7 @@ class LIBARDOUR_API AudioBackend : public PortEngine /** Set the period size to be used. * must be called before starting the backend. */ - virtual int set_peridod_size (uint32_t) + virtual int set_period_size (uint32_t) { return -1; } diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index 38843d263f6..900dc96e6ba 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -2920,7 +2920,7 @@ LuaBindings::common (lua_State* L) .addFunction ("set_sample_rate", &AudioBackend::set_sample_rate) .addFunction ("set_buffer_size", &AudioBackend::set_buffer_size) - .addFunction ("set_peridod_size", &AudioBackend::set_peridod_size) + .addFunction ("set_period_size", &AudioBackend::set_period_size) .addFunction ("enumerate_drivers", &AudioBackend::enumerate_drivers) .addFunction ("driver_name", &AudioBackend::driver_name) diff --git a/libs/backends/alsa/alsa_audiobackend.cc b/libs/backends/alsa/alsa_audiobackend.cc index 27ee52c6de1..e6ec62c863e 100644 --- a/libs/backends/alsa/alsa_audiobackend.cc +++ b/libs/backends/alsa/alsa_audiobackend.cc @@ -384,7 +384,7 @@ AlsaAudioBackend::set_sample_rate (float sr) } int -AlsaAudioBackend::set_peridod_size (uint32_t n) +AlsaAudioBackend::set_period_size (uint32_t n) { if (n == 0) { return -1; diff --git a/libs/backends/alsa/alsa_audiobackend.h b/libs/backends/alsa/alsa_audiobackend.h index 1b593cf8795..84907aa358f 100644 --- a/libs/backends/alsa/alsa_audiobackend.h +++ b/libs/backends/alsa/alsa_audiobackend.h @@ -154,7 +154,7 @@ class AlsaAudioBackend : public AudioBackend, public PortEngineSharedImpl int set_output_device_name (const std::string&); int set_sample_rate (float); int set_buffer_size (uint32_t); - int set_peridod_size (uint32_t); + int set_period_size (uint32_t); int set_interleaved (bool yn); int set_systemic_input_latency (uint32_t); int set_systemic_output_latency (uint32_t); diff --git a/libs/backends/jack/jack_audiobackend.cc b/libs/backends/jack/jack_audiobackend.cc index 8f4f1f0a78e..97b0f00e3c3 100644 --- a/libs/backends/jack/jack_audiobackend.cc +++ b/libs/backends/jack/jack_audiobackend.cc @@ -262,7 +262,7 @@ JACKAudioBackend::set_sample_rate (float sr) } int -JACKAudioBackend::set_peridod_size (uint32_t nperiods) +JACKAudioBackend::set_period_size (uint32_t nperiods) { if (!available()) { _target_num_periods = nperiods; diff --git a/libs/backends/jack/jack_audiobackend.h b/libs/backends/jack/jack_audiobackend.h index 21c775e47f1..822424f87f3 100644 --- a/libs/backends/jack/jack_audiobackend.h +++ b/libs/backends/jack/jack_audiobackend.h @@ -78,7 +78,7 @@ class JACKAudioBackend : public AudioBackend { int set_device_name (const std::string&); int set_sample_rate (float); int set_buffer_size (uint32_t); - int set_peridod_size (uint32_t); + int set_period_size (uint32_t); int set_interleaved (bool yn); int set_systemic_input_latency (uint32_t); int set_systemic_output_latency (uint32_t); From a3ac3c72010608cc8081c3760e5567a6f7ff25ac Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sun, 20 Oct 2024 21:41:20 +0200 Subject: [PATCH 2/5] 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. --- gtk2_ardour/engine_dialog.cc | 8 +-- libs/ardour/ardour/audio_backend.h | 10 ++-- libs/ardour/audio_backend.cc | 16 +++--- libs/backends/alsa/alsa_audiobackend.cc | 50 +++++++++---------- libs/backends/coreaudio/coreaudio_backend.cc | 8 +-- libs/backends/portaudio/portaudio_backend.cc | 6 +-- libs/backends/portaudio/portaudio_io.cc | 8 +-- libs/backends/portaudio/portaudio_io.h | 5 -- .../backends/pulseaudio/pulseaudio_backend.cc | 4 +- 9 files changed, 53 insertions(+), 62 deletions(-) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index e0966b41bbc..b7c80b9f096 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -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::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 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 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 (); diff --git a/libs/ardour/ardour/audio_backend.h b/libs/ardour/ardour/audio_backend.h index 14d614ac90c..96e1f056de6 100644 --- a/libs/ardour/ardour/audio_backend.h +++ b/libs/ardour/ardour/audio_backend.h @@ -131,12 +131,8 @@ class LIBARDOUR_API AudioBackend : public PortEngine 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 @@ class LIBARDOUR_API AudioBackend : public PortEngine * 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 { diff --git a/libs/ardour/audio_backend.cc b/libs/ardour/audio_backend.cc index 30df66c6ffe..1001c550ffa 100644 --- a/libs/ardour/audio_backend.cc +++ b/libs/ardour/audio_backend.cc @@ -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 diff --git a/libs/backends/alsa/alsa_audiobackend.cc b/libs/backends/alsa/alsa_audiobackend.cc index e6ec62c863e..14c23b8c069 100644 --- a/libs/backends/alsa/alsa_audiobackend.cc +++ b/libs/backends/alsa/alsa_audiobackend.cc @@ -129,7 +129,7 @@ AlsaAudioBackend::enumerate_input_devices () const _input_audio_device_status.clear (); std::map 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::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 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::const_iterator i = devices.begin (); i != devices.end (); ++i) { if (_output_audio_device == "") { _output_audio_device = i->first; @@ -159,11 +159,11 @@ std::vector AlsaAudioBackend::available_sample_rates2 (const std::string& input_device, const std::string& output_device) const { std::vector 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 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 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 AlsaAudioBackend::available_buffer_sizes2 (const std::string& input_device, const std::string& output_device) const { std::vector 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 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 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 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 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 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); diff --git a/libs/backends/coreaudio/coreaudio_backend.cc b/libs/backends/coreaudio/coreaudio_backend.cc index 05c59220d09..747ebb18783 100644 --- a/libs/backends/coreaudio/coreaudio_backend.cc +++ b/libs/backends/coreaudio/coreaudio_backend.cc @@ -177,7 +177,7 @@ CoreAudioBackend::enumerate_input_devices () const std::map 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::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 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::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; diff --git a/libs/backends/portaudio/portaudio_backend.cc b/libs/backends/portaudio/portaudio_backend.cc index b1feb1271d4..3dce7a5d786 100644 --- a/libs/backends/portaudio/portaudio_backend.cc +++ b/libs/backends/portaudio/portaudio_backend.cc @@ -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; } diff --git a/libs/backends/portaudio/portaudio_io.cc b/libs/backends/portaudio/portaudio_io.cc index d2d6ac4c587..67a949f6e8c 100644 --- a/libs/backends/portaudio/portaudio_io.cc +++ b/libs/backends/portaudio/portaudio_io.cc @@ -484,9 +484,9 @@ void PortAudioIO::add_none_devices () { _input_devices.insert(std::pair( - 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( - 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 (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 (DeviceDefault, - new paDevice(AudioBackend::get_standard_device_name(AudioBackend::DeviceDefault), + new paDevice(AudioBackend::get_default_device_name (), nfo_i->maxInputChannels, nfo_o->maxOutputChannels ))); diff --git a/libs/backends/portaudio/portaudio_io.h b/libs/backends/portaudio/portaudio_io.h index cfd6283d571..1874176d340 100644 --- a/libs/backends/portaudio/portaudio_io.h +++ b/libs/backends/portaudio/portaudio_io.h @@ -34,11 +34,6 @@ class PortAudioIO { PortAudioIO (void); ~PortAudioIO (void); - enum StandardDevices { - DeviceNone = -2, - DeviceDefault = -1 - }; - void host_api_list (std::vector&); bool set_host_api (const std::string& host_api_name); std::string get_host_api () const { return _host_api_name; } diff --git a/libs/backends/pulseaudio/pulseaudio_backend.cc b/libs/backends/pulseaudio/pulseaudio_backend.cc index 889190d4adb..708798ae9ce 100644 --- a/libs/backends/pulseaudio/pulseaudio_backend.cc +++ b/libs/backends/pulseaudio/pulseaudio_backend.cc @@ -482,7 +482,7 @@ std::vector PulseAudioBackend::enumerate_midi_options () const { std::vector 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 */ From 9c0c4f527bf775fde4968be2f919f3f4c957e0c8 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Thu, 17 Oct 2024 23:20:15 +0200 Subject: [PATCH 3/5] audio_backend: Merge is_realtime() into client_real_time_priority() The description of is_realtime() did not match its actual use. And client_real_time_priority() did not have any description. It was hard to come up with good descriptions of what they actually did. Most backends returned true from is_realtime(), but every one except JACK used the default implementation of client_real_time_priority() that returned 0 ... which is exactly the same as when is_realtime() returns false. Just merge them and keep it simple. --- libs/ardour/ardour/audio_backend.h | 9 ++------- libs/ardour/audioengine.cc | 6 +----- libs/backends/alsa/alsa_audiobackend.cc | 6 ------ libs/backends/alsa/alsa_audiobackend.h | 1 - libs/backends/coreaudio/coreaudio_backend.cc | 6 ------ libs/backends/coreaudio/coreaudio_backend.h | 1 - libs/backends/dummy/dummy_audiobackend.cc | 6 ------ libs/backends/dummy/dummy_audiobackend.h | 1 - libs/backends/jack/jack_audiobackend.cc | 9 ++------- libs/backends/jack/jack_audiobackend.h | 1 - libs/backends/portaudio/portaudio_backend.cc | 6 ------ libs/backends/portaudio/portaudio_backend.h | 1 - libs/backends/pulseaudio/pulseaudio_backend.cc | 6 ------ libs/backends/pulseaudio/pulseaudio_backend.h | 1 - 14 files changed, 5 insertions(+), 55 deletions(-) diff --git a/libs/ardour/ardour/audio_backend.h b/libs/ardour/ardour/audio_backend.h index 96e1f056de6..85de704dd95 100644 --- a/libs/ardour/ardour/audio_backend.h +++ b/libs/ardour/ardour/audio_backend.h @@ -149,15 +149,10 @@ class LIBARDOUR_API AudioBackend : public PortEngine */ virtual std::string name () const = 0; - /** Return true if the callback from the underlying mechanism/API - * (CoreAudio, JACK, ASIO etc.) occurs in a thread subject to realtime - * constraints. Return false otherwise. - */ - virtual bool is_realtime () const = 0; - - /** Return true if the backed is JACK */ + /** Return true if the backend is JACK */ virtual bool is_jack () const { return false; } + /** Return the priority to be set with pbd_set_engine_rt_priority. */ virtual int client_real_time_priority () { return 0; } /* Discovering devices and parameters */ diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 99bb95f12b8..fd8cf65753b 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -1067,11 +1067,7 @@ AudioEngine::start (bool for_latency) return -1; } - if (_backend->is_realtime ()) { - pbd_set_engine_rt_priority (_backend->client_real_time_priority ()); - } else { - pbd_set_engine_rt_priority (0); - } + pbd_set_engine_rt_priority (_backend->client_real_time_priority ()); _running = true; diff --git a/libs/backends/alsa/alsa_audiobackend.cc b/libs/backends/alsa/alsa_audiobackend.cc index 14c23b8c069..0234e47f9da 100644 --- a/libs/backends/alsa/alsa_audiobackend.cc +++ b/libs/backends/alsa/alsa_audiobackend.cc @@ -99,12 +99,6 @@ AlsaAudioBackend::name () const return X_("ALSA"); } -bool -AlsaAudioBackend::is_realtime () const -{ - return true; -} - std::vector AlsaAudioBackend::enumerate_devices () const { diff --git a/libs/backends/alsa/alsa_audiobackend.h b/libs/backends/alsa/alsa_audiobackend.h index 84907aa358f..3b9df0c7025 100644 --- a/libs/backends/alsa/alsa_audiobackend.h +++ b/libs/backends/alsa/alsa_audiobackend.h @@ -125,7 +125,6 @@ class AlsaAudioBackend : public AudioBackend, public PortEngineSharedImpl /* AUDIOBACKEND API */ std::string name () const; - bool is_realtime () const; bool use_separate_input_and_output_devices () const { return true; } bool match_input_output_devices_or_none () const { return false; } diff --git a/libs/backends/coreaudio/coreaudio_backend.cc b/libs/backends/coreaudio/coreaudio_backend.cc index 747ebb18783..0d14d247039 100644 --- a/libs/backends/coreaudio/coreaudio_backend.cc +++ b/libs/backends/coreaudio/coreaudio_backend.cc @@ -149,12 +149,6 @@ CoreAudioBackend::name () const return X_("CoreAudio"); } -bool -CoreAudioBackend::is_realtime () const -{ - return true; -} - std::vector CoreAudioBackend::enumerate_devices () const { diff --git a/libs/backends/coreaudio/coreaudio_backend.h b/libs/backends/coreaudio/coreaudio_backend.h index 8aa6bbccc5b..e32ac82d550 100644 --- a/libs/backends/coreaudio/coreaudio_backend.h +++ b/libs/backends/coreaudio/coreaudio_backend.h @@ -160,7 +160,6 @@ class CoreAudioBackend : public AudioBackend, public PortEngineSharedImpl { /* AUDIOBACKEND API */ std::string name () const; - bool is_realtime () const; bool use_separate_input_and_output_devices () const { return true; } std::vector enumerate_devices () const; diff --git a/libs/backends/dummy/dummy_audiobackend.cc b/libs/backends/dummy/dummy_audiobackend.cc index 60b30b64601..6507d22a59b 100644 --- a/libs/backends/dummy/dummy_audiobackend.cc +++ b/libs/backends/dummy/dummy_audiobackend.cc @@ -110,12 +110,6 @@ DummyAudioBackend::name () const return X_("Dummy"); // internal name } -bool -DummyAudioBackend::is_realtime () const -{ - return false; -} - std::vector DummyAudioBackend::enumerate_devices () const { diff --git a/libs/backends/dummy/dummy_audiobackend.h b/libs/backends/dummy/dummy_audiobackend.h index bde876e87c4..d2cb1a3b2da 100644 --- a/libs/backends/dummy/dummy_audiobackend.h +++ b/libs/backends/dummy/dummy_audiobackend.h @@ -194,7 +194,6 @@ class DummyAudioBackend : public AudioBackend, public PortEngineSharedImpl /* AUDIOBACKEND API */ std::string name () const; - bool is_realtime () const; bool requires_driver_selection() const { return true; } std::string driver_name () const; diff --git a/libs/backends/jack/jack_audiobackend.cc b/libs/backends/jack/jack_audiobackend.cc index 97b0f00e3c3..d62ceac1939 100644 --- a/libs/backends/jack/jack_audiobackend.cc +++ b/libs/backends/jack/jack_audiobackend.cc @@ -105,13 +105,6 @@ JACKAudioBackend::available() const return (private_handle() != 0); } -bool -JACKAudioBackend::is_realtime () const -{ - GET_PRIVATE_JACK_POINTER_RET (_priv_jack,false); - return jack_is_realtime (_priv_jack); -} - bool JACKAudioBackend::requires_driver_selection() const { @@ -882,6 +875,8 @@ int JACKAudioBackend::client_real_time_priority () { GET_PRIVATE_JACK_POINTER_RET (_priv_jack, 0); + if (!jack_is_realtime (_priv_jack)) + return 0; return jack_client_real_time_priority (_priv_jack); } diff --git a/libs/backends/jack/jack_audiobackend.h b/libs/backends/jack/jack_audiobackend.h index 822424f87f3..54e81784352 100644 --- a/libs/backends/jack/jack_audiobackend.h +++ b/libs/backends/jack/jack_audiobackend.h @@ -58,7 +58,6 @@ class JACKAudioBackend : public AudioBackend { std::string name() const; void* private_handle() const; - bool is_realtime () const; bool is_jack () const { return true; } diff --git a/libs/backends/portaudio/portaudio_backend.cc b/libs/backends/portaudio/portaudio_backend.cc index 3dce7a5d786..5c0fb2ee0a5 100644 --- a/libs/backends/portaudio/portaudio_backend.cc +++ b/libs/backends/portaudio/portaudio_backend.cc @@ -118,12 +118,6 @@ PortAudioBackend::name () const return X_("PortAudio"); } -bool -PortAudioBackend::is_realtime () const -{ - return true; -} - bool PortAudioBackend::requires_driver_selection() const { diff --git a/libs/backends/portaudio/portaudio_backend.h b/libs/backends/portaudio/portaudio_backend.h index 4c82e87a764..5a927b224a6 100644 --- a/libs/backends/portaudio/portaudio_backend.h +++ b/libs/backends/portaudio/portaudio_backend.h @@ -99,7 +99,6 @@ class PortAudioBackend : public AudioBackend, public PortEngineSharedImpl { /* AUDIOBACKEND API */ std::string name () const; - bool is_realtime () const; bool requires_driver_selection() const; std::string driver_name () const; diff --git a/libs/backends/pulseaudio/pulseaudio_backend.cc b/libs/backends/pulseaudio/pulseaudio_backend.cc index 708798ae9ce..d3273eb4c97 100644 --- a/libs/backends/pulseaudio/pulseaudio_backend.cc +++ b/libs/backends/pulseaudio/pulseaudio_backend.cc @@ -332,12 +332,6 @@ PulseAudioBackend::name () const return X_("PulseAudio"); } -bool -PulseAudioBackend::is_realtime () const -{ - return true; -} - std::vector PulseAudioBackend::enumerate_devices () const { diff --git a/libs/backends/pulseaudio/pulseaudio_backend.h b/libs/backends/pulseaudio/pulseaudio_backend.h index 1e8c981990b..4190706be37 100644 --- a/libs/backends/pulseaudio/pulseaudio_backend.h +++ b/libs/backends/pulseaudio/pulseaudio_backend.h @@ -102,7 +102,6 @@ class PulseAudioBackend : public AudioBackend, public PortEngineSharedImpl /* AUDIOBACKEND API */ std::string name () const; - bool is_realtime () const; std::vector enumerate_devices () const; std::vector available_sample_rates (const std::string& device) const; From 710bd07cd4b1963bf02e8ef06c4028162616d035 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sun, 20 Oct 2024 18:44:43 +0200 Subject: [PATCH 4/5] audio_backend: Rename instantiate() parameter arg2 to `session_id` The thing called backend_client_name defaulted to lowercase PROGRAM_NAME and could be controlled with: -c, --name Use a specific backend client name, default is ardour This value was *only* used for set_backend arg2 which only is used for jack, where it was called session_uuid and passed to jack_client_open as "a SessionID Token this allows the sessionmanager to identify the client again" because JackSessionID. It is certainly misleading to call it a uuid. It also doesn't seem helpful to call it "client name" when the documentation calls it "session id". And mostly: jack_client_open calls its *first* argument "client_name" and it comes from argv1. To clear things up, consistently call it something with "session id". And it is not helpful to use a generic arg2 naming. --- gtk2_ardour/ardour_ui_startup.cc | 2 +- gtk2_ardour/engine_dialog.cc | 4 ++-- gtk2_ardour/nsm.cc | 2 +- gtk2_ardour/opts.cc | 6 +++--- gtk2_ardour/opts.h | 2 +- headless/load_session.cc | 8 ++++---- libs/ardour/ardour/audio_backend.h | 4 ++-- libs/ardour/ardour/audioengine.h | 2 +- libs/ardour/audioengine.cc | 4 ++-- libs/backends/alsa/alsa_audiobackend.cc | 4 ++-- libs/backends/coreaudio/coreaudio_backend.cc | 4 ++-- libs/backends/dummy/dummy_audiobackend.cc | 4 ++-- libs/backends/jack/jack_api.cc | 6 +++--- libs/backends/jack/jack_connection.cc | 6 +++--- libs/backends/jack/jack_connection.h | 4 ++-- libs/backends/portaudio/portaudio_backend.cc | 4 ++-- libs/backends/pulseaudio/pulseaudio_backend.cc | 4 ++-- 17 files changed, 35 insertions(+), 35 deletions(-) diff --git a/gtk2_ardour/ardour_ui_startup.cc b/gtk2_ardour/ardour_ui_startup.cc index e22db6cd6ba..827212561b1 100644 --- a/gtk2_ardour/ardour_ui_startup.cc +++ b/gtk2_ardour/ardour_ui_startup.cc @@ -866,7 +866,7 @@ ARDOUR_UI::load_from_application_api (const std::string& path) #else "JACK", #endif - ARDOUR_COMMAND_LINE::backend_client_name, "")) { + ARDOUR_COMMAND_LINE::backend_session_id, "")) { error << _("NSM: The JACK backend is mandatory and can not be loaded.") << endmsg; return; } diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index b7c80b9f096..44f0935aac5 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -1024,7 +1024,7 @@ EngineControl::backend_changed () string backend_name = backend_combo.get_active_text (); std::shared_ptr backend; - if (!(backend = ARDOUR::AudioEngine::instance ()->set_backend (backend_name, ARDOUR_COMMAND_LINE::backend_client_name, ""))) { + if (!(backend = ARDOUR::AudioEngine::instance ()->set_backend (backend_name, ARDOUR_COMMAND_LINE::backend_session_id, ""))) { /* eh? setting the backend failed... how ? */ /* A: stale config contains a backend that does not exist in current build */ return; @@ -2207,7 +2207,7 @@ EngineControl::set_current_state (const State& state) std::shared_ptr backend; - if (!(backend = ARDOUR::AudioEngine::instance ()->set_backend (state->backend, ARDOUR_COMMAND_LINE::backend_client_name, ""))) { + if (!(backend = ARDOUR::AudioEngine::instance ()->set_backend (state->backend, ARDOUR_COMMAND_LINE::backend_session_id, ""))) { DEBUG_ECONTROL (string_compose ("Unable to set backend to %1", state->backend)); // this shouldn't happen as the invalid backend names should have been // removed from the list of states. diff --git a/gtk2_ardour/nsm.cc b/gtk2_ardour/nsm.cc index 30e64455b80..57b69f9b78e 100644 --- a/gtk2_ardour/nsm.cc +++ b/gtk2_ardour/nsm.cc @@ -49,7 +49,7 @@ NSM_Client::command_open(const char* name, { int r = ERR_OK; - ARDOUR_COMMAND_LINE::backend_client_name = client_id; + ARDOUR_COMMAND_LINE::backend_session_id = client_id; ARDOUR_COMMAND_LINE::session_name = ""; /* this appears asynchronous, but almost certainly is diff --git a/gtk2_ardour/opts.cc b/gtk2_ardour/opts.cc index 234381a249a..14684b19d05 100644 --- a/gtk2_ardour/opts.cc +++ b/gtk2_ardour/opts.cc @@ -41,7 +41,7 @@ using namespace std; string ARDOUR_COMMAND_LINE::session_name = ""; -string ARDOUR_COMMAND_LINE::backend_client_name = PBD::downcase(PROGRAM_NAME); +string ARDOUR_COMMAND_LINE::backend_session_id = PBD::downcase(PROGRAM_NAME); bool ARDOUR_COMMAND_LINE::show_key_actions = false; bool ARDOUR_COMMAND_LINE::show_actions = false; bool ARDOUR_COMMAND_LINE::no_splash = false; @@ -72,7 +72,7 @@ print_help (const char *execname) << _(" -A, --actions Print all possible menu action names\n") << _(" -b, --bindings Display all current key bindings\n") << _(" -B, --bypass-plugins Bypass all plugins in an existing session\n") - << _(" -c, --name Use a specific backend client name, default is ardour\n") + << _(" -c, --name Specify audio backend client session id, default is ardour\n") << _(" -d, --disable-plugins Disable all plugins (safe mode)\n") #ifndef NDEBUG << _(" -D, --debug Set debug flags. Use \"-D list\" to see available options\n") @@ -218,7 +218,7 @@ ARDOUR_COMMAND_LINE::parse_opts (int argc, char *argv[]) break; case 'c': - backend_client_name = optarg; + backend_session_id = optarg; break; case 'k': diff --git a/gtk2_ardour/opts.h b/gtk2_ardour/opts.h index 56e0b2c0314..d9f58351a8c 100644 --- a/gtk2_ardour/opts.h +++ b/gtk2_ardour/opts.h @@ -29,7 +29,7 @@ extern bool show_key_actions; extern bool show_actions; extern bool no_splash; extern bool just_version; -extern std::string backend_client_name; +extern std::string backend_session_id; extern bool new_session; extern bool try_hw_optimization; extern bool no_connect_ports; diff --git a/headless/load_session.cc b/headless/load_session.cc index f921b836768..247b34bf833 100644 --- a/headless/load_session.cc +++ b/headless/load_session.cc @@ -48,7 +48,7 @@ using namespace PBD; static const char* localedir = LOCALEDIR; -static string backend_client_name; +static string backend_session_id; static CrossThreadChannel xthread (true); static TestReceiver test_receiver; @@ -72,7 +72,7 @@ load_session (string dir, string state) AudioEngine* engine = AudioEngine::create (); - if (!engine->set_backend (backend_name, backend_client_name, "")) { + if (!engine->set_backend (backend_name, backend_session_id, "")) { std::cerr << "Cannot set Audio/MIDI engine backend\n"; exit (EXIT_FAILURE); } @@ -172,7 +172,7 @@ main (int argc, char* argv[]) bool try_hw_optimization = true; - backend_client_name = PBD::downcase (std::string (PROGRAM_NAME)); + backend_session_id = PBD::downcase (std::string (PROGRAM_NAME)); int c; while ((c = getopt_long (argc, argv, optstring, longopts, (int*)0)) != EOF) { @@ -191,7 +191,7 @@ main (int argc, char* argv[]) break; case 'c': - backend_client_name = optarg; + backend_session_id = optarg; break; case 'B': diff --git a/libs/ardour/ardour/audio_backend.h b/libs/ardour/ardour/audio_backend.h index 85de704dd95..f337e21e92f 100644 --- a/libs/ardour/ardour/audio_backend.h +++ b/libs/ardour/ardour/audio_backend.h @@ -44,11 +44,11 @@ namespace ARDOUR struct LIBARDOUR_API AudioBackendInfo { const char* name; - /** Using arg1 and arg2, initialize this audiobackend. + /** Using arg1 and session_id, initialize this audiobackend. * * Returns zero on success, non-zero otherwise. */ - int (*instantiate) (const std::string& arg1, const std::string& arg2); + int (*instantiate) (const std::string& arg1, const std::string& session_id); /** Release all resources associated with this audiobackend */ int (*deinstantiate) (void); diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index a63913747ce..c047c462a91 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -71,7 +71,7 @@ class LIBARDOUR_API AudioEngine : public PortManager, public SessionHandlePtr int discover_backends(); std::vector available_backends() const; std::string current_backend_name () const; - std::shared_ptr set_backend (const std::string&, const std::string& arg1, const std::string& arg2); + std::shared_ptr set_backend (const std::string& name, const std::string& arg1, const std::string& session_id); std::shared_ptr current_backend() const { return _backend; } bool setup_required () const; bool is_jack () const; diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index fd8cf65753b..43a9a74bdbf 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -1015,7 +1015,7 @@ AudioEngine::drop_backend () } std::shared_ptr -AudioEngine::set_backend (const std::string& name, const std::string& arg1, const std::string& arg2) +AudioEngine::set_backend (const std::string& name, const std::string& arg1, const std::string& session_id) { BackendMap::iterator b = _backends.find (name); @@ -1026,7 +1026,7 @@ AudioEngine::set_backend (const std::string& name, const std::string& arg1, cons drop_backend (); try { - if (b->second->instantiate (arg1, arg2)) { + if (b->second->instantiate (arg1, session_id)) { throw failed_constructor (); } diff --git a/libs/backends/alsa/alsa_audiobackend.cc b/libs/backends/alsa/alsa_audiobackend.cc index 0234e47f9da..943ae0b23db 100644 --- a/libs/backends/alsa/alsa_audiobackend.cc +++ b/libs/backends/alsa/alsa_audiobackend.cc @@ -2181,7 +2181,7 @@ AlsaAudioBackend::AudioSlave::update_latencies (uint32_t play, uint32_t capt) static std::shared_ptr _instance; static std::shared_ptr backend_factory (AudioEngine& e); -static int instantiate (const std::string& arg1, const std::string& /* arg2 */); +static int instantiate (const std::string& arg1, const std::string& /* session_id */); static int deinstantiate (); static bool already_configured (); static bool available (); @@ -2205,7 +2205,7 @@ backend_factory (AudioEngine& e) } static int -instantiate (const std::string& arg1, const std::string& /* arg2 */) +instantiate (const std::string& arg1, const std::string& /* session_id */) { s_instance_name = arg1; return 0; diff --git a/libs/backends/coreaudio/coreaudio_backend.cc b/libs/backends/coreaudio/coreaudio_backend.cc index 0d14d247039..967660a6f8d 100644 --- a/libs/backends/coreaudio/coreaudio_backend.cc +++ b/libs/backends/coreaudio/coreaudio_backend.cc @@ -1529,7 +1529,7 @@ CoreAudioBackend::hw_changed_callback () static std::shared_ptr _instance; static std::shared_ptr backend_factory (AudioEngine& e); -static int instantiate (const std::string& arg1, const std::string& /* arg2 */); +static int instantiate (const std::string& arg1, const std::string& /* session_id */); static int deinstantiate (); static bool already_configured (); static bool available (); @@ -1553,7 +1553,7 @@ backend_factory (AudioEngine& e) } static int -instantiate (const std::string& arg1, const std::string& /* arg2 */) +instantiate (const std::string& arg1, const std::string& /* session_id */) { s_instance_name = arg1; return 0; diff --git a/libs/backends/dummy/dummy_audiobackend.cc b/libs/backends/dummy/dummy_audiobackend.cc index 6507d22a59b..b153189b287 100644 --- a/libs/backends/dummy/dummy_audiobackend.cc +++ b/libs/backends/dummy/dummy_audiobackend.cc @@ -1016,7 +1016,7 @@ DummyAudioBackend::main_process_thread () static std::shared_ptr _instance; static std::shared_ptr backend_factory (AudioEngine& e); -static int instantiate (const std::string& arg1, const std::string& /* arg2 */); +static int instantiate (const std::string& arg1, const std::string& /* session_id */); static int deinstantiate (); static bool already_configured (); static bool available (); @@ -1040,7 +1040,7 @@ backend_factory (AudioEngine& e) } static int -instantiate (const std::string& arg1, const std::string& /* arg2 */) +instantiate (const std::string& arg1, const std::string& /* session_id */) { s_instance_name = arg1; return 0; diff --git a/libs/backends/jack/jack_api.cc b/libs/backends/jack/jack_api.cc index 959e3e58380..5e437a46416 100644 --- a/libs/backends/jack/jack_api.cc +++ b/libs/backends/jack/jack_api.cc @@ -25,7 +25,7 @@ static std::shared_ptr backend; static std::shared_ptr jack_connection; static std::shared_ptr backend_factory (AudioEngine& ae); -static int instantiate (const std::string& arg1, const std::string& arg2); +static int instantiate (const std::string& arg1, const std::string& session_id); static int deinstantiate (); static bool already_configured (); static bool available (); @@ -58,10 +58,10 @@ backend_factory (AudioEngine& ae) } static int -instantiate (const std::string& arg1, const std::string& arg2) +instantiate (const std::string& arg1, const std::string& session_id) { try { - jack_connection.reset (new JackConnection (arg1, arg2)); + jack_connection.reset (new JackConnection (arg1, session_id)); backend.reset (); } catch (...) { return -1; diff --git a/libs/backends/jack/jack_connection.cc b/libs/backends/jack/jack_connection.cc index 207c4add791..ac1ee247a0f 100644 --- a/libs/backends/jack/jack_connection.cc +++ b/libs/backends/jack/jack_connection.cc @@ -50,10 +50,10 @@ static void jack_halted_info_callback (jack_status_t code, const char* reason, v } -JackConnection::JackConnection (const std::string& arg1, const std::string& arg2) +JackConnection::JackConnection (const std::string& arg1, const std::string& session_id) : _jack (0) , _client_name (arg1) - , session_uuid (arg2) + , _session_id (session_id) , _probed_buffer_size (0) , _probed_sample_rate (0) { @@ -116,7 +116,7 @@ JackConnection::open () get_jack_server_dir_paths (dirs); set_path_env_for_jack_autostart (dirs); - if ((_jack = jack_client_open (_client_name.c_str(), JackSessionID, &status, session_uuid.c_str())) == 0) { + if ((_jack = jack_client_open (_client_name.c_str(), JackSessionID, &status, _session_id.c_str())) == 0) { return -1; } diff --git a/libs/backends/jack/jack_connection.h b/libs/backends/jack/jack_connection.h index b9aaab7aa83..164525665af 100644 --- a/libs/backends/jack/jack_connection.h +++ b/libs/backends/jack/jack_connection.h @@ -10,7 +10,7 @@ namespace ARDOUR { class JackConnection { public: - JackConnection (const std::string& client_name, const std::string& session_uuid); + JackConnection (const std::string& client_name, const std::string& session_id); ~JackConnection (); const std::string& client_name() const { return _client_name; } @@ -35,7 +35,7 @@ class JackConnection { private: jack_client_t* volatile _jack; std::string _client_name; - std::string session_uuid; + std::string _session_id; static bool _in_control; uint32_t _probed_buffer_size; // when not in control uint32_t _probed_sample_rate; // when not in control diff --git a/libs/backends/portaudio/portaudio_backend.cc b/libs/backends/portaudio/portaudio_backend.cc index 5c0fb2ee0a5..71b88e84bf7 100644 --- a/libs/backends/portaudio/portaudio_backend.cc +++ b/libs/backends/portaudio/portaudio_backend.cc @@ -1793,7 +1793,7 @@ PortAudioBackend::process_port_connection_changes () static std::shared_ptr _instance; static std::shared_ptr backend_factory (AudioEngine& e); -static int instantiate (const std::string& arg1, const std::string& /* arg2 */); +static int instantiate (const std::string& arg1, const std::string& /* session_id */); static int deinstantiate (); static bool already_configured (); static bool available (); @@ -1817,7 +1817,7 @@ backend_factory (AudioEngine& e) } static int -instantiate (const std::string& arg1, const std::string& /* arg2 */) +instantiate (const std::string& arg1, const std::string& /* session_id */) { s_instance_name = arg1; return 0; diff --git a/libs/backends/pulseaudio/pulseaudio_backend.cc b/libs/backends/pulseaudio/pulseaudio_backend.cc index d3273eb4c97..de29b1a30fb 100644 --- a/libs/backends/pulseaudio/pulseaudio_backend.cc +++ b/libs/backends/pulseaudio/pulseaudio_backend.cc @@ -1084,7 +1084,7 @@ PulseAudioBackend::main_process_thread () static std::shared_ptr _instance; static std::shared_ptr backend_factory (AudioEngine& e); -static int instantiate (const std::string& arg1, const std::string& /* arg2 */); +static int instantiate (const std::string& arg1, const std::string& /* session_id */); static int deinstantiate (); static bool already_configured (); static bool available (); @@ -1108,7 +1108,7 @@ backend_factory (AudioEngine& e) } static int -instantiate (const std::string& arg1, const std::string& /* arg2 */) +instantiate (const std::string& arg1, const std::string& /* session_id */) { s_instance_name = arg1; return 0; From 79e99c12a5f22cf01b1191d5ffab350c3f5ed072 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sun, 20 Oct 2024 19:31:08 +0200 Subject: [PATCH 5/5] audio_backend: Rename instantiate() parameter arg1 to `client_name` This parameter is consistently used to name the audio backend instance and how it appear as client of the sound server. Just name it `client_name`, consistent with the name of the jack_client_open parameter it is passed to . --- libs/ardour/ardour/audio_backend.h | 4 ++-- libs/ardour/ardour/audioengine.h | 2 +- libs/ardour/audioengine.cc | 4 ++-- libs/backends/alsa/alsa_audiobackend.cc | 6 +++--- libs/backends/coreaudio/coreaudio_backend.cc | 6 +++--- libs/backends/dummy/dummy_audiobackend.cc | 6 +++--- libs/backends/jack/jack_api.cc | 6 +++--- libs/backends/jack/jack_connection.cc | 4 ++-- libs/backends/portaudio/portaudio_backend.cc | 6 +++--- libs/backends/pulseaudio/pulseaudio_backend.cc | 6 +++--- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/libs/ardour/ardour/audio_backend.h b/libs/ardour/ardour/audio_backend.h index f337e21e92f..39f768c131e 100644 --- a/libs/ardour/ardour/audio_backend.h +++ b/libs/ardour/ardour/audio_backend.h @@ -44,11 +44,11 @@ namespace ARDOUR struct LIBARDOUR_API AudioBackendInfo { const char* name; - /** Using arg1 and session_id, initialize this audiobackend. + /** Using client_name and session_id, initialize this audiobackend. * * Returns zero on success, non-zero otherwise. */ - int (*instantiate) (const std::string& arg1, const std::string& session_id); + int (*instantiate) (const std::string& client_name, const std::string& session_id); /** Release all resources associated with this audiobackend */ int (*deinstantiate) (void); diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index c047c462a91..698bc96c2b0 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -71,7 +71,7 @@ class LIBARDOUR_API AudioEngine : public PortManager, public SessionHandlePtr int discover_backends(); std::vector available_backends() const; std::string current_backend_name () const; - std::shared_ptr set_backend (const std::string& name, const std::string& arg1, const std::string& session_id); + std::shared_ptr set_backend (const std::string& name, const std::string& client_name, const std::string& session_id); std::shared_ptr current_backend() const { return _backend; } bool setup_required () const; bool is_jack () const; diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 43a9a74bdbf..8258bd022b0 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -1015,7 +1015,7 @@ AudioEngine::drop_backend () } std::shared_ptr -AudioEngine::set_backend (const std::string& name, const std::string& arg1, const std::string& session_id) +AudioEngine::set_backend (const std::string& name, const std::string& client_name, const std::string& session_id) { BackendMap::iterator b = _backends.find (name); @@ -1026,7 +1026,7 @@ AudioEngine::set_backend (const std::string& name, const std::string& arg1, cons drop_backend (); try { - if (b->second->instantiate (arg1, session_id)) { + if (b->second->instantiate (client_name, session_id)) { throw failed_constructor (); } diff --git a/libs/backends/alsa/alsa_audiobackend.cc b/libs/backends/alsa/alsa_audiobackend.cc index 943ae0b23db..d8cc8b3f937 100644 --- a/libs/backends/alsa/alsa_audiobackend.cc +++ b/libs/backends/alsa/alsa_audiobackend.cc @@ -2181,7 +2181,7 @@ AlsaAudioBackend::AudioSlave::update_latencies (uint32_t play, uint32_t capt) static std::shared_ptr _instance; static std::shared_ptr backend_factory (AudioEngine& e); -static int instantiate (const std::string& arg1, const std::string& /* session_id */); +static int instantiate (const std::string& client_name, const std::string& /* session_id */); static int deinstantiate (); static bool already_configured (); static bool available (); @@ -2205,9 +2205,9 @@ backend_factory (AudioEngine& e) } static int -instantiate (const std::string& arg1, const std::string& /* session_id */) +instantiate (const std::string& client_name, const std::string& /* session_id */) { - s_instance_name = arg1; + s_instance_name = client_name; return 0; } diff --git a/libs/backends/coreaudio/coreaudio_backend.cc b/libs/backends/coreaudio/coreaudio_backend.cc index 967660a6f8d..090220237c1 100644 --- a/libs/backends/coreaudio/coreaudio_backend.cc +++ b/libs/backends/coreaudio/coreaudio_backend.cc @@ -1529,7 +1529,7 @@ CoreAudioBackend::hw_changed_callback () static std::shared_ptr _instance; static std::shared_ptr backend_factory (AudioEngine& e); -static int instantiate (const std::string& arg1, const std::string& /* session_id */); +static int instantiate (const std::string& client_name, const std::string& /* session_id */); static int deinstantiate (); static bool already_configured (); static bool available (); @@ -1553,9 +1553,9 @@ backend_factory (AudioEngine& e) } static int -instantiate (const std::string& arg1, const std::string& /* session_id */) +instantiate (const std::string& client_name, const std::string& /* session_id */) { - s_instance_name = arg1; + s_instance_name = client_name; return 0; } diff --git a/libs/backends/dummy/dummy_audiobackend.cc b/libs/backends/dummy/dummy_audiobackend.cc index b153189b287..b7016694f3f 100644 --- a/libs/backends/dummy/dummy_audiobackend.cc +++ b/libs/backends/dummy/dummy_audiobackend.cc @@ -1016,7 +1016,7 @@ DummyAudioBackend::main_process_thread () static std::shared_ptr _instance; static std::shared_ptr backend_factory (AudioEngine& e); -static int instantiate (const std::string& arg1, const std::string& /* session_id */); +static int instantiate (const std::string& client_name, const std::string& /* session_id */); static int deinstantiate (); static bool already_configured (); static bool available (); @@ -1040,9 +1040,9 @@ backend_factory (AudioEngine& e) } static int -instantiate (const std::string& arg1, const std::string& /* session_id */) +instantiate (const std::string& client_name, const std::string& /* session_id */) { - s_instance_name = arg1; + s_instance_name = client_name; return 0; } diff --git a/libs/backends/jack/jack_api.cc b/libs/backends/jack/jack_api.cc index 5e437a46416..f3123926c60 100644 --- a/libs/backends/jack/jack_api.cc +++ b/libs/backends/jack/jack_api.cc @@ -25,7 +25,7 @@ static std::shared_ptr backend; static std::shared_ptr jack_connection; static std::shared_ptr backend_factory (AudioEngine& ae); -static int instantiate (const std::string& arg1, const std::string& session_id); +static int instantiate (const std::string& client_name, const std::string& session_id); static int deinstantiate (); static bool already_configured (); static bool available (); @@ -58,10 +58,10 @@ backend_factory (AudioEngine& ae) } static int -instantiate (const std::string& arg1, const std::string& session_id) +instantiate (const std::string& client_name, const std::string& session_id) { try { - jack_connection.reset (new JackConnection (arg1, session_id)); + jack_connection.reset (new JackConnection (client_name, session_id)); backend.reset (); } catch (...) { return -1; diff --git a/libs/backends/jack/jack_connection.cc b/libs/backends/jack/jack_connection.cc index ac1ee247a0f..540bbd6248c 100644 --- a/libs/backends/jack/jack_connection.cc +++ b/libs/backends/jack/jack_connection.cc @@ -50,9 +50,9 @@ static void jack_halted_info_callback (jack_status_t code, const char* reason, v } -JackConnection::JackConnection (const std::string& arg1, const std::string& session_id) +JackConnection::JackConnection (const std::string& client_name, const std::string& session_id) : _jack (0) - , _client_name (arg1) + , _client_name (client_name) , _session_id (session_id) , _probed_buffer_size (0) , _probed_sample_rate (0) diff --git a/libs/backends/portaudio/portaudio_backend.cc b/libs/backends/portaudio/portaudio_backend.cc index 71b88e84bf7..0bf16c89493 100644 --- a/libs/backends/portaudio/portaudio_backend.cc +++ b/libs/backends/portaudio/portaudio_backend.cc @@ -1793,7 +1793,7 @@ PortAudioBackend::process_port_connection_changes () static std::shared_ptr _instance; static std::shared_ptr backend_factory (AudioEngine& e); -static int instantiate (const std::string& arg1, const std::string& /* session_id */); +static int instantiate (const std::string& client_name, const std::string& /* session_id */); static int deinstantiate (); static bool already_configured (); static bool available (); @@ -1817,9 +1817,9 @@ backend_factory (AudioEngine& e) } static int -instantiate (const std::string& arg1, const std::string& /* session_id */) +instantiate (const std::string& client_name, const std::string& /* session_id */) { - s_instance_name = arg1; + s_instance_name = client_name; return 0; } diff --git a/libs/backends/pulseaudio/pulseaudio_backend.cc b/libs/backends/pulseaudio/pulseaudio_backend.cc index de29b1a30fb..39b9d9759fc 100644 --- a/libs/backends/pulseaudio/pulseaudio_backend.cc +++ b/libs/backends/pulseaudio/pulseaudio_backend.cc @@ -1084,7 +1084,7 @@ PulseAudioBackend::main_process_thread () static std::shared_ptr _instance; static std::shared_ptr backend_factory (AudioEngine& e); -static int instantiate (const std::string& arg1, const std::string& /* session_id */); +static int instantiate (const std::string& client_name, const std::string& /* session_id */); static int deinstantiate (); static bool already_configured (); static bool available (); @@ -1108,9 +1108,9 @@ backend_factory (AudioEngine& e) } static int -instantiate (const std::string& arg1, const std::string& /* session_id */) +instantiate (const std::string& client_name, const std::string& /* session_id */) { - s_instance_name = arg1; + s_instance_name = client_name; return 0; }