mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Fix seek past EOF panic for some tracks
This commit is contained in:
parent
96557b4ec1
commit
74e0adac15
1 changed files with 9 additions and 4 deletions
|
@ -348,11 +348,16 @@ impl Read for AudioFileStreaming {
|
|||
impl Seek for AudioFileStreaming {
|
||||
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
|
||||
self.position = try!(self.read_file.seek(pos));
|
||||
// Do not seek past EOF
|
||||
if (self.position as usize % CHUNK_SIZE) != 0 {
|
||||
// Notify the fetch thread to get the correct block
|
||||
// This can fail if fetch thread has completed, in which case the
|
||||
// block is ready. Just ignore the error.
|
||||
let _ = self.seek.unbounded_send(self.position);
|
||||
} else {
|
||||
warn!("Trying to seek past EOF");
|
||||
}
|
||||
|
||||
// Notify the fetch thread to get the correct block
|
||||
// This can fail if fetch thread has completed, in which case the
|
||||
// block is ready. Just ignore the error.
|
||||
let _ = self.seek.unbounded_send(self.position);
|
||||
Ok(self.position)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue