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

Author Topic: Music thread is stuck waiting  (Read 175 times)

0 Members and 1 Guest are viewing this topic.

kr3nshaw

  • Newbie
  • *
  • Posts: 10
    • View Profile
Music thread is stuck waiting
« 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 9221
    • View Profile
    • development blog
    • Email
Re: Music thread is stuck waiting
« Reply #1 on: June 10, 2019, 02:12:15 pm »
What SFML version?
Can you provide a minimal but complete example?
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

kr3nshaw

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Music thread is stuck waiting
« Reply #2 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();
}

 

anything