mixCreateAudioDecoder function mixer

Pointer<MixAudioDecoder> mixCreateAudioDecoder(
  1. String? path,
  2. int props
)

Create a MIX_AudioDecoder from a path on the filesystem.

Most apps won't need this, as SDL_mixer's usual interfaces will decode audio as needed. However, if one wants to decode an audio file into a memory buffer without playing it, this interface offers that.

This function allows properties to be specified. This is intended to supply file-specific settings, such as where to find SoundFonts for a MIDI file, etc. In most cases, the caller should pass a zero to specify no extra properties.

When done with the audio decoder, it can be destroyed with MIX_DestroyAudioDecoder().

This function requires SDL_mixer to have been initialized with a successful call to MIX_Init(), but does not need an actual MIX_Mixer to have been created.

\param path the path on the filesystem from which to load data. \param props decoder-specific properties. May be zero. \returns an audio decoder, ready to decode.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL_mixer 3.0.0.

\sa MIX_CreateAudioDecoder_IO \sa MIX_DecodeAudio \sa MIX_DestroyAudioDecoder

extern SDL_DECLSPEC MIX_AudioDecoder * SDLCALL MIX_CreateAudioDecoder(const char *path, SDL_PropertiesID props)

Implementation

Pointer<MixAudioDecoder> mixCreateAudioDecoder(String? path, int props) {
  final mixCreateAudioDecoderLookupFunction = _libMixer
      .lookupFunction<
        Pointer<MixAudioDecoder> Function(Pointer<Utf8> path, Uint32 props),
        Pointer<MixAudioDecoder> Function(Pointer<Utf8> path, int props)
      >('MIX_CreateAudioDecoder');
  final pathPointer = path != null ? path.toNativeUtf8() : nullptr;
  final result = mixCreateAudioDecoderLookupFunction(pathPointer, props);
  calloc.free(pathPointer);
  return result;
}