---
name: "SDL_LockAudioStream"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_LockAudioStream"
---

# SDL\_LockAudioStream(3)

Lock an audio stream for serialized access.

## NAME

SDL\_LockAudioStream - Lock an audio stream for serialized access.

## HEADER FILE

Defined in SDL3/SDL\_audio.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**bool SDL\_LockAudioStream(SDL\_AudioStream \*stream);**

## DESCRIPTION

Each  **SDL\_AudioStream**\
  has an internal mutex it uses to protect its data structures from threading conflicts. This function allows an app to lock that mutex, which could be useful if registering callbacks on this stream.

One does not need to lock a stream to use in it most cases, as the stream manages this lock internally. However, this lock is held during callbacks, which may run from arbitrary threads at any time, so if an app needs to protect shared data during those callbacks, locking the stream guarantees that the callback is not running while the lock is held.

As this is just a wrapper over  **SDL\_LockMutex**\
  for an internal lock; it has all the same attributes (recursive locks are allowed, etc).

## FUNCTION PARAMETERS

- *stream*

  the audio stream to lock.

## RETURN VALUE

Returns true on success or false on failure; call

**SDL\_GetError** () for more information.

## THREAD SAFETY

It is safe to call this function from any thread.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_UnlockAudioStream**(3)](/SDL_UnlockAudioStream/3.md)
