X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ffilm_viewer.cc;h=cd5b6e2eafd47d1576fa08584683d3e3b0c61fcf;hb=4f9314a311de379b105741273a15821da62a75cc;hp=a93b4226e97084f228b104d5957e8351c0b5e7d7;hpb=081525ef1c392465fc5a0bb4be79af8e84655bc4;p=dcpomatic.git diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index a93b4226e..cd5b6e2ea 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -223,7 +223,7 @@ FilmViewer::recreate_butler () _player, Config::instance()->audio_mapping(_audio_channels), _audio_channels, - bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), + boost::bind(&PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, j2k_gl_optimised ? Image::Alignment::COMPACT : Image::Alignment::PADDED, true, @@ -283,9 +283,9 @@ FilmViewer::calculate_sizes () auto const container = _film->container (); - auto const dpi_scale_factor = _video_view->get()->GetDPIScaleFactor(); - int const video_view_width = std::round(_video_view->get()->GetSize().x * dpi_scale_factor); - int const video_view_height = std::round(_video_view->get()->GetSize().y * dpi_scale_factor); + auto const scale = dpi_scale_factor (_video_view->get()); + int const video_view_width = std::round(_video_view->get()->GetSize().x * scale); + int const video_view_height = std::round(_video_view->get()->GetSize().y * scale); auto const view_ratio = float(video_view_width) / video_view_height; auto const film_ratio = container ? container->ratio () : 1.78; @@ -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