---
name: "al_lock_sample_id"
section: "3"
platform: "linux"
package: "allegro"
version: "5.2.11.3-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/al_lock_sample_id"
---

# al\_lock\_sample\_id(3)

Allegro 5 API

## NAME

al\_lock\_sample\_id - Allegro 5 API

## SYNOPSIS

-

  ```
  #include <allegro5/allegro_audio.h>
  ALLEGRO_SAMPLE_INSTANCE* al_lock_sample_id(ALLEGRO_SAMPLE_ID *spl_id)
  ```

## DESCRIPTION

Locks a [ALLEGRO\_SAMPLE\_ID(3)](/ALLEGRO_SAMPLE_ID/3.md), returning the underlying [ALLEGRO\_SAMPLE\_INSTANCE(3)](/ALLEGRO_SAMPLE_INSTANCE/3.md). This allows you to adjust the various properties of the instance (such as volume, pan, etc) while the sound is playing.

This function will return `NULL` if the sound corresponding to the id is no longer playing.

While locked, `ALLEGRO_SAMPLE_ID` will be unavailable to additional calls to [al\_play\_sample(3)](/al_play_sample/3.md), even if the sound stops while locked. To put the `ALLEGRO_SAMPLE_ID` back into the pool for reuse, make sure to call `al_unlock_sample_id` when you’re done with the instance.

## SEE ALSO

[al\_play\_sample(3)](/al_play_sample/3.md), [al\_unlock\_sample\_id(3)](/al_unlock_sample_id/3.md)

## SINCE

5\.2.3

*\[Unstable API\]:* New API.
