mixLoadAudio function mixer

Pointer<MixAudio> mixLoadAudio(
  1. Pointer<MixMixer> mixer,
  2. String? path,
  3. bool predecode
)

Load audio for playback from a file.

This is equivalent to calling:

MIX_LoadAudio_IO(mixer, SDL_IOFromFile(path, "rb"), predecode, true);

This function loads data from a path on the filesystem. There is also a version that loads from an SDL_IOStream (MIX_LoadAudio_IO()), and one that accepts properties for ultimate control (MIX_LoadAudioWithProperties()).

\param mixer a mixer this audio is intended to be used with. May be NULL. \param path the path on the filesystem to load data from. \param predecode if true, data will be fully uncompressed before returning. \returns an audio object that can be used to make sound on a mixer, or NULL on failure; call SDL_GetError() for more information.

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

\since This function is available since SDL_mixer 3.0.0.

\sa MIX_DestroyAudio \sa MIX_SetTrackAudio \sa MIX_LoadAudio_IO \sa MIX_LoadAudioWithProperties

extern SDL_DECLSPEC MIX_Audio * SDLCALL MIX_LoadAudio(MIX_Mixer *mixer, const char *path, bool predecode)

Implementation

Pointer<MixAudio> mixLoadAudio(
  Pointer<MixMixer> mixer,
  String? path,
  bool predecode,
) {
  final mixLoadAudioLookupFunction = _libMixer
      .lookupFunction<
        Pointer<MixAudio> Function(
          Pointer<MixMixer> mixer,
          Pointer<Utf8> path,
          Uint8 predecode,
        ),
        Pointer<MixAudio> Function(
          Pointer<MixMixer> mixer,
          Pointer<Utf8> path,
          int predecode,
        )
      >('MIX_LoadAudio');
  final pathPointer = path != null ? path.toNativeUtf8() : nullptr;
  final result = mixLoadAudioLookupFunction(
    mixer,
    pathPointer,
    predecode ? 1 : 0,
  );
  calloc.free(pathPointer);
  return result;
}