*/
+#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"
#include "nag_dialog.h"
#include "static_text.h"
#include <dcp/file.h>
restart->SetFont (font);
++r;
- _set_language->Bind (wxEVT_CHECKBOX, bind (&GeneralPage::set_language_changed, this));
+ _set_language->bind(&GeneralPage::set_language_changed, this);
_language->Bind (wxEVT_CHOICE, bind (&GeneralPage::language_changed, this));
}
table->Add (_check_for_test_updates, wxGBPosition (r, 0), wxGBSpan (1, 2));
++r;
- _check_for_updates->Bind (wxEVT_CHECKBOX, bind (&GeneralPage::check_for_updates_changed, this));
- _check_for_test_updates->Bind (wxEVT_CHECKBOX, bind (&GeneralPage::check_for_test_updates_changed, this));
+ _check_for_updates->bind(&GeneralPage::check_for_updates_changed, this);
+ _check_for_test_updates->bind(&GeneralPage::check_for_test_updates_changed, this);
}
void
_sound = new CheckBox (_panel, _("Play sound via"));
table->Add (_sound, wxGBPosition (r, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
- wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ 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));
font.SetPointSize (font.GetPointSize() - 1);
_sound_output_details->SetFont (font);
- RtAudio audio (DCPOMATIC_RTAUDIO_API);
+ for (auto const& api: audio_apis()) {
+ _sound_api->add(api.name(), new wxStringClientData(api.id()));
+ }
+
+ update_sound_outputs();
+
+ _sound->bind(&SoundPage::sound_changed, this);
+ _sound_api->bind(&SoundPage::sound_api_changed, this);
+ _sound_output->Bind(wxEVT_CHOICE, bind(&SoundPage::sound_output_changed, this));
+ _map->Changed.connect(bind(&SoundPage::map_changed, this, _1));
+ _reset_to_default->Bind(wxEVT_BUTTON, bind(&SoundPage::reset_to_default, this));
+}
+
+
+
+void
+SoundPage::update_sound_outputs()
+{
+ _sound_output->Clear();
+ auto& audio = _viewer->audio_backend();
for (unsigned int i = 0; i < audio.getDeviceCount(); ++i) {
try {
auto dev = audio.getDeviceInfo (i);
/* Something went wrong so let's just ignore that device */
}
}
-
- _sound->Bind (wxEVT_CHECKBOX, bind(&SoundPage::sound_changed, this));
- _sound_output->Bind (wxEVT_CHOICE, bind(&SoundPage::sound_output_changed, this));
- _map->Changed.connect (bind(&SoundPage::map_changed, this, _1));
- _reset_to_default->Bind (wxEVT_BUTTON, bind(&SoundPage::reset_to_default, this));
}
+
void
SoundPage::reset_to_default ()
{
Config::instance()->set_sound (_sound->GetValue ());
}
+
+void
+SoundPage::sound_api_changed()
+{
+ Config::instance()->set_sound_api(id_to_audio_api(get_sound_api()).id());
+ Config::instance()->unset_sound_output();
+}
+
+
void
SoundPage::sound_output_changed ()
{
- RtAudio audio (DCPOMATIC_RTAUDIO_API);
+ auto& audio = _viewer->audio_backend();
auto const so = get_sound_output();
string default_device;
try {
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;
+ }
+ }
+
+ update_sound_outputs();
+
auto const current_so = get_sound_output ();
optional<string> configured_so;
+ auto& audio = _viewer->audio_backend();
+
if (config->sound_output()) {
configured_so = config->sound_output().get();
} else {
/* No configured output means we should use the default */
- RtAudio audio (DCPOMATIC_RTAUDIO_API);
try {
configured_so = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name;
} catch (RtAudioError&) {
}
}
- RtAudio audio (DCPOMATIC_RTAUDIO_API);
-
map<int, wxString> apis;
apis[RtAudio::MACOSX_CORE] = _("CoreAudio");
apis[RtAudio::WINDOWS_ASIO] = _("ASIO");
_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 ()
+SoundPage::get_sound_output() const
{
int const sel = _sound_output->GetSelection ();
if (sel == wxNOT_FOUND) {
- return optional<string> ();
+ return {};
}
return wx_to_std (_sound_output->GetString (sel));
wxBitmap
LocationsPage::GetLargeIcon () const
{
- return wxBitmap(bitmap_path("locations.png"), wxBITMAP_TYPE_PNG);
+ return wxBitmap(icon_path("locations"), wxBITMAP_TYPE_PNG);
}
#endif