Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using map_err over inspect_err #231

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1689,14 +1689,13 @@ fn get_fixed_latency(devid: AudioObjectID, devtype: DeviceType) -> u32 {
} else {
get_stream_latency(devstreams[0].stream)
}
}).map_err(|e| {
}).inspect_err(|e| {
cubeb_log!(
"Cannot get the stream, or the latency of the first stream on device {} in {:?} scope. Error: {}",
devid,
devtype,
e
);
e
}).unwrap_or(0); // default stream latency

device_latency + stream_latency
Expand Down Expand Up @@ -3620,12 +3619,11 @@ impl<'ctx> CoreStreamData<'ctx> {
StreamParams::from(p)
};

self.input_dev_desc = create_stream_description(&params).map_err(|e| {
self.input_dev_desc = create_stream_description(&params).inspect_err(|_| {
cubeb_log!(
"({:p}) Setting format description for input failed.",
self.stm_ptr
);
e
})?;

#[cfg(feature = "audio-dump")]
Expand Down Expand Up @@ -3826,12 +3824,11 @@ impl<'ctx> CoreStreamData<'ctx> {
StreamParams::from(p)
};

self.output_dev_desc = create_stream_description(&params).map_err(|e| {
self.output_dev_desc = create_stream_description(&params).inspect_err(|_| {
cubeb_log!(
"({:p}) Could not initialize the audio stream description.",
self.stm_ptr
);
e
})?;

#[cfg(feature = "audio-dump")]
Expand All @@ -3856,12 +3853,11 @@ impl<'ctx> CoreStreamData<'ctx> {

let device_layout = self
.get_output_channel_layout()
.map_err(|e| {
.inspect_err(|_| {
cubeb_log!(
"({:p}) Could not get any channel layout. Defaulting to no channels.",
self.stm_ptr
);
e
})
.unwrap_or_default();

Expand Down Expand Up @@ -4739,9 +4735,8 @@ impl<'ctx> AudioUnitStream<'ctx> {

self.core_stream_data
.setup(&mut self.context.shared_voice_processing_unit)
.map_err(|e| {
.inspect_err(|_| {
cubeb_log!("({:p}) Setup failed.", self.core_stream_data.stm_ptr);
e
})?;

if let Ok(volume) = vol_rv {
Expand All @@ -4750,12 +4745,11 @@ impl<'ctx> AudioUnitStream<'ctx> {

// If the stream was running, start it again.
if !self.stopped.load(Ordering::SeqCst) {
self.core_stream_data.start_audiounits().map_err(|e| {
self.core_stream_data.start_audiounits().inspect_err(|_| {
cubeb_log!(
"({:p}) Start audiounit failed.",
self.core_stream_data.stm_ptr
);
e
})?;
}

Expand Down
Loading