This has been a long-time issue for me with SFML and I always seem to have to create my own workaround for it.
As Ryan Bram previously mentioned, this problem can be resolved with zero interface changes merely by pulling the loop information out of the audio file metadata.
libsndfile already provides the ability to extract some metadata. While I was unable to extract the exact "LOOPSTART" and "LOOPLENGTH" metadata fields that he mentioned using libsndfile, I was able to extract similar strings by putting them in the "comments" field of the audio file.
Personally, I think a LOOPLENGTH identifier is pointless, since it just adds more complication when you can just use EOF. All we really need is a LOOPSTART.
The key for the change is in the SoundFile class. All this class has to do is:
1) In SoundFile::initialize: Extract a loop start point from the sound file metadata (start point should be a sample offset for maximum precision and not a time offset)
2) In SoundFile::read: Once EOF is reached, merely seek the file back to the loop point (if specified)
Both of these steps require minimal code changes (maybe 10-15 lines), do not really impact larger design issues, and do not require any interface changes. The only externally visible change you'd need is to the documentation to make note of the feature.
I've made a similar change in my local copy of SFML 2.0 and it works great. I'd be okay with applying the change (after cleaning it up) to the latest SFML bulid... but only if it's going to be welcome.
So what do you guys think?
EDIT:
Laurent mentioned this on the first page:
Using specific metadata is not an option, since SFML supports many standard audio formats.
This is why I suggest extracting text from the 'comments' field. This is generic enough to be common across all audio formats. And the functionality for reading this metadata is already in libsndfile.