An alternative approach to removing UnknownBufferType.

This is a potential alternative to #359. This PR is based on #359.

This approach opts for a dynamically checked sample type approach with
the aim of minimising compile time and binary size.

You can read more discussion on this [here](https://github.com/RustAudio/cpal/pull/359#issuecomment-575931461)

Implemented backends:

- [x] null
- [x] ALSA
- [ ] CoreAudio
- [ ] WASAPI
- [ ] ASIO
- [ ] Emscripten
This commit is contained in:
mitchmindtree 2020-01-19 15:06:19 +01:00
parent 01425b4b80
commit 58356f49b4
8 changed files with 189 additions and 219 deletions

View file

@ -255,15 +255,14 @@ macro_rules! impl_platform_host {
}
}
fn build_input_stream<T, D, E>(
fn build_input_stream<D, E>(
&self,
format: &crate::Format,
data_callback: D,
error_callback: E,
) -> Result<Self::Stream, crate::BuildStreamError>
where
T: crate::Sample,
D: FnMut(crate::InputData<T>) + Send + 'static,
D: FnMut(&crate::Data) + Send + 'static,
E: FnMut(crate::StreamError) + Send + 'static,
{
match self.0 {
@ -275,15 +274,14 @@ macro_rules! impl_platform_host {
}
}
fn build_output_stream<T, D, E>(
fn build_output_stream<D, E>(
&self,
format: &crate::Format,
data_callback: D,
error_callback: E,
) -> Result<Self::Stream, crate::BuildStreamError>
where
T: crate::Sample,
D: FnMut(crate::OutputData<T>) + Send + 'static,
D: FnMut(&mut crate::Data) + Send + 'static,
E: FnMut(crate::StreamError) + Send + 'static,
{
match self.0 {