SFML community forums
Help => Audio => Topic started by: Raptormeat on August 26, 2016, 01:01:04 am
-
I have a game that has been using SFML for a few years now (thank you!). I just upgraded to 2.4 (from 2.2) and I'm experiencing a new problem.
I have a custom sf::InputStream subclass which loads up encrypted music data from a stream and decrypts it for the audio system to play. This was working before the upgrade.
I have a single sf::Music object which I use to play all of my music. When one song is complete or I want to switch, I stop the music, close the input stream, then open a new file using the same stream and play the stream using the same music object.
So, when I start the game, the first music (the title music) plays just fine. However when I start gameplay and the title music switches to another song, the game freezes. Putting some breakpoints in the InputStream, I can see that read() is called a few times to load up some data. However then seek( 0 ) is called forever. The call to openFromStream() never returns and the program hangs.
Anyway I fully understand that this is probably an obscure problem on my end, but considering it was a new problem I thought it might be worth posting in case it was a known issue.
-
Update: I have found that, instead of just stopping the sf::Music object, if I delete it and recreate it, then there is no hang. Previously the music object was stack-allocated and I just reused it for every song.
Still no idea why I was getting the hang. I'm trying to figure out whether I had screwed something up, but the interface is so simple it's hard to know what that might be.