mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
playback: Only send a packet to the audio backend if it isn't empty
The lewton decoder sometimes delivers empty packets, especially after skipping inside a track or switching tracks. This caused the pulseaudio backend to fail since it expects a non-empty packet. There is no need to handle empty packets in the audio backend, so we can skip them entirely.
This commit is contained in:
parent
e92bb451b5
commit
014533a583
1 changed files with 12 additions and 10 deletions
|
@ -372,19 +372,21 @@ impl PlayerInternal {
|
|||
fn handle_packet(&mut self, packet: Option<VorbisPacket>, normalisation_factor: f32) {
|
||||
match packet {
|
||||
Some(mut packet) => {
|
||||
if let Some(ref editor) = self.audio_filter {
|
||||
editor.modify_stream(&mut packet.data_mut())
|
||||
};
|
||||
if packet.data().len() > 0 {
|
||||
if let Some(ref editor) = self.audio_filter {
|
||||
editor.modify_stream(&mut packet.data_mut())
|
||||
};
|
||||
|
||||
if self.config.normalisation && normalisation_factor != 1.0 {
|
||||
for x in packet.data_mut().iter_mut() {
|
||||
*x = (*x as f32 * normalisation_factor) as i16;
|
||||
if self.config.normalisation && normalisation_factor != 1.0 {
|
||||
for x in packet.data_mut().iter_mut() {
|
||||
*x = (*x as f32 * normalisation_factor) as i16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Err(err) = self.sink.write(&packet.data()) {
|
||||
error!("Could not write audio: {}", err);
|
||||
self.stop_sink();
|
||||
if let Err(err) = self.sink.write(&packet.data()) {
|
||||
error!("Could not write audio: {}", err);
|
||||
self.stop_sink();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue