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

@ -2,17 +2,15 @@
use {
BuildStreamError,
Data,
DefaultFormatError,
DeviceNameError,
DevicesError,
Format,
InputData,
InputDevices,
OutputData,
OutputDevices,
PauseStreamError,
PlayStreamError,
Sample,
StreamError,
SupportedFormat,
SupportedFormatsError,
@ -120,27 +118,25 @@ pub trait DeviceTrait {
fn default_output_format(&self) -> Result<Format, DefaultFormatError>;
/// Create an input stream.
fn build_input_stream<T, D, E>(
fn build_input_stream<D, E>(
&self,
format: &Format,
data_callback: D,
error_callback: E,
) -> Result<Self::Stream, BuildStreamError>
where
T: Sample,
D: FnMut(InputData<T>) + Send + 'static,
D: FnMut(&Data) + Send + 'static,
E: FnMut(StreamError) + Send + 'static;
/// Create an output stream.
fn build_output_stream<T, D, E>(
fn build_output_stream<D, E>(
&self,
format: &Format,
data_callback: D,
error_callback: E,
) -> Result<Self::Stream, BuildStreamError>
where
T: Sample,
D: FnMut(OutputData<T>) + Send + 'static,
D: FnMut(&mut Data) + Send + 'static,
E: FnMut(StreamError) + Send + 'static;
}