From 1d3a37a594f957d6127856417364fa2410858616 Mon Sep 17 00:00:00 2001 From: Hamir Mahal Date: Sun, 10 Mar 2024 09:02:55 -0700 Subject: [PATCH] refactor: replace `seek(SeekFrom::Current(0))` (#551) with more concise `stream_position()` --- src/decoder/flac.rs | 2 +- src/decoder/vorbis.rs | 2 +- src/decoder/wav.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/decoder/flac.rs b/src/decoder/flac.rs index 7b2d360e..ce6a33bc 100644 --- a/src/decoder/flac.rs +++ b/src/decoder/flac.rs @@ -124,7 +124,7 @@ fn is_flac(mut data: R) -> bool where R: Read + Seek, { - let stream_pos = data.seek(SeekFrom::Current(0)).unwrap(); + let stream_pos = data.stream_position().unwrap(); if FlacReader::new(data.by_ref()).is_err() { data.seek(SeekFrom::Start(stream_pos)).unwrap(); diff --git a/src/decoder/vorbis.rs b/src/decoder/vorbis.rs index 11a5bd9e..a02cbc0c 100644 --- a/src/decoder/vorbis.rs +++ b/src/decoder/vorbis.rs @@ -109,7 +109,7 @@ fn is_vorbis(mut data: R) -> bool where R: Read + Seek, { - let stream_pos = data.seek(SeekFrom::Current(0)).unwrap(); + let stream_pos = data.stream_position().unwrap(); if OggStreamReader::new(data.by_ref()).is_err() { data.seek(SeekFrom::Start(stream_pos)).unwrap(); diff --git a/src/decoder/wav.rs b/src/decoder/wav.rs index 5c611ee9..5b5c4267 100644 --- a/src/decoder/wav.rs +++ b/src/decoder/wav.rs @@ -154,7 +154,7 @@ fn is_wave(mut data: R) -> bool where R: Read + Seek, { - let stream_pos = data.seek(SeekFrom::Current(0)).unwrap(); + let stream_pos = data.stream_position().unwrap(); if WavReader::new(data.by_ref()).is_err() { data.seek(SeekFrom::Start(stream_pos)).unwrap();