pub fn open_audio_device<'a, D>(
frequency: i32,
format: AudioFormat,
channels: i32,
chunksize: i32,
device: D,
allowed_changes: AllowChangeFlag,
) -> Result<(), String>Expand description
Open a specific audio device for playback.
(A slightly simpler version of this function is available in open_audio, which still might
meet most applications’ needs.)
The allowed_changes parameter specifies what settings are flexible. These tell SDL_mixer
that the app doesn’t mind if a specific setting changes. For example, the app might need stereo
data in i16 format, but if the sample rate or chunk size changes, the app can handle that.
In that case, the app would specify AllowChangeFlag::FORMAT | AllowChangeFlag::SAMPLES. In
this case, if the system’s hardware requires something other than the requested format,
SDL_mixer can select what the hardware demands instead of the app. For a given
AllowChangeFlag, If it is not specified, SDL_mixer must convert data behind the scenes
between what the app demands and what the hardware requires. If your app needs precisely what
is requested, specify AllowChangeFlag::empty.
frequency: The frequency to playback audio at (in Hz).format: Audio format (AudioFormat).channels: Number of channels (1 is mono, 2 is stereo, etc).chunksize: Audio buffer size in sample FRAMES (total samples divided by channel count). The lower the number, the lower the latency, but you risk dropouts if it gets too low.device: The device name to open, orNoneto choose a reasonable default.allowed_changes: Allow change flags (AllowChangeFlag).