1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-05 19:42:03 +02:00

Various code improvements (#777)

* Remove deprecated use of std::u16::MAX
* Use `FromStr` for fallible `&str` conversions
* DRY up strings into constants
* Change `as_ref().map()` into `as_deref()`
* Use `Duration` for time constants and functions
* Optimize `Vec` with response times
* Move comments for `rustdoc` to parse
This commit is contained in:
Roderick van Domburg 2021-05-31 22:32:39 +02:00 committed by GitHub
parent bae1834988
commit ad19b69bfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 433 additions and 309 deletions

View file

@ -2,7 +2,7 @@ use super::{Open, Sink};
use crate::config::AudioFormat;
use crate::convert::Converter;
use crate::decoder::AudioPacket;
use crate::player::{NUM_CHANNELS, SAMPLE_RATE};
use crate::{NUM_CHANNELS, SAMPLE_RATE};
use portaudio_rs::device::{get_default_output_index, DeviceIndex, DeviceInfo};
use portaudio_rs::stream::*;
use std::io;
@ -57,7 +57,7 @@ impl<'a> Open for PortAudioSink<'a> {
portaudio_rs::initialize().unwrap();
let device_idx = match device.as_ref().map(AsRef::as_ref) {
let device_idx = match device.as_deref() {
Some("?") => {
list_outputs();
exit(0)
@ -178,3 +178,7 @@ impl<'a> Drop for PortAudioSink<'a> {
portaudio_rs::terminate().unwrap();
}
}
impl<'a> PortAudioSink<'a> {
pub const NAME: &'static str = "portaudio";
}