sdlSetAudioStreamPutCallback function
- Pointer<
SdlAudioStream> stream, - Pointer<
NativeFunction< callback,SdlAudioStreamCallback> > - Pointer<
NativeType> userdata
Set a callback that runs when data is added to an audio stream.
This callback is called after the data is added to the stream, giving the callback the chance to obtain it immediately.
The callback can (optionally) call SDL_GetAudioStreamData() to obtain audio from the stream during this call.
The callback's approx_request
argument is how many bytes of converted
data (in the stream's output format) was provided by the caller, although
this may underestimate a little for safety. This value might be less than
what is currently available in the stream, if data was already there, and
might be less than the caller provided if the stream needs to keep a buffer
to aid in resampling. Which means the callback may be provided with zero
bytes, and a different amount on each call.
The callback may call SDL_GetAudioStreamAvailable to see the total amount currently available to read from the stream, instead of the total provided by the current call.
The callback is not required to obtain all data. It is allowed to read less or none at all. Anything not read now simply remains in the stream for later access.
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 added to 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_SetAudioStreamGetCallback
extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamPutCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata)
Implementation
bool sdlSetAudioStreamPutCallback(
Pointer<SdlAudioStream> stream,
Pointer<NativeFunction<SdlAudioStreamCallback>> callback,
Pointer<NativeType> userdata) {
final sdlSetAudioStreamPutCallbackLookupFunction = 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_SetAudioStreamPutCallback');
return sdlSetAudioStreamPutCallbackLookupFunction(
stream, callback, userdata) ==
1;
}