Skip to content

Commit

Permalink
Fix clippy warnings (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
ameknite authored Mar 1, 2024
1 parent f3de611 commit f894781
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
1 change: 0 additions & 1 deletion examples/beep.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anyhow;
use clap::Parser;
use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait},
Expand Down
9 changes: 5 additions & 4 deletions src/host/coreaudio/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use std::fmt;
use std::mem;
use std::os::raw::c_char;
use std::ptr::null;
use std::rc::Rc;
use std::slice;
use std::sync::mpsc::{channel, RecvTimeoutError};
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -306,7 +307,7 @@ impl Device {
channels: n_channels as ChannelCount,
min_sample_rate: SampleRate(range.mMinimum as _),
max_sample_rate: SampleRate(range.mMaximum as _),
buffer_size: buffer_size.clone(),
buffer_size,
sample_format,
};
fmts.push(fmt);
Expand Down Expand Up @@ -568,7 +569,7 @@ impl Device {
let sample_rate = config.sample_rate;
type Args = render_callback::Args<data::Raw>;
audio_unit.set_input_callback(move |args: Args| unsafe {
let ptr = (*args.data.data).mBuffers.as_ptr() as *const AudioBuffer;
let ptr = (*args.data.data).mBuffers.as_ptr();
let len = (*args.data.data).mNumberBuffers as usize;
let buffers: &[AudioBuffer] = slice::from_raw_parts(ptr, len);

Expand All @@ -580,7 +581,7 @@ impl Device {
} = buffers[0];

let data = data as *mut ();
let len = (data_byte_size as usize / bytes_per_channel) as usize;
let len = data_byte_size as usize / bytes_per_channel;
let data = Data::from_parts(data, len, sample_format);

// TODO: Need a better way to get delay, for now we assume a double-buffer offset.
Expand Down Expand Up @@ -685,7 +686,7 @@ impl Device {
} = (*args.data.data).mBuffers[0];

let data = data as *mut ();
let len = (data_byte_size as usize / bytes_per_channel) as usize;
let len = data_byte_size as usize / bytes_per_channel;
let mut data = Data::from_parts(data, len, sample_format);

let callback = match host_time_to_stream_instant(args.time_stamp.mHostTime) {
Expand Down
4 changes: 2 additions & 2 deletions src/host/coreaudio/macos/property_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::BuildStreamError;

/// A double-indirection to be able to pass a closure (a fat pointer)
/// via a single c_void.
struct PropertyListenerCallbackWrapper(Box<dyn FnMut() -> ()>);
struct PropertyListenerCallbackWrapper(Box<dyn FnMut()>);

/// Maintain an audio object property listener.
/// The listener will be removed when this type is dropped.
Expand All @@ -21,7 +21,7 @@ pub struct AudioObjectPropertyListener {

impl AudioObjectPropertyListener {
/// Attach the provided callback as a audio object property listener.
pub fn new<F: FnMut() -> () + 'static>(
pub fn new<F: FnMut() + 'static>(
audio_object_id: AudioObjectID,
property_address: AudioObjectPropertyAddress,
callback: F,
Expand Down
4 changes: 2 additions & 2 deletions src/host/coreaudio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ fn asbd_from_config(
let frames_per_packet = 1;
let bytes_per_packet = frames_per_packet * bytes_per_frame;
let format_flags = match sample_format {
SampleFormat::F32 => (kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked) as u32,
_ => kAudioFormatFlagIsPacked as u32,
SampleFormat::F32 => kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked,
_ => kAudioFormatFlagIsPacked,
};
AudioStreamBasicDescription {
mBitsPerChannel: bits_per_channel as _,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ impl SupportedStreamConfigRange {

#[test]
fn test_cmp_default_heuristics() {
let mut formats = vec![
let mut formats = [
SupportedStreamConfigRange {
buffer_size: SupportedBufferSize::Range { min: 256, max: 512 },
channels: 2,
Expand Down

0 comments on commit f894781

Please sign in to comment.