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

Author Topic: Sound randomly stops playing  (Read 2719 times)

0 Members and 1 Guest are viewing this topic.

mbestf

  • Newbie
  • *
  • Posts: 3
    • View Profile
Sound randomly stops playing
« on: October 18, 2016, 01:20:30 am »
Hi, I think I found the problem of sfml sounds or something with what...
Lets say, I have explosion1..5.wav sounds which's length is 4seconds.

In example:
I have the sound buffer array with 5 elements
Then, I have another array of the objects(classes), with sf::Sound variable...
Every sf::Sound has its own buffer

Now, the intresting part:
For the first object i writing sounds[0].play()... Then - "Sleep(3000)"
And then next object starting to play... But only 1sec... Not 4 as it should... Why ?
The sound randomly stops and that's it...

The sequence:
sound[0].play(); (4s of the explosion sound...)
Sleep(3000) (1s left of playing sound for sound[0])
sound[1].play(); (4s of the explosion sound...)
<sound[1] stops after 1 second>
Sleep(3000) (randomly 2 seconds of "nothing")
sound[2].play();
Sleep(3000) (again everything is good, 1s left for sound[2])
sound[3].play() (again, sound[3] stops after 1 second...)

Why this is happening? How to fix that?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Sound randomly stops playing
« Reply #1 on: October 18, 2016, 01:37:56 am »
Can you provide a complete but minimal example code?
Keep in mind that Sleep() isn't very accurate.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything