Trait discord::voice::AudioSource [] [src]

pub trait AudioSource: Send {
    fn is_stereo(&mut self) -> bool;
    fn read_frame(&mut self, buffer: &mut [i16]) -> Option<usize>;
}

A readable audio source.

Required Methods

Called each frame to determine if the audio source is stereo.

This value should change infrequently; changing it will reset the encoder state.

Called each frame when more audio is required.

Samples should be supplied at 48000Hz, and if is_stereo returned true, the channels should be interleaved, left first.

The result should normally be Some(N), where N is the number of samples written to the buffer. The rest of the buffer is zero-filled; the whole buffer must be filled each call to avoid audio interruptions.

If Some(0) is returned, no audio will be sent this frame, but the audio source will remain active. If None is returned, the audio source is considered to have ended, and read_frame will not be called again.

Implementors