TSdlAudioStreamCallback
A callback that fires when data passes through a TSdlAudioStream.
Apps can (optionally) register a callback with an audio stream that is called when data is added with TSdlAudioStream.PutData, or requested with TSdlAudioStream.GetData.
Two values are offered here: one is the amount of additional data needed to satisfy the immediate request (which might be zero if the stream already has enough data queued) and the other is the total amount being requested. In a Get call triggering a Put callback, these values can be different. In a Put call triggering a Get callback, these values are always the same.
Byte counts might be slightly overestimated due to buffering or resampling, and may change from call to call.
This callback is not required to do anything. Generally this is useful for adding/reading data on demand, and the app will often put/get data as appropriate, but the system goes on with the data currently available to it if this callback does nothing.
Definition
Unit: Neslib.Sdl3.Audio
type TSdlAudioStreamCallback = procedure(AUserData: Pointer;
AStream: TSdlAudioStream; AAdditionalAmount, ATotalAmount: Integer); cdecl
Parameters
AUserData
: Pointer
: An opaque pointer provided by the app for their personal use.
AStream
: TSdlAudioStream
: The SDL audio stream associated with this callback.
AAdditionalAmount
: Integer
: The amount of data, in bytes, that is needed right now.
ATotalAmount
: Integer
: The total amount of data requested, in bytes, that is requested or available.
See Also
Remarks
This callback may run from any thread, so if you need to protect shared data, you should use TSdlAudioStream.Lock to serialize access; this lock will be held before your callback is called, so your callback does not need to manage the lock explicitly.