al_lock_sample_id(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

al_lock_sample_id β€” the Allegro 5 API girlie that grabs your sample id and hands you the actual instance underneath it πŸŽ€


✨ SYNOPSIS ✨

#include <allegro5/allegro_audio.h>

ALLEGRO_SAMPLE_INSTANCE* al_lock_sample_id(ALLEGRO_SAMPLE_ID *spl_id)

🌸 DESCRIPTION 🌸

Okay so bestie, listen. al_lock_sample_id locks an ALLEGRO_SAMPLE_ID and gives you back the ALLEGRO_SAMPLE_INSTANCE hiding underneath it. It's giving peek behind the curtain ✨. And why do we care? Because now you can mess with all the properties of that instance β€” volume, pan, etc. β€” while the sound is literally playing. Main character mixing energy, no cap πŸ’….

Heads up though: this function returns NULL if the sound that corresponds to the id is no longer playing. So vibe check that return value, fr fr 😭.

And here's the part that matters, don't skip it πŸ™ˆ: while it's locked, the ALLEGRO_SAMPLE_ID is unavailable to any additional calls to al_play_sample β€” even if the sound stops while it's still locked. Like, it's booked and busy, don't come for it. To put that ALLEGRO_SAMPLE_ID back into the pool for reuse, make sure you call al_unlock_sample_id when you're done with the instance. Periodt 🫢.


πŸ¦‹ SEE ALSO πŸ¦‹


⭐ SINCE ⭐

5.2.3

[Unstable API]: New API. Baby's brand new, handle with care πŸ“

Written down in the Allegro reference manual, version al_lock_sample_id(3alleg5) β€” mwah, slay, go lock responsibly, ily πŸ§šπŸ’œ

πŸ“¦ where this page comes from