Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [A5] al_play_sample isn't always playing sound

Credits go to Edgar Reynaldo for helping out!
This thread is locked; no one can reply to it. rss feed Print
[A5] al_play_sample isn't always playing sound
wixy00
Member #17,122
September 2019

I've got problem with al_play_sample() not always playing sound. On Allegro.cc manual I've read something along those lines: "Playback may fail because all the reserved sample instances are currently used.". What can I do about that?

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

wixy00
Member #17,122
September 2019

I'm reserving two samples, playing one at a time.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

wixy00
Member #17,122
September 2019

Source

It's faster to just upload my source code, everything should compile just fine.
So I reserve two samples in Setup() located in Game.c. Samples are being played in Logic() located in the same file. Logic() is being called whenever timer fires off. HasSnakePickUpFruit() works because score is being incremented so I don't know what's the problem. Latest version.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

wixy00
Member #17,122
September 2019

I think in my case, sound isn't being played when I pick up fruit after fruit almost immediately + it's not always the case. It also happens in release build.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

wixy00
Member #17,122
September 2019

Okay, it is working but I'm curious why it wasn't working properly just on my machine (I mean with two samples reserved).

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Go to: