Seek the player before creating a new butler.
authorCarl Hetherington <cth@carlh.net>
Wed, 19 Mar 2025 00:04:43 +0000 (01:04 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 19 Mar 2025 00:08:06 +0000 (01:08 +0100)
Consider the case where we switch to a different sound card when the
player GUI is showing frame 0.

At this point, the butler will be full up to some readahead, so the
player will also "think" it's at the readahead position.

If we create a new butler, the first get of video from the new buffer
would previously return a frame from the readahead position (because
that's where the player was).

Since the new butler would coincide with the audio stream position
being 0, the video thread would think it was ahead by the ring buffer
readahead and so would sleep for quite a long time.

Meanwhile audio arrives and is played, and when the video thread finally
wakes it is a long time behind the audio.

src/wx/film_viewer.cc

index a7a2ab98449473e49e5983b5ebc9d1d6f5c664fd..26c3467aad81b305423e707a4fee75c6f71cca42 100644 (file)
@@ -238,6 +238,7 @@ FilmViewer::create_butler()
 #endif
 
        DCPOMATIC_ASSERT(_player);
+       _player->seek(_video_view->position(), true);
 
        auto& audio = AudioBackend::instance()->rtaudio();