Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrançois Laignel <fengalin@free.fr>2021-10-09 13:17:05 +0300
committerFrançois Laignel <fengalin@free.fr>2021-10-18 16:09:47 +0300
commit27b9f0d868f436e9b2bcc3e51f393c40b56fcc02 (patch)
tree93c0db7b1cf26ea7d0e3a4d70a7d2844c2e00975 /audio/csound
parentbd8a7e8df7e8ebf751b2d00fe6a096d726683c00 (diff)
Improve usability thanks to opt-ops
The crate option-operations simplifies usage when dealing with `Option`s, which is often the case with `ClockTime`.
Diffstat (limited to 'audio/csound')
-rw-r--r--audio/csound/src/filter/imp.rs5
-rw-r--r--audio/csound/tests/csound_filter.rs2
2 files changed, 4 insertions, 3 deletions
diff --git a/audio/csound/src/filter/imp.rs b/audio/csound/src/filter/imp.rs
index b3c649ae6..c6f479c9c 100644
--- a/audio/csound/src/filter/imp.rs
+++ b/audio/csound/src/filter/imp.rs
@@ -120,8 +120,9 @@ impl State {
// pts at the beginning of the adapter.
let samples = distance / self.in_info.bpf() as u64;
prev_pts
- .zip(self.samples_to_time(samples))
- .map(|(prev_pts, time_offset)| prev_pts + time_offset)
+ .opt_checked_add(self.samples_to_time(samples))
+ .ok()
+ .flatten()
}
fn buffer_duration(&self, buffer_size: u64) -> Option<gst::ClockTime> {
diff --git a/audio/csound/tests/csound_filter.rs b/audio/csound/tests/csound_filter.rs
index 702d47e54..54f856a2c 100644
--- a/audio/csound/tests/csound_filter.rs
+++ b/audio/csound/tests/csound_filter.rs
@@ -181,7 +181,7 @@ fn csound_filter_eos() {
let samples_at_eos = (EOS_NUM_BUFFERS * EOS_NUM_SAMPLES) % ksmps;
assert_eq!(
buffer.as_ref().pts(),
- duration_from_samples(samples_at_eos as _, sr as _).map(|duration| in_pts - duration)
+ in_pts.opt_sub(duration_from_samples(samples_at_eos as _, sr as _))
);
let map = buffer.into_mapped_buffer_readable().unwrap();