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

Author Topic: Behaviour of SoundStream on program exit  (Read 2093 times)

0 Members and 1 Guest are viewing this topic.

ribisel

  • Newbie
  • *
  • Posts: 2
    • View Profile
Behaviour of SoundStream on program exit
« on: March 11, 2015, 01:27:43 am »
I have a program that plays mp3 files. I use a derived class of sf::SoundStream together with mpg123 (All my code is based off this example: https://github.com/SFML/SFML/wiki/Source%3A-MP3-Player )

When I call sf::SoundStream::stop() and exit the main thread using a return statement at the end of main, I get a warning like this: AL lib: FreeContext: (0x2a799b0) Deleting 1 Source(s)
When I call pthread_exit() instead of a return statement at the end of my main thread, the program does not terminate. I could imagine it is because the thread that was launched in sf::SoundStream::play() does not return, but I did not check this.

What is the correct way to terminate audio playback before EOF is reached?
« Last Edit: March 11, 2015, 01:34:26 am by ribisel »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Behaviour of SoundStream on program exit
« Reply #1 on: March 11, 2015, 01:36:06 am »
The code you linked was written for a pre-release version of SFML 2.0, as such I would not be surprised if it contained errors.

At best you figure out why it segfaults when exiting while still playing. It's dirty to do so, but it shouldn't cause a crash.
Then I guess you'll have to make sure the class works in harmony with OpenAL, no idea what is required here.

IMHO you should get an audio converted, convert everything to OGG and stop bothering with MP3. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ribisel

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Behaviour of SoundStream on program exit
« Reply #2 on: March 11, 2015, 01:47:26 am »
eXpl0it3r, thank you for your reply. While you were writing, I edited away the segfault because it was related to something else. The AL lib warning remains however. I remember reading somewhere that this is ok and just indicates that sources were not deleted manually but by the library.

Now my real question is, when does the thread started by SoundStream::play() exit?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
AW: Behaviour of SoundStream on program exit
« Reply #3 on: March 11, 2015, 01:55:46 am »
Look at SFML's source code, at least that's what I'd have to do.

What version of SFML are you using?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Behaviour of SoundStream on program exit
« Reply #4 on: March 11, 2015, 02:16:01 pm »
Even with last "git" version of SFML I'm stopping music/sounds manually always before exit.

 

anything