diff --git a/src/daq/api/api_cpal.rs b/src/daq/api/api_cpal.rs index 4b14501..e58e595 100644 --- a/src/daq/api/api_cpal.rs +++ b/src/daq/api/api_cpal.rs @@ -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, ) -> Result> { 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.", diff --git a/src/daq/streamdata.rs b/src/daq/streamdata.rs index b244f41..a2d1f43 100644 --- a/src/daq/streamdata.rs +++ b/src/daq/streamdata.rs @@ -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 {