I'm having the same issue OP is getting. For some reference, here's the offending function in my app:
void onMouseUp(int x, int y, unsigned b)
{
if (b != sf::Mouse::Left)
return;
if (mouseHoverProgressBar)
{
if (playMode == PLAY_FILE_BUFFER)
{
... irrelevant code here
}
else if (playMode == PLAY_FILE_STREAM)
{
sf::Time t = audioStream->getDuration() * (static_cast<float>(x) / rw->getSize().x);
audioStream->setPlayingOffset(t); // <<< PROBLEMS HAPPEN IN HERE SOMEWHERE.
// audioStream is an instance of a child class of sf::Music.
//printf(">>>seeking=%f | duration=%f\n",t.asSeconds(),audioStream->getDuration().asSeconds());
}
}
}
The program was working flawlessly using sfml 2.2, before upgrading it to 2.3.2 today.
That print statement I have being printed out displays exactly what the OP was having trouble with, for instance on a stereo 200s flac file, seeking to anything above 100s will cause the song to repeat. Seeking to say, something like 99s will bring me very near the end of the song.
In this print example, I seek to just almost half way through the audio, displays that it's only a few minutes through the song, but the last few seconds of the audio is playing instead.
>>>seeking=176.484055 | duration=365.533325I also tried using an 8 channel flac file, and as I've expected and you've probably guessed, the song fails to seek properly after 1/8th (12.5%) of the duration, and setting the offset to 1/16th of the duration will bring me half way through the song. So, there's some sort of flawed math happening during seeking that's likely not taking into account of the number of channels.
If I were to guess,
this line probably needs to factor in the number of channels in the source file.
I've also tested my program against .ogg and .wav files and they did not share the same issue. Only .flac files have this problem.