mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Fix clippy lint and add back ALSA padding.
This commit is contained in:
parent
b867ab2eab
commit
96f5a4d54d
2 changed files with 12 additions and 3 deletions
|
@ -41,7 +41,7 @@ async fn main() {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
let mut player = Player::new(player_config, session, Box::new(NoOpVolume), move || {
|
||||
let player = Player::new(player_config, session, Box::new(NoOpVolume), move || {
|
||||
backend(None, audio_format, sample_rate)
|
||||
});
|
||||
|
||||
|
|
|
@ -52,6 +52,9 @@ enum AlsaError {
|
|||
#[error("<AlsaSink> Device {device} May be Invalid, Busy, or Already in Use, {e}")]
|
||||
PcmSetUp { device: String, e: alsa::Error },
|
||||
|
||||
#[error("<AlsaSink> Failed to Drain PCM Buffer, {0}")]
|
||||
DrainFailure(alsa::Error),
|
||||
|
||||
#[error("<AlsaSink> {0}")]
|
||||
OnWrite(alsa::Error),
|
||||
|
||||
|
@ -236,8 +239,14 @@ impl Sink for AlsaSink {
|
|||
}
|
||||
|
||||
fn stop(&mut self) -> SinkResult<()> {
|
||||
self.period_buffer.clear();
|
||||
self.pcm = None;
|
||||
// Zero fill the remainder of the period buffer and
|
||||
// write any leftover data before draining the actual PCM buffer.
|
||||
self.period_buffer.resize(self.period_buffer.capacity(), 0);
|
||||
self.write_buf()?;
|
||||
|
||||
if let Some(pcm) = self.pcm.take() {
|
||||
pcm.drain().map_err(AlsaError::DrainFailure)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue