sdlGetAudioDeviceName function

String? sdlGetAudioDeviceName(
  1. int index,
  2. int iscapture
)

Get the human-readable name of a specific audio device.

This function is only valid after successfully initializing the audio subsystem. The values returned by this function reflect the latest call to SDL_GetNumAudioDevices(); re-call that function to redetect available hardware.

The string returned by this function is UTF-8 encoded, read-only, and managed internally. You are not to free it. If you need to keep the string for any length of time, you should make your own copy of it, as it will be invalid next time any of several other SDL functions are called.

\param index the index of the audio device; valid values range from 0 to SDL_GetNumAudioDevices() - 1 \param iscapture non-zero to query the list of recording devices, zero to query the list of output devices. \returns the name of the audio device at the requested index, or NULL on error.

\since This function is available since SDL 2.0.0.

\sa SDL_GetNumAudioDevices \sa SDL_GetDefaultAudioInfo

extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index, int iscapture)

Implementation

String? sdlGetAudioDeviceName(int index, int iscapture) {
  final sdlGetAudioDeviceNameLookupFunction = libSdl2.lookupFunction<
      Pointer<Utf8> Function(Int32 index, Int32 iscapture),
      Pointer<Utf8> Function(
          int index, int iscapture)>('SDL_GetAudioDeviceName');
  final result = sdlGetAudioDeviceNameLookupFunction(index, iscapture);
  if (result == nullptr) {
    return null;
  }
  return result.toDartString();
}