1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//! Communication between Kira and a low-level audio API.
#[cfg(feature = "cpal")]
pub mod cpal;
pub mod mock;
mod renderer;
pub(crate) mod resources;
pub use renderer::*;
#[cfg(feature = "cpal")]
/// The default backend used by [`AudioManager`](crate::AudioManager)s.
///
/// If the `cpal` feature is enabled, this will be the cpal backend. Otherwise,
/// it will be the mock backend.
pub type DefaultBackend = cpal::CpalBackend;
#[cfg(not(feature = "cpal"))]
/// The default backend used by [`AudioManager`](crate::AudioManager)s.
///
/// If the `cpal` feature is enabled, this will be the cpal backend. Otherwise,
/// it will be the mock backend.
pub type DefaultBackend = mock::MockBackend;
/// Connects a [`Renderer`] to a lower level audio API.
pub trait Backend: Sized {
/// Settings for this backend.
type Settings;
/// Errors that can occur when using this backend.
type Error;
/// Starts the backend and returns itself and the initial sample rate.
fn setup(
settings: Self::Settings,
internal_buffer_size: usize,
) -> Result<(Self, u32), Self::Error>;
/// Sends the renderer to the backend to start audio playback.
fn start(&mut self, renderer: Renderer) -> Result<(), Self::Error>;
}