SFML community forums

Help => Audio => Topic started by: kr3nshaw on June 10, 2019, 11:04:21 am

Title: Music thread is stuck waiting
Post by: kr3nshaw on June 10, 2019, 11:04:21 am
If one track is playing on loop and I switch to another track, there's no issues. However, if a track finishes playing and I switch to another track, the program hangs. Specifically, it gets stuck in the stop method of openFromStream. Can anybody suggest why this might be?
Title: Re: Music thread is stuck waiting
Post by: eXpl0it3r on June 10, 2019, 02:12:15 pm
What SFML version?
Can you provide a minimal but complete example?
Title: Re: Music thread is stuck waiting
Post by: kr3nshaw on June 10, 2019, 02:20:57 pm
The version is 2.5.1.

void AudioService::LoadMusic(string fileName)
{
   // Hack to release the stream so we can overwrite it
   bgm.openFromMemory(0, 0);

   archive->open(fileName);

   bgm.openFromStream(*archive);

   if (archive->GetMetadataB())
   {
      bgm.setLoopPoints(Music::TimeSpan(milliseconds(archive->GetMetadataA()), milliseconds(archive->GetMetadataB())));
      bgm.setLoop(true);
   }
   else
   {
      bgm.setLoop(false);
   }
}

void AudioService::PlayMusic()
{
   bgm.play();
}