diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-11-12 20:51:00 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-11-13 00:12:26 +0100 |
| commit | 1b3c5f3babffed992786c477baa34ce86eae1ad2 (patch) | |
| tree | 201087e192e3e7965fcc2863ce4281a2e3d01ed3 | |
| parent | b02059e59d96733f79eb17a01bb960e582b647e3 (diff) | |
Add unbound audio API selection choice.
| -rw-r--r-- | src/wx/config_dialog.cc | 37 | ||||
| -rw-r--r-- | src/wx/config_dialog.h | 3 |
2 files changed, 39 insertions, 1 deletions
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index aab1f1feb..50e067aae 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -19,8 +19,10 @@ */ +#include "audio_api.h" #include "audio_mapping_view.h" #include "check_box.h" +#include "dcpomatic_choice.h" #include "config_dialog.h" #include "dcpomatic_button.h" #include "film_viewer.h" @@ -862,8 +864,10 @@ SoundPage::setup () _sound = new CheckBox (_panel, _("Play sound via")); table->Add (_sound, wxGBPosition (r, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); auto s = new wxBoxSizer (wxHORIZONTAL); + _sound_api = new Choice(_panel); + s->Add(_sound_api); _sound_output = new wxChoice (_panel, wxID_ANY); - s->Add (_sound_output, 0); + s->Add(_sound_output, 0, wxLEFT, DCPOMATIC_SIZER_X_GAP); _sound_output_details = new wxStaticText (_panel, wxID_ANY, wxT("")); s->Add (_sound_output_details, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, DCPOMATIC_SIZER_X_GAP); table->Add (s, wxGBPosition(r, 1)); @@ -884,6 +888,10 @@ SoundPage::setup () font.SetPointSize (font.GetPointSize() - 1); _sound_output_details->SetFont (font); + for (auto const& api: audio_apis()) { + _sound_api->add(api.name(), new wxStringClientData(api.id())); + } + auto& audio = _viewer->audio_backend(); for (unsigned int i = 0; i < audio.getDeviceCount(); ++i) { try { @@ -945,6 +953,20 @@ SoundPage::config_changed () checked_set (_sound, config->sound ()); + auto const current_api = get_sound_api(); + auto const configured_api = id_to_audio_api(config->sound_api()).id(); + + if (current_api != configured_api) { + /* Update _sound_api with the configured value */ + unsigned int index = 0; + while (index < _sound_api->GetCount()) { + if (string_client_data(_sound_api->GetClientObject(index)) == configured_api) { + _sound_api->SetSelection(index); + } + ++index; + } + } + auto const current_so = get_sound_output (); optional<string> configured_so; @@ -1025,6 +1047,19 @@ SoundPage::setup_sensitivity () _sound_output->Enable (_sound->GetValue()); } + +optional<string> +SoundPage::get_sound_api() const +{ + auto const sel = _sound_api->get(); + if (!sel) { + return {}; + } + + return index_to_audio_api(*sel).id(); +} + + /** @return Currently-selected preview sound output in the dialogue */ optional<string> SoundPage::get_sound_output() const diff --git a/src/wx/config_dialog.h b/src/wx/config_dialog.h index a98bba1af..c43d29ff7 100644 --- a/src/wx/config_dialog.h +++ b/src/wx/config_dialog.h @@ -50,6 +50,7 @@ LIBDCP_ENABLE_WARNINGS class AudioMappingView; class CheckBox; +class Choice; class FilmViewer; @@ -208,6 +209,7 @@ private: void setup () override; void config_changed () override; + boost::optional<std::string> get_sound_api() const; boost::optional<std::string> get_sound_output() const; void sound_changed (); void sound_output_changed (); @@ -216,6 +218,7 @@ private: void reset_to_default (); CheckBox* _sound; + Choice* _sound_api; wxChoice* _sound_output; wxStaticText* _sound_output_details; AudioMappingView* _map; |
