diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2015-08-11 13:02:25 +1000 |
---|---|---|
committer | Tim Mayberry <mojofunk@gmail.com> | 2015-08-11 14:00:57 +1000 |
commit | a8daa369013c272491971765a365acb90b08d32d (patch) | |
tree | 3733ccff6addea44dbb5bd60d4328db87eadb530 /gtk2_ardour | |
parent | e8b2d7a85ba4f747a6752b708744f9a27c4c80e5 (diff) |
Use a union of all sample rates and buffer sizes for all devices in EngineControl
Using just the input device doesn't work in the case that the input device is
an invalid/None device
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/engine_dialog.cc | 69 | ||||
-rw-r--r-- | gtk2_ardour/engine_dialog.h | 7 |
2 files changed, 68 insertions, 8 deletions
diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index f4481e22f8..d753d92dd7 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -1121,8 +1121,32 @@ EngineControl::driver_changed () } } +vector<float> +EngineControl::get_sample_rates_for_all_devices () +{ + boost::shared_ptr<ARDOUR::AudioBackend> backend = + ARDOUR::AudioEngine::instance ()->current_backend (); + vector<float> input_rates; + vector<float> output_rates; + vector<float> all_rates; + + if (backend->use_separate_input_and_output_devices ()) { + input_rates = backend->available_sample_rates (get_input_device_name ()); + output_rates = backend->available_sample_rates (get_output_device_name ()); + + std::set_union (input_rates.begin (), + input_rates.end (), + output_rates.begin (), + output_rates.end (), + std::back_inserter (all_rates)); + } else { + all_rates = backend->available_sample_rates (get_device_name ()); + } + return all_rates; +} + void -EngineControl::set_samplerate_popdown_strings (const std::string& device_name) +EngineControl::set_samplerate_popdown_strings () { DEBUG_ECONTROL ("set_samplerate_popdown_strings"); boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend(); @@ -1131,7 +1155,9 @@ EngineControl::set_samplerate_popdown_strings (const std::string& device_name) vector<string> s; if (_have_control) { - sr = backend->available_sample_rates (device_name); + + sr = get_sample_rates_for_all_devices (); + } else { sr.push_back (8000.0f); @@ -1173,16 +1199,41 @@ EngineControl::set_samplerate_popdown_strings (const std::string& device_name) } } +vector<uint32_t> +EngineControl::get_buffer_sizes_for_all_devices () +{ + boost::shared_ptr<ARDOUR::AudioBackend> backend = + ARDOUR::AudioEngine::instance ()->current_backend (); + vector<uint32_t> input_sizes; + vector<uint32_t> output_sizes; + vector<uint32_t> all_sizes; + + if (backend->use_separate_input_and_output_devices ()) { + input_sizes = backend->available_buffer_sizes (get_input_device_name ()); + output_sizes = backend->available_buffer_sizes (get_output_device_name ()); + + std::set_union (input_sizes.begin (), + input_sizes.end (), + output_sizes.begin (), + output_sizes.end (), + std::back_inserter (all_sizes)); + } else { + all_sizes = backend->available_buffer_sizes (get_device_name ()); + } + return all_sizes; +} + void -EngineControl::set_buffersize_popdown_strings (const std::string& device_name) +EngineControl::set_buffersize_popdown_strings () { DEBUG_ECONTROL ("set_buffersize_popdown_strings"); boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend(); vector<uint32_t> bs; vector<string> s; + string device_name; if (_have_control) { - bs = backend->available_buffer_sizes (device_name); + bs = get_buffer_sizes_for_all_devices (); } else if (backend->can_change_buffer_size_when_running()) { bs.push_back (8); bs.push_back (16); @@ -1201,6 +1252,12 @@ EngineControl::set_buffersize_popdown_strings (const std::string& device_name) s.push_back (bufsize_as_string (*x)); } + if (backend->use_separate_input_and_output_devices ()) { + device_name = get_input_device_name (); + } else { + device_name = get_device_name (); + } + if (!s.empty()) { buffer_size_combo.set_sensitive (true); set_popdown_strings (buffer_size_combo, s); @@ -1266,8 +1323,8 @@ EngineControl::device_changed () /* backends that support separate devices, need to ignore * the device-name - and use the devies set above */ - set_samplerate_popdown_strings (device_name_in); - set_buffersize_popdown_strings (device_name_in); + set_samplerate_popdown_strings (); + set_buffersize_popdown_strings (); /* XXX theoretically need to set min + max channel counts here */ diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h index 7bc0b59a30..c507b13968 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -138,6 +138,9 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList { std::string bufsize_as_string (uint32_t); + std::vector<float> get_sample_rates_for_all_devices (); + std::vector<uint32_t> get_buffer_sizes_for_all_devices (); + float get_rate() const; uint32_t get_buffer_size() const; uint32_t get_input_channels() const; @@ -158,8 +161,8 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList { bool set_device_popdown_strings (); bool set_input_device_popdown_strings (); bool set_output_device_popdown_strings (); - void set_samplerate_popdown_strings (const std::string& dev_name); - void set_buffersize_popdown_strings (const std::string& dev_name); + void set_samplerate_popdown_strings (); + void set_buffersize_popdown_strings (); void list_devices (); void show_buffer_duration (); |