summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-08-29 20:33:45 +0200
committerCarl Hetherington <cth@carlh.net>2020-08-29 20:33:45 +0200
commit47245166de02206389a0cb18aae7de35f8517c7d (patch)
tree3648813c1b22accc9ef76dece9600d3e205c96e4 /src
parentffb5e31b6a35a09f40afef45b787aa8bb345071d (diff)
Try to fix crashes when things go wrong with getDeviceInfo.v2.15.99
Diffstat (limited to 'src')
-rw-r--r--src/wx/config_dialog.cc22
-rw-r--r--src/wx/film_viewer.cc20
2 files changed, 30 insertions, 12 deletions
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc
index 0a546dc91..352c8ae48 100644
--- a/src/wx/config_dialog.cc
+++ b/src/wx/config_dialog.cc
@@ -878,9 +878,17 @@ SoundPage::setup ()
RtAudio audio (DCPOMATIC_RTAUDIO_API);
for (unsigned int i = 0; i < audio.getDeviceCount(); ++i) {
- RtAudio::DeviceInfo dev = audio.getDeviceInfo (i);
- if (dev.probed && dev.outputChannels > 0) {
- _sound_output->Append (std_to_wx (dev.name));
+ try {
+ RtAudio::DeviceInfo dev = audio.getDeviceInfo (i);
+ if (dev.probed && dev.outputChannels > 0) {
+ _sound_output->Append (std_to_wx (dev.name));
+ }
+#ifdef DCPOMATIC_USE_RTERROR
+ } catch (RtError&) {
+#else
+ } catch (RtAudioError&) {
+#endif
+ /* Something went wrong so let's just ignore that device */
}
}
@@ -913,7 +921,13 @@ SoundPage::sound_output_changed ()
{
RtAudio audio (DCPOMATIC_RTAUDIO_API);
optional<string> const so = get_sound_output();
- if (!so || *so == audio.getDeviceInfo(audio.getDefaultOutputDevice()).name) {
+ string default_device;
+ try {
+ default_device = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name;
+ } catch (RtAudioError&) {
+ /* Never mind */
+ }
+ if (!so || *so == default_device) {
Config::instance()->unset_sound_output ();
} else {
Config::instance()->set_sound_output (*so);
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index d3a6c12e4..5f609856f 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -527,8 +527,12 @@ FilmViewer::config_changed (Config::Property p)
unsigned int st = 0;
if (Config::instance()->sound_output()) {
while (st < _audio.getDeviceCount()) {
- if (_audio.getDeviceInfo(st).name == Config::instance()->sound_output().get()) {
- break;
+ try {
+ if (_audio.getDeviceInfo(st).name == Config::instance()->sound_output().get()) {
+ break;
+ }
+ } catch (RtAudioError&) {
+ /* Something went wrong with that device so we don't want to use it anyway */
}
++st;
}
@@ -539,19 +543,19 @@ FilmViewer::config_changed (Config::Property p)
st = _audio.getDefaultOutputDevice();
}
- _audio_channels = _audio.getDeviceInfo(st).outputChannels;
-
- RtAudio::StreamParameters sp;
- sp.deviceId = st;
- sp.nChannels = _audio_channels;
- sp.firstChannel = 0;
try {
+ _audio_channels = _audio.getDeviceInfo(st).outputChannels;
+ RtAudio::StreamParameters sp;
+ sp.deviceId = st;
+ sp.nChannels = _audio_channels;
+ sp.firstChannel = 0;
_audio.openStream (&sp, 0, RTAUDIO_FLOAT32, 48000, &_audio_block_size, &rtaudio_callback, this);
#ifdef DCPOMATIC_USE_RTERROR
} catch (RtError& e) {
#else
} catch (RtAudioError& e) {
#endif
+ _audio_channels = 0;
error_dialog (
_video_view->get(),
_("Could not set up audio output. There will be no audio during the preview."), std_to_wx(e.what())