From 2c95f1a00ec68de522fc8767cf32690b0f8fab35 Mon Sep 17 00:00:00 2001 From: taro Date: Thu, 5 Sep 2024 02:53:47 -0300 Subject: [PATCH 1/2] Optimistic update to controls.position in try_seek --- src/sink.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sink.rs b/src/sink.rs index 2de077d..59d2fab 100644 --- a/src/sink.rs +++ b/src/sink.rs @@ -238,7 +238,10 @@ impl Sink { } match feedback.recv() { - Ok(seek_res) => seek_res, + Ok(seek_res) => { + *self.controls.position.lock().unwrap() = pos; + seek_res + }, // The feedback channel closed. Probably another seekorder was set // invalidating this one and closing the feedback channel // ... or the audio thread panicked. From 7fc5bd05d1da1123213048c8422a98ab4a0079be Mon Sep 17 00:00:00 2001 From: taro Date: Thu, 5 Sep 2024 11:46:25 -0300 Subject: [PATCH 2/2] Optimistic update to controls.position in try_seek: - Add entry in CHANGELOG.md - `cargo fmt` --- CHANGELOG.md | 4 ++++ src/sink.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63faa80..1bcc2ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `fade_in` has been refactored to use the `linear_gain_ramp` implementation. +### Fixed +- `Sink.try_seek` now updates `controls.position` before returning. Calls to `Sink.get_pos` + done immediately after a seek will now return the correct value. + ### Changed - `SamplesBuffer` is now `Clone` diff --git a/src/sink.rs b/src/sink.rs index 59d2fab..71e278d 100644 --- a/src/sink.rs +++ b/src/sink.rs @@ -241,7 +241,7 @@ impl Sink { Ok(seek_res) => { *self.controls.position.lock().unwrap() = pos; seek_res - }, + } // The feedback channel closed. Probably another seekorder was set // invalidating this one and closing the feedback channel // ... or the audio thread panicked.