SDL Wiki
(This is the documentation for SDL3, which is under heavy development and the API is changing! SDL2 is the current stable version!)

SDL_UnlockAudio

This function is a legacy means of unlocking the audio device.

Syntax

void SDL_UnlockAudio(void);

Remarks

New programs might want to use SDL_UnlockAudioDevice() instead. This function is equivalent to calling...

SDL_UnlockAudioDevice(1);

...and is only useful if you used the legacy SDL_OpenAudio() function.

Version

This function is available since SDL 3.0.0.

Code Examples

void MyAudioCallback(void *userdata, Uint8* stream, int len)
{
    printf("The audio callback is running!\n");
    SDL_memset(stream, 0, len);  // just silence.
    printf("The audio callback is done!\n");
}

// don't lock for 2 seconds at a time in real life, please.
SDL_Delay(2000);  // callback runs for 2 seconds.
SDL_LockAudio();
printf("The audio callback can't be running right now!\n");
SDL_Delay(2000);  // callback doesn't run for 2 seconds.
printf("Ok, unlocking!\n");
SDL_UnlockAudio();
SDL_Delay(2000);  // callback runs for 2 seconds.
SDL_LockAudio
SDL_UnlockAudioDevice

CategoryAPI, CategoryAudio


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.