Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Hang when playing second music with an sf::InputStream with 2.4  (Read 2730 times)

0 Members and 1 Guest are viewing this topic.

Raptormeat

  • Newbie
  • *
  • Posts: 4
    • View Profile
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.
« Last Edit: August 26, 2016, 01:29:06 am by Raptormeat »

Raptormeat

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Hang when playing second music with an sf::InputStream with 2.4
« Reply #1 on: August 26, 2016, 02:54:04 am »
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.