Skip to content

Commit

Permalink
Fix clippy lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLG1979 committed Jun 22, 2023
1 parent efec96b commit dd85a60
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions playback/src/audio_backend/portaudio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{Open, Sink, SinkError, SinkResult};
use crate::config::AudioFormat;
use crate::convert::Converter;
use crate::decoder::AudioPacket;
use crate::{NUM_CHANNELS, SAMPLE_RATE};
use crate::NUM_CHANNELS;
use portaudio_rs::device::{get_default_output_index, DeviceIndex, DeviceInfo};
use portaudio_rs::stream::*;
use std::process::exit;
Expand Down Expand Up @@ -76,14 +76,14 @@ impl<'a> Open for PortAudioSink<'a> {
};

macro_rules! open_sink {
($sink: expr, $type: ty) => {{
($sink: expr, $type: ty, $sample_rate: ident) => {{
let params = StreamParameters {
device: device_idx,
channel_count: NUM_CHANNELS as u32,
suggested_latency: latency,
data: 0.0 as $type,
};
$sink(None, params, sample_rate)
$sink(None, params, $sample_rate)
}};
}
match format {
Expand Down Expand Up @@ -141,9 +141,9 @@ impl<'a> Sink for PortAudioSink<'a> {
}};
}
match self {
Self::F32(stream, _) => stop_sink!(ref mut stream),
Self::S32(stream, _) => stop_sink!(ref mut stream),
Self::S16(stream, _) => stop_sink!(ref mut stream),
Self::F32(stream, _, _) => stop_sink!(ref mut stream),
Self::S32(stream, _, _) => stop_sink!(ref mut stream),
Self::S16(stream, _, _) => stop_sink!(ref mut stream),
};

Ok(())
Expand All @@ -161,15 +161,15 @@ impl<'a> Sink for PortAudioSink<'a> {
.map_err(|e| SinkError::OnWrite(e.to_string()))?;

let result = match self {
Self::F32(stream, _parameters) => {
Self::F32(stream, _parameters, _sample_rate) => {
let samples_f32: &[f32] = &converter.f64_to_f32(samples);
write_sink!(ref mut stream, samples_f32)
}
Self::S32(stream, _parameters) => {
Self::S32(stream, _parameters, _sample_rate) => {
let samples_s32: &[i32] = &converter.f64_to_s32(samples);
write_sink!(ref mut stream, samples_s32)
}
Self::S16(stream, _parameters) => {
Self::S16(stream, _parameters, _sample_rate) => {
let samples_s16: &[i16] = &converter.f64_to_s16(samples);
write_sink!(ref mut stream, samples_s16)
}
Expand Down

0 comments on commit dd85a60

Please sign in to comment.