Okay. With some further testing, I've written a small code that is a little similar to yours that moves the loop points automatically very quickly. Not even that far but they must change.
#include <SFML/Audio.hpp>
int main()
{
sf::Music music;
if (!music.openFromFile("music.ogg"))
return EXIT_FAILURE;
music.setLoop(true);
const sf::Time timespanOffsetStep{ sf::seconds(16.f) };
const sf::Time timespanLength{ sf::seconds(1.f) };
const sf::Time resetLoopPointsTime{ sf::seconds(0.03f) };
unsigned int loopPointStart{ 0u };
sf::Clock clock;
music.play();
while (!sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
{
if (clock.getElapsedTime() > resetLoopPointsTime)
{
++loopPointStart;
if (loopPointStart > 1u)
loopPointStart = 0u;
music.setLoopPoints(sf::Music::TimeSpan(static_cast<float>(loopPointStart) * timespanOffsetStep, timespanLength));
clock.restart();
}
}
}
Please can some people test this code.
The music file is a 3 and a half minute song.
The first thing you may notice is that even though the only thing that is happening is the loop points are moving, the music playback itself is severly affected.
Occasionally, it may stop a couple of seconds in. Sometimes, it may not.
These are the most 'reliable' settings for me to get it to stop. Feel free to change the 3 const times to experiment with its effects.
I would say that the setting the music's loop points should be implemented in such a way that it does not affect the music performance itself. Just changing it once, I noticed the slight delay 'click'. The code above makes this happen often so you can see it more obviously.
On top of that, and also getting back to the original poster's problem, this can also cause the music to just stop dead. There must be something somewhere that causes setting a loop point to stop the music, although I suspect that it's linked to the fact that the performance is affected since it must be changing the stream every time the loop points are altered.