Fixed an error found due to clippy

This commit is contained in:
Anne de Jong 2024-07-18 13:30:23 +02:00
parent ff6a0687c4
commit f3dbf9d948
2 changed files with 53 additions and 51 deletions

View File

@ -365,11 +365,11 @@ impl CpalApi {
for (och, ich) in out_chunks.into_iter().zip(siggen_chunks.into_iter()) { for (och, ich) in out_chunks.into_iter().zip(siggen_chunks.into_iter()) {
let mut sig_frame_iter = ich.into_iter(); let mut sig_frame_iter = ich.into_iter();
och.into_iter().zip(&enabled_outch).for_each(|(o, en)| { och.into_iter().zip(&enabled_outch).for_each(|(o, en)| {
(if *en { if *en {
*o = sig_frame_iter.next().unwrap(); *o = sig_frame_iter.next().unwrap();
} else { } else {
*o = Sample::EQUILIBRIUM; *o = Sample::EQUILIBRIUM;
}) }
}); });
} }
@ -487,56 +487,58 @@ impl CpalApi {
sender: Sender<InStreamMsg>, sender: Sender<InStreamMsg>,
) -> Result<Box<dyn Stream>> { ) -> Result<Box<dyn Stream>> {
for cpaldev in self.host.devices()? { for cpaldev in self.host.devices()? {
// See if we can create a supported stream config. if cpaldev.name().unwrap_or("".to_string()) == conf.device_name {
let supported_config = (match stype { // See if we can create a supported stream config.
StreamType::Duplex => bail!("Duplex stream not supported for CPAL"), let supported_config = (match stype {
StreamType::Input => CpalApi::create_cpal_config( StreamType::Duplex => bail!("Duplex stream not supported for CPAL"),
stype, StreamType::Input => CpalApi::create_cpal_config(
devinfo, stype,
conf, devinfo,
conf,
&cpaldev,
cpaldev.supported_input_configs()?,
),
StreamType::Output => CpalApi::create_cpal_config(
stype,
devinfo,
conf,
&cpaldev,
cpaldev.supported_output_configs()?,
),
})?;
let framesPerBlock = conf.framesPerBlock(devinfo);
let sf = supported_config.sample_format();
let config: cpal::StreamConfig = supported_config.config();
let meta = StreamMetaData::new(
&conf.enabledInchannelConfig(),
conf.dtype,
supported_config.sample_rate().0 as Flt,
framesPerBlock,
);
let meta = Arc::new(meta);
let (stream, status) = CpalApi::build_input_stream(
meta.clone(),
sf,
&config,
&cpaldev, &cpaldev,
cpaldev.supported_input_configs()?, sender,
), conf.enabledInchannelsList(),
StreamType::Output => CpalApi::create_cpal_config( framesPerBlock,
stype, )?;
devinfo,
conf,
&cpaldev,
cpaldev.supported_output_configs()?,
),
})?;
let framesPerBlock = conf.framesPerBlock(devinfo);
let sf = supported_config.sample_format(); stream.play()?;
let config: cpal::StreamConfig = supported_config.config(); status.store(StreamStatus::Running {});
let meta = StreamMetaData::new( return Ok(Box::new(CpalStream {
&conf.enabledInchannelConfig(), stream,
conf.dtype, metadata: meta,
supported_config.sample_rate().0 as Flt, noutchannels: 0,
framesPerBlock, status,
); }));
let meta = Arc::new(meta); }
let (stream, status) = CpalApi::build_input_stream(
meta.clone(),
sf,
&config,
&cpaldev,
sender,
conf.enabledInchannelsList(),
framesPerBlock,
)?;
stream.play()?;
status.store(StreamStatus::Running {});
return Ok(Box::new(CpalStream {
stream,
metadata: meta,
noutchannels: 0,
status,
}));
} }
bail!(format!( bail!(format!(
"Error: requested device {} not found. Please make sure the device is available.", "Error: requested device {} not found. Please make sure the device is available.",

View File

@ -155,7 +155,7 @@ impl InStreamData {
let v: &'a [T] = unsafe { reinterpret_slice($c) }; let v: &'a [T] = unsafe { reinterpret_slice($c) };
v.iter().skip(ch).step_by(self.meta.nchannels()) v.iter().skip(ch).step_by(self.meta.nchannels())
}}; }};
}; }
match &self.raw { match &self.raw {
RawStreamData::Datai8(c) => { RawStreamData::Datai8(c) => {
@ -276,7 +276,7 @@ impl InStreamData {
) )
.expect(errmsg) .expect(errmsg)
}; };
}; }
// Perform the actual conversion // Perform the actual conversion
let converted_data = match &self.raw { let converted_data = match &self.raw {