[A5] al_play_sample isn't always playing sound
wixy00

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

How many samples are you reserving? How many are you playing at a time?

wixy00

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

Edgar Reynaldo

Can you show a simple code example that demonstrates this? I've reserved only 1 or 2 samples, and yet it still works to play sound. What version of Allegro are you using?

wixy00

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

It's working for me. ???

It plays a sound when I eat a fruit, and it plays a sound when I hit the wall.

wixy00

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

Well the first thing you can do is change the number of samples that you are reserving.

wixy00

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

How long are your samples? Are they padded with silence?

Thread #617941. Printed from Allegro.cc