diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-06-18 00:46:22 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-06-18 00:46:22 +0100 |
| commit | 450b235d586b862ecd61a0a41b4125fffe8a86c1 (patch) | |
| tree | c80cbfae015173df6279c236f617549644c12801 /src | |
| parent | 733c0a0152b802ac43efe40806ad86cf6f4662da (diff) | |
Try to avoid crash on opening preferences on a machine with no audio devices.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/config_dialog.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 796972384..03dae5281 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -329,21 +329,25 @@ private: checked_set (_preview_sound, config->preview_sound()); optional<string> const current_so = get_preview_sound_output (); - string configured_so; + optional<string> configured_so; if (config->preview_sound_output()) { configured_so = config->preview_sound_output().get(); } else { /* No configured output means we should use the default */ RtAudio audio (DCPOMATIC_RTAUDIO_API); - configured_so = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name; + try { + configured_so = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name; + } catch (RtAudioError& e) { + /* Probably no audio devices at all */ + } } - if (!current_so || *current_so != configured_so) { + if (configured_so && current_so != configured_so) { /* Update _preview_sound_output with the configured value */ unsigned int i = 0; while (i < _preview_sound_output->GetCount()) { - if (_preview_sound_output->GetString(i) == std_to_wx(configured_so)) { + if (_preview_sound_output->GetString(i) == std_to_wx(*configured_so)) { _preview_sound_output->SetSelection (i); break; } |
