Only allow for private construction of SupportedStreamConfig.
This should give the user a higher confidence that, if they have a `SupportedStreamConfig` format type that it is actually supported. Also updates the `raw` stream builder methods to take a `StreamConfig` and `SampleFormat` as separate arguments for flexibility. **Backends Updated** - [x] null - [x] alsa - [ ] emscripten - [ ] coreaudio - [ ] wasapi - [ ] asio
This commit is contained in:
parent
07b66f52f3
commit
476f6c4c2c
8 changed files with 92 additions and 58 deletions
|
|
@ -40,7 +40,7 @@ fn main() -> Result<(), anyhow::Error> {
|
|||
eprintln!("an error occurred on stream: {}", err);
|
||||
};
|
||||
|
||||
let stream = match config.sample_format {
|
||||
let stream = match config.sample_format() {
|
||||
cpal::SampleFormat::F32 => device.build_input_stream(
|
||||
&config.into(),
|
||||
move |data| write_input_data::<f32, f32>(data, &writer_2),
|
||||
|
|
@ -78,10 +78,10 @@ fn sample_format(format: cpal::SampleFormat) -> hound::SampleFormat {
|
|||
|
||||
fn wav_spec_from_config(config: &cpal::SupportedStreamConfig) -> hound::WavSpec {
|
||||
hound::WavSpec {
|
||||
channels: config.channels as _,
|
||||
sample_rate: config.sample_rate.0 as _,
|
||||
bits_per_sample: (config.sample_format.sample_size() * 8) as _,
|
||||
sample_format: sample_format(config.sample_format),
|
||||
channels: config.channels() as _,
|
||||
sample_rate: config.sample_rate().0 as _,
|
||||
bits_per_sample: (config.sample_format().sample_size() * 8) as _,
|
||||
sample_format: sample_format(config.sample_format()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue