sdlBuildAudioCvt function

int sdlBuildAudioCvt(
  1. Pointer<SdlAudioCvt> cvt,
  2. int srcFormat,
  3. int srcChannels,
  4. int srcRate,
  5. int dstFormat,
  6. int dstChannels,
  7. int dstRate,
)

Initialize an SDL_AudioCVT structure for conversion.

Before an SDL_AudioCVT structure can be used to convert audio data it must be initialized with source and destination information.

This function will zero out every field of the SDL_AudioCVT, so it must be called before the application fills in the final buffer information.

Once this function has returned successfully, and reported that a conversion is necessary, the application fills in the rest of the fields in SDL_AudioCVT, now that it knows how large a buffer it needs to allocate, and then can call SDL_ConvertAudio() to complete the conversion.

\param cvt an SDL_AudioCVT structure filled in with audio conversion information \param src_format the source format of the audio data; for more info see SDL_AudioFormat \param src_channels the number of channels in the source \param src_rate the frequency (sample-frames-per-second) of the source \param dst_format the destination format of the audio data; for more info see SDL_AudioFormat \param dst_channels the number of channels in the destination \param dst_rate the frequency (sample-frames-per-second) of the destination \returns 1 if the audio filter is prepared, 0 if no conversion is needed, or a negative error code on failure; call SDL_GetError() for more information.

\since This function is available since SDL 2.0.0.

\sa SDL_ConvertAudio

extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, SDL_AudioFormat src_format, Uint8 src_channels, int src_rate, SDL_AudioFormat dst_format, Uint8 dst_channels, int dst_rate)

Implementation

int sdlBuildAudioCvt(Pointer<SdlAudioCvt> cvt, int srcFormat, int srcChannels,
    int srcRate, int dstFormat, int dstChannels, int dstRate) {
  final sdlBuildAudioCvtLookupFunction = libSdl2.lookupFunction<
      Int32 Function(
          Pointer<SdlAudioCvt> cvt,
          Uint16 srcFormat,
          Uint8 srcChannels,
          Int32 srcRate,
          Uint16 dstFormat,
          Uint8 dstChannels,
          Int32 dstRate),
      int Function(
          Pointer<SdlAudioCvt> cvt,
          int srcFormat,
          int srcChannels,
          int srcRate,
          int dstFormat,
          int dstChannels,
          int dstRate)>('SDL_BuildAudioCVT');
  return sdlBuildAudioCvtLookupFunction(
      cvt, srcFormat, srcChannels, srcRate, dstFormat, dstChannels, dstRate);
}