From 5a10a963ff2fcddc8ddd1fa8ff8a11793415953b Mon Sep 17 00:00:00 2001 From: JasonLG1979 Date: Sat, 18 Jun 2022 09:08:04 -0500 Subject: [PATCH 1/2] Minor alsa backend tweaks Silence a clippy warning and we don't need `std::cmp::min` when `usize` already has `min`. --- playback/src/audio_backend/alsa.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/playback/src/audio_backend/alsa.rs b/playback/src/audio_backend/alsa.rs index 20e73618..e8d9ee05 100644 --- a/playback/src/audio_backend/alsa.rs +++ b/playback/src/audio_backend/alsa.rs @@ -6,7 +6,6 @@ use crate::{NUM_CHANNELS, SAMPLE_RATE}; use alsa::device_name::HintIter; use alsa::pcm::{Access, Format, Frames, HwParams, PCM}; use alsa::{Direction, ValueOr}; -use std::cmp::min; use std::process::exit; use thiserror::Error; @@ -141,7 +140,7 @@ fn list_compatible_devices() -> SinkResult<()> { println!( "\tDescription:\n\n\t\t{}\n", - a.desc.unwrap_or_default().replace("\n", "\n\t\t") + a.desc.unwrap_or_default().replace('\n', "\n\t\t") ); println!( @@ -467,7 +466,7 @@ impl SinkAsBytes for AlsaSink { loop { let data_left = data_len - start_index; let space_left = capacity - self.period_buffer.len(); - let data_to_buffer = min(data_left, space_left); + let data_to_buffer = data_left.min(space_left); let end_index = start_index + data_to_buffer; self.period_buffer From 0db17973a152657990c3fd5d695bf531edcd2b0f Mon Sep 17 00:00:00 2001 From: JasonLG1979 Date: Sat, 25 Jun 2022 00:17:36 -0500 Subject: [PATCH 2/2] Fix --opt=value line argument logging Fixes https://github.com/librespot-org/librespot/issues/1011 --- src/main.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5e4b0bb5..0c542f6f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -658,7 +658,15 @@ fn get_setup() -> Setup { trace!("Command line argument(s):"); for (index, key) in args.iter().enumerate() { - let opt = key.trim_start_matches('-'); + let opt = { + let key = key.trim_start_matches('-'); + + if let Some((s, _)) = key.split_once('=') { + s + } else { + key + } + }; if index > 0 && key.starts_with('-') @@ -668,13 +676,13 @@ fn get_setup() -> Setup { { if matches!(opt, PASSWORD | PASSWORD_SHORT | USERNAME | USERNAME_SHORT) { // Don't log creds. - trace!("\t\t{} \"XXXXXXXX\"", key); + trace!("\t\t{} \"XXXXXXXX\"", opt); } else { let value = matches.opt_str(opt).unwrap_or_else(|| "".to_string()); if value.is_empty() { - trace!("\t\t{}", key); + trace!("\t\t{}", opt); } else { - trace!("\t\t{} \"{}\"", key, value); + trace!("\t\t{} \"{}\"", opt, value); } } }