diff options
| -rw-r--r-- | src/wx/film_viewer.cc | 11 | ||||
| -rw-r--r-- | src/wx/film_viewer.h | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 40d3be65c..dcee453d4 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -89,6 +89,7 @@ rtaudio_callback(void* out, void *, unsigned int frames, double, RtAudioStreamSt FilmViewer::FilmViewer(wxWindow* p, bool wake) : _closed_captions_dialog(new ClosedCaptionsDialog(p, this)) , _stream_time(0) + , _stream_time_update_needed(true) { #if wxCHECK_VERSION(3, 1, 0) switch (Config::instance()->video_view_type()) { @@ -354,7 +355,8 @@ FilmViewer::start_audio_stream_if_open() auto& audio = AudioBackend::instance()->rtaudio(); if (audio.isStreamOpen()) { - audio.setStreamTime(_video_view->position().seconds()); + _stream_time = _video_view->position().seconds(); + _stream_time_update_needed = true; auto error = AudioBackend::instance()->start_stream(); if (error) { _audio_channels = 0; @@ -729,7 +731,12 @@ FilmViewer::audio_callback(void* out_p, unsigned int frames) { auto& audio = AudioBackend::instance()->rtaudio(); - _stream_time = audio.getStreamTime(); + if (_stream_time_update_needed) { + audio.setStreamTime(_stream_time); + _stream_time_update_needed = false; + } else { + _stream_time = audio.getStreamTime(); + } while (true) { auto t = _butler->get_audio(Butler::Behaviour::NON_BLOCKING, reinterpret_cast<float*>(out_p), frames); diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index e1360e7c0..6d08df368 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -237,6 +237,8 @@ private: * time in seconds. */ std::atomic<double> _stream_time; + /** true if we need to call setStreamTime() with the current _stream_time */ + std::atomic<bool> _stream_time_update_needed; boost::signals2::scoped_connection _config_changed_connection; }; |
