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()) {
let mut sig_frame_iter = ich.into_iter();
och.into_iter().zip(&enabled_outch).for_each(|(o, en)| {
(if *en {
if *en {
*o = sig_frame_iter.next().unwrap();
} else {
*o = Sample::EQUILIBRIUM;
})
}
});
}
@ -487,56 +487,58 @@ impl CpalApi {
sender: Sender<InStreamMsg>,
) -> Result<Box<dyn Stream>> {
for cpaldev in self.host.devices()? {
// See if we can create a supported stream config.
let supported_config = (match stype {
StreamType::Duplex => bail!("Duplex stream not supported for CPAL"),
StreamType::Input => CpalApi::create_cpal_config(
stype,
devinfo,
conf,
if cpaldev.name().unwrap_or("".to_string()) == conf.device_name {
// See if we can create a supported stream config.
let supported_config = (match stype {
StreamType::Duplex => bail!("Duplex stream not supported for CPAL"),
StreamType::Input => CpalApi::create_cpal_config(
stype,
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.supported_input_configs()?,
),
StreamType::Output => CpalApi::create_cpal_config(
stype,
devinfo,
conf,
&cpaldev,
cpaldev.supported_output_configs()?,
),
})?;
let framesPerBlock = conf.framesPerBlock(devinfo);
sender,
conf.enabledInchannelsList(),
framesPerBlock,
)?;
let sf = supported_config.sample_format();
let config: cpal::StreamConfig = supported_config.config();
stream.play()?;
status.store(StreamStatus::Running {});
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,
sender,
conf.enabledInchannelsList(),
framesPerBlock,
)?;
stream.play()?;
status.store(StreamStatus::Running {});
return Ok(Box::new(CpalStream {
stream,
metadata: meta,
noutchannels: 0,
status,
}));
return Ok(Box::new(CpalStream {
stream,
metadata: meta,
noutchannels: 0,
status,
}));
}
}
bail!(format!(
"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) };
v.iter().skip(ch).step_by(self.meta.nchannels())
}};
};
}
match &self.raw {
RawStreamData::Datai8(c) => {
@ -276,7 +276,7 @@ impl InStreamData {
)
.expect(errmsg)
};
};
}
// Perform the actual conversion
let converted_data = match &self.raw {