X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=sndplay%2Fsrc%2Fmain.rs;h=c368651a6815e68e3e87e8370d9972eabdc4c3c1;hb=ff58185ab2070ba00779e48df0fd7e7f6a87ad9e;hp=c8e75a420731439355bad5c45ef1e7f432485aa7;hpb=b2d3e848c0984925382081499ddf518ae22f2641;p=nihav-player.git diff --git a/sndplay/src/main.rs b/sndplay/src/main.rs index c8e75a4..c368651 100644 --- a/sndplay/src/main.rs +++ b/sndplay/src/main.rs @@ -153,6 +153,9 @@ impl<'a> Decoder<'a> { if let Some(pts) = frm.ts.get_pts() { self.samplepos = NATimeInfo::ts_to_time(pts, u64::from(self.arate), frm.ts.tb_num, frm.ts.tb_den); } + if buf.get_audio_length() == 0 { + return false; + } let out_buf = convert_audio_frame(&buf, &self.dst_info, &self.dst_chmap).unwrap(); match out_buf { NABufferType::AudioI16(abuf) => { @@ -193,6 +196,7 @@ impl<'a> Decoder<'a> { fn seek(&mut self, time: u64) -> bool { let ret = self.demuxer.seek(NATimePoint::Milliseconds(time)); if ret.is_err() { println!(" seek error\n"); } + self.decoder.flush(); ret.is_ok() } } @@ -359,7 +363,7 @@ impl Player { } } std::io::stdout().flush().unwrap(); - if device.size() < underfill_limit && !self.paused && refill_limit < (1 << 20) { + if device.size() < underfill_limit && !self.paused && (refill_limit < (1 << 20)) & !eof { if full_ms > 5000 { println!("underrun!"); }