sdlSetAudioStreamGetCallback function
- Pointer<
SdlAudioStream> stream, - Pointer<
NativeFunction< callback,SdlAudioStreamCallback> > - Pointer<
NativeType> userdata
Set a callback that runs when data is requested from an audio stream.
This callback is called before data is obtained from the stream, giving the callback the chance to add more on-demand.
The callback can (optionally) call SDL_PutAudioStreamData() to add more audio to the stream during this call; if needed, the request that triggered this callback will obtain the new data immediately.
The callback's approx_request
argument is roughly how many bytes of
unconverted data (in the stream's input format) is needed by the caller,
although this may overestimate a little for safety. This takes into account
how much is already in the stream and only asks for any extra necessary to
resolve the request, which means the callback may be asked for zero bytes,
and a different amount on each call.
The callback is not required to supply exact amounts; it is allowed to supply too much or too little or none at all. The caller will get what's available, up to the amount they requested, regardless of this callback's outcome.
Clearing or flushing an audio stream does not call this callback.
This function obtains the stream's lock, which means any existing callback (get or put) in progress will finish running before setting the new callback.
Setting a NULL function turns off the callback.
\param stream the audio stream to set the new callback on.
\param callback the new callback function to call when data is requested
from the stream.
\param userdata an opaque pointer provided to the callback for its own
personal use.
\returns true on success or false on failure; call SDL_GetError() for more
information. This only fails if stream
is NULL.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.1.3.
\sa SDL_SetAudioStreamPutCallback
extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamGetCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata)
Implementation
bool sdlSetAudioStreamGetCallback(
Pointer<SdlAudioStream> stream,
Pointer<NativeFunction<SdlAudioStreamCallback>> callback,
Pointer<NativeType> userdata) {
final sdlSetAudioStreamGetCallbackLookupFunction = libSdl3.lookupFunction<
Uint8 Function(
Pointer<SdlAudioStream> stream,
Pointer<NativeFunction<SdlAudioStreamCallback>> callback,
Pointer<NativeType> userdata),
int Function(
Pointer<SdlAudioStream> stream,
Pointer<NativeFunction<SdlAudioStreamCallback>> callback,
Pointer<NativeType> userdata)>('SDL_SetAudioStreamGetCallback');
return sdlSetAudioStreamGetCallbackLookupFunction(
stream, callback, userdata) ==
1;
}