Struct AudioContext

Source
pub struct AudioContext<'a> {
    pub(crate) environment_callback: &'a retro_environment_t,
    pub(crate) interfaces: Arc<RwLock<InterfaceList>>,
    pub(crate) audio_sample_batch_callback: &'a retro_audio_sample_batch_t,
    pub(crate) audio_sample_callback: &'a retro_audio_sample_t,
}
Expand description

Functions that are safe to be called in Core::on_write_audio.

For a description of the callbacks see CoreWrapper.

Fields§

§environment_callback: &'a retro_environment_t§interfaces: Arc<RwLock<InterfaceList>>§audio_sample_batch_callback: &'a retro_audio_sample_batch_t§audio_sample_callback: &'a retro_audio_sample_t

Implementations§

Source§

impl AudioContext<'_>

Source

pub fn batch_audio_samples(&self, samples: &[i16])

Renders multiple audio frames in one go if AudioContext::audio_sample_batch_callback has been set.

One frame is defined as a sample of left and right channels, interleaved. I.e. let buf: [u16; 4] = [ l, r, l, r ]; would be 2 frames.

Only one of the audio callbacks must ever be used.

Source

pub fn queue_audio_sample(&self, left: i16, right: i16)

Renders a single audio frame if AudioContext::audio_sample_callback has been set. Should only be used if implementation generates a single sample at a time. Format is signed 16-bit native endian.

Only one of the audio callbacks must ever be used.

Trait Implementations§

Source§

impl<'a> From<&AudioContext<'a>> for GenericContext<'a>

Source§

fn from(other: &AudioContext<'a>) -> GenericContext<'a>

Converts to this type from the input type.
Source§

impl<'a> From<&mut AudioContext<'a>> for GenericContext<'a>

Source§

fn from(other: &mut AudioContext<'a>) -> GenericContext<'a>

Converts to this type from the input type.
Source§

impl<'a> From<&mut RunContext<'a>> for AudioContext<'a>

Source§

fn from(other: &mut RunContext<'a>) -> AudioContext<'a>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for AudioContext<'a>

§

impl<'a> RefUnwindSafe for AudioContext<'a>

§

impl<'a> !Send for AudioContext<'a>

§

impl<'a> !Sync for AudioContext<'a>

§

impl<'a> Unpin for AudioContext<'a>

§

impl<'a> UnwindSafe for AudioContext<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.