Trait sdl2::audio::AudioFormatNum[][src]

pub trait AudioFormatNum {
    const SILENCE: Self;

    fn audio_format() -> AudioFormat;
}
Expand description

A phantom type for retrieving the SDL_AudioFormat of a given generic type. All format types are returned as native-endian.

Associated Constants

The appropriately typed silence value for the audio format used.

Examples
// The AudioFormatNum trait has to be imported for the Channel::SILENCE part to work.
use sdl2::audio::{AudioCallback, AudioFormatNum};

struct Silence;

impl AudioCallback for Silence {
    type Channel = u16;

    fn callback(&mut self, out: &mut [u16]) {
        for dst in out.iter_mut() {
            *dst = Self::Channel::SILENCE;
        }
    }
}

Required methods

Implementations on Foreign Types

AUDIO_S8

AUDIO_U8

AUDIO_S16

AUDIO_U16

AUDIO_S32

AUDIO_F32

Implementors