sdlPutAudioStreamPlanarData function audio
- Pointer<
SdlAudioStream> stream, - Pointer<
Pointer< channelBuffers,NativeType> > - int numChannels,
- int numSamples,
Add data to the stream with each channel in a separate array.
This data must match the format/channels/samplerate specified in the latest call to SDL_SetAudioStreamFormat, or the format specified when creating the stream if it hasn't been changed.
The data will be interleaved and queued. Note that SDL_AudioStream only operates on interleaved data, so this is simply a convenience function for easily queueing data from sources that provide separate arrays. There is no equivalent function to retrieve planar data.
The arrays in channel_buffers
are ordered as they are to be interleaved;
the first array will be the first sample in the interleaved data. Any
individual array may be NULL; in this case, silence will be interleaved for
that channel.
num_channels
specifies how many arrays are in channel_buffers
. This can
be used as a safety to prevent overflow, in case the stream format has
changed elsewhere. If more channels are specified than the current input
spec, they are ignored. If less channels are specified, the missing arrays
are treated as if they are NULL (silence is written to those channels). If
the count is -1, SDL will assume the array count matches the current input
spec.
Note that num_samples
is the number of samples per array. This can also
be thought of as the number of sample frames to be queued. A value of 1
with stereo arrays will queue two samples to the stream. This is different
than SDL_PutAudioStreamData, which wants the size of a single array in
bytes.
\param stream the stream the audio data is being added to.
\param channel_buffers a pointer to an array of arrays, one array per
channel.
\param num_channels the number of arrays in channel_buffers
or -1.
\param num_samples the number of samples per array to write to the
stream.
\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, but if the stream has a callback set, the caller might need to manage extra locking.
\since This function is available since SDL 3.4.0.
\sa SDL_ClearAudioStream \sa SDL_FlushAudioStream \sa SDL_GetAudioStreamData \sa SDL_GetAudioStreamQueued
extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamPlanarData(SDL_AudioStream *stream, const void * const *channel_buffers, int num_channels, int num_samples)
Implementation
bool sdlPutAudioStreamPlanarData(
Pointer<SdlAudioStream> stream,
Pointer<Pointer<NativeType>> channelBuffers,
int numChannels,
int numSamples,
) {
final sdlPutAudioStreamPlanarDataLookupFunction = _libSdl
.lookupFunction<
Uint8 Function(
Pointer<SdlAudioStream> stream,
Pointer<Pointer<NativeType>> channelBuffers,
Int32 numChannels,
Int32 numSamples,
),
int Function(
Pointer<SdlAudioStream> stream,
Pointer<Pointer<NativeType>> channelBuffers,
int numChannels,
int numSamples,
)
>('SDL_PutAudioStreamPlanarData');
return sdlPutAudioStreamPlanarDataLookupFunction(
stream,
channelBuffers,
numChannels,
numSamples,
) ==
1;
}