mixCreateMixerDevice function mixer
Create a mixer that plays sound directly to an audio device.
This is usually the function you want, vs MIX_CreateMixer().
You can choose a specific device ID to open, following SDL's usual rules, but often the correct choice is to specify SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK and let SDL figure out what device to use (and seamlessly transition you to new hardware if the default changes).
Only playback devices make sense here. Attempting to open a recording device will fail.
This will call SDL_Init(SDL_INIT_AUDIO) internally; it's safe to call SDL_Init() before this call, too, if you intend to enumerate audio devices to choose one to open here.
An audio format can be requested, and the system will try to set the hardware to those specifications, or as close as possible, but this is just a hint. SDL_mixer will handle all data conversion behind the scenes in any case, and specifying a NULL spec is a reasonable choice. The best reason to specify a format is because you know all your data is in that format and it might save some unnecessary CPU time on conversion.
The actual device format chosen is available through MIX_GetMixerFormat().
Once a mixer is created, next steps are usually to load audio (through MIX_LoadAudio() and friends), create a track (MIX_CreateTrack()), and play that audio through that track.
When done with the mixer, it can be destroyed with MIX_DestroyMixer().
\param devid the device to open for playback, or SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK for the default. \param spec the audio format request from the device. May be NULL. \returns a mixer that can be used to play audio, 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_CreateMixer \sa MIX_DestroyMixer
extern SDL_DECLSPEC MIX_Mixer * SDLCALL MIX_CreateMixerDevice(SDL_AudioDeviceID devid, const SDL_AudioSpec *spec)
Implementation
Pointer<MixMixer> mixCreateMixerDevice(int devid, Pointer<SdlAudioSpec> spec) {
final mixCreateMixerDeviceLookupFunction = _libMixer
.lookupFunction<
Pointer<MixMixer> Function(Uint32 devid, Pointer<SdlAudioSpec> spec),
Pointer<MixMixer> Function(int devid, Pointer<SdlAudioSpec> spec)
>('MIX_CreateMixerDevice');
return mixCreateMixerDeviceLookupFunction(devid, spec);
}