Catch exceptions from RtAudio::startStream() in all cases.
authorCarl Hetherington <cth@carlh.net>
Sun, 28 Nov 2021 21:00:21 +0000 (22:00 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 28 Nov 2021 21:01:38 +0000 (22:01 +0100)
src/wx/film_viewer.cc
src/wx/film_viewer.h

index 259e2bc16a4a02b5ca078add1d95a8251b4851cb..ac12bea3f6f9870a001e976b20d6f5d0eb1d8e0a 100644 (file)
@@ -319,16 +319,31 @@ 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
index 0291b660fa403ea0e57359dc286216d5143be7f0..64ac885e37bdcbe73b0637332c8a2007c28534be 100644 (file)
@@ -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;