Speculative fixes for hangs when audio stream cannot be opened.
[dcpomatic.git] / src / wx / film_viewer.cc
index 9493a55c9ee7c949098dd28643cab9277f4ee899..0bb582c66dffe8d6b46ca649eee103f20c53dc5d 100644 (file)
@@ -253,7 +253,7 @@ FilmViewer::recreate_butler ()
        }
 
        _butler.reset (new Butler (_player, _film->log(), map, _audio_channels));
-       if (!Config::instance()->sound()) {
+       if (!Config::instance()->sound() && !_audio.isStreamOpen()) {
                _butler->disable_audio ();
        }
 
@@ -290,7 +290,7 @@ FilmViewer::get ()
                return;
        }
 
-       if ((time() - video.second) > one_video_frame()) {
+       if (_playing && (time() - video.second) > one_video_frame()) {
                /* Too late; just drop this frame before we try to get its image (which will be the time-consuming
                   part if this frame is J2K).
                */
@@ -743,8 +743,6 @@ FilmViewer::config_changed (Config::Property p)
 
                _audio_channels = _audio.getDeviceInfo(st).outputChannels;
 
-               recreate_butler ();
-
                RtAudio::StreamParameters sp;
                sp.deviceId = st;
                sp.nChannels = _audio_channels;
@@ -761,6 +759,7 @@ FilmViewer::config_changed (Config::Property p)
                                wxString::Format (_("Could not set up audio output (%s).  There will be no audio during the preview."), e.what())
                                );
                }
+               recreate_butler ();
 
        } else {
                _audio_channels = 0;