ソースを参照

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.
Thomas Bächler 7 年 前
コミット
014533a583
1 ファイル変更13 行追加11 行削除
  1. 13 11
      playback/src/player.rs

+ 13 - 11
playback/src/player.rs

@@ -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 self.config.normalisation && normalisation_factor != 1.0 {
-                    for x in packet.data_mut().iter_mut() {
-                        *x = (*x as f32 * normalisation_factor) as i16;
+                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 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();
+                    }
                 }
             }