mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
On stop write any chunk(s) left in the period buffer
That should prevent a possible sudden stop
This commit is contained in:
parent
cbe3c98fa1
commit
a68dfa0287
1 changed files with 8 additions and 1 deletions
|
@ -107,7 +107,14 @@ impl Sink for AlsaSink {
|
|||
|
||||
fn stop(&mut self) -> io::Result<()> {
|
||||
{
|
||||
let pcm = self.pcm.as_ref().unwrap();
|
||||
let pcm = self.pcm.as_mut().unwrap();
|
||||
// Write any leftover data in the period buffer
|
||||
// before draining the actual buffer
|
||||
let io = pcm.io_i16().unwrap();
|
||||
match io.writei(&self.buffer[..self.buffered_data]) {
|
||||
Ok(_) => (),
|
||||
Err(err) => pcm.try_recover(err, false).unwrap(),
|
||||
}
|
||||
pcm.drain().unwrap();
|
||||
}
|
||||
self.pcm = None;
|
||||
|
|
Loading…
Reference in a new issue