playbin: buggy seek to beginning after end of audio playback
Tested with gstreamer 1.22.
Play a sound with playbin.
When the sound has finished playing, perform a flushing seek to the beginning of the buffer.
Replay the sound.
Then the following happens:
-
If the sound is long enough (longer than 2 seconds for example), it replays correctly, but a part at the beginning of the sound is missing in an audible manner (i estimate a few milliseconds, it can be eard with sounds with a fast attack). If replaying continuously, the length of the missing segment at the beginning can vary slightly in an audible manner
-
If the sound is short enough (tested with a sound of 0.1s), after two or three replays, playbin is then unable to replay the sound
I have put code and sound samples to reproduce this bug here: https://github.com/mimbert/gst-playbin-seek-test There is a short bass drum sound of 0.1s to show the second behaviour, and the same sample longer, with reverberation added, to show the first behaviour.
There is a vagrant file to check the bug in different environments. The bug occurs on debian testing with pipewire acting as the pulseaudio server, gstreamer 1.22 (vagrant box name debtesting
), and it does not occur on debian stable with regular pulseaudio, with gstreamer 1.18 (vagrant box name debtstable
). Interrestingly, it does not occur on debian stable with regular pulseaudio, with only gstreamer 1.22 taken from debian testing (vagrant box name debstable2
), so i don't know if the bug is actually in gstreamer or caused by the specific interaction between gstreamer and pipewire.
I also made some tests by using explicit audio sinks instead of the default automatic audio sink and got these results on my development laptop on debian testing, gstreamer 1.22, pipewire (pipewire being the pulseaudio server and the jack server):
-
pulsesink (pipewire): the bug occurs
-
jackaudiosink: the bug occurs, but less. I can hear that still there is a small part of the sound (smaller than pulsink) missing at beginning after the first play/seek to beginning.
-
openalsink: works perfectly, no bug (in this situation, openal is a client of the pulseaudio (pipewire) server).
The code that allows selecting the sink is in the misc-tests
branch of https://github.com/mimbert/gst-playbin-seek-test
For example i have run it like that:
$ ./gst-playbin-seek-test.py --sink=pulsesink bass_drum_reverb.wav
$ ./gst-playbin-seek-test.py "--sink=jackaudiosink/connect=explicit/port-names=USB Audio #1:playback_FL,USB Audio #1:playback_FR" bass_drum_reverb.wav
$ ./gst-playbin-seek-test.py --sink=openalsink bass_drum_reverb.wav