summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-11-28 22:00:21 +0100
committerCarl Hetherington <cth@carlh.net>2021-11-28 22:01:38 +0100
commit30c07e4fa2b4eeb3f5e5b21b9ccbc63b28226690 (patch)
tree70ed3a252fa4f3e250a37911412654ff0aeb9bd1 /src
parentb0e863770782b701162075d01eceda60566b7eef (diff)
Catch exceptions from RtAudio::startStream() in all cases.
Diffstat (limited to 'src')
-rw-r--r--src/wx/film_viewer.cc36
-rw-r--r--src/wx/film_viewer.h1
2 files changed, 21 insertions, 16 deletions
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index 259e2bc16..ac12bea3f 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -320,15 +320,30 @@ FilmViewer::suspend ()
void
+FilmViewer::start_audio_stream_if_open ()
+{
+ if (_audio.isStreamOpen()) {
+ _audio.setStreamTime (_video_view->position().seconds());
+ try {
+ _audio.startStream ();
+ } catch (RtAudioError& e) {
+ _audio_channels = 0;
+ error_dialog (
+ _video_view->get(),
+ _("There was a problem starting audio playback. Please try another audio output device in Preferences."), std_to_wx(e.what())
+ );
+ }
+ }
+}
+
+
+void
FilmViewer::resume ()
{
DCPOMATIC_ASSERT (_suspended > 0);
--_suspended;
if (_playing && !_suspended) {
- if (_audio.isStreamOpen()) {
- _audio.setStreamTime (_video_view->position().seconds());
- _audio.startStream ();
- }
+ start_audio_stream_if_open ();
_video_view->start ();
}
}
@@ -358,18 +373,7 @@ FilmViewer::start ()
/* Take the video view's idea of position as our `playhead' and start the
audio stream (which is the timing reference) there.
*/
- if (_audio.isStreamOpen()) {
- _audio.setStreamTime (_video_view->position().seconds());
- try {
- _audio.startStream ();
- } catch (RtAudioError& e) {
- _audio_channels = 0;
- error_dialog (
- _video_view->get(),
- _("There was a problem starting audio playback. Please try another audio output device in Preferences."), std_to_wx(e.what())
- );
- }
- }
+ start_audio_stream_if_open ();
_playing = true;
/* Calling start() below may directly result in Stopped being emitted, and if that
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index 0291b660f..64ac885e3 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -161,6 +161,7 @@ private:
void config_changed (Config::Property);
void film_length_change ();
void ui_finished ();
+ void start_audio_stream_if_open ();
dcpomatic::DCPTime uncorrected_time () const;
Frame average_latency () const;