sdlLockAudioStream function
Lock an audio stream for serialized access.
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).
\param stream the audio stream to lock. \returns true on success or false on failure; call SDL_GetError() for more information.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.1.3.
\sa SDL_UnlockAudioStream
extern SDL_DECLSPEC bool SDLCALL SDL_LockAudioStream(SDL_AudioStream *stream)
Implementation
bool sdlLockAudioStream(Pointer<SdlAudioStream> stream) {
final sdlLockAudioStreamLookupFunction = libSdl3.lookupFunction<
Uint8 Function(Pointer<SdlAudioStream> stream),
int Function(Pointer<SdlAudioStream> stream)>('SDL_LockAudioStream');
return sdlLockAudioStreamLookupFunction(stream) == 1;
}