Skip to content

Commit

Permalink
Merge pull request #262 from librespot-org/seek-eof
Browse files Browse the repository at this point in the history
Fix seek past EOF panic for some tracks
  • Loading branch information
sashahilton00 committed Nov 19, 2018
2 parents 96557b4 + 74e0ada commit d2cadec
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions audio/src/fetch.rs
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit d2cadec

Please sign in to comment.