forked from mirrors/gstreamer-rs
tutorial: take advantage of Div impl on Percent
This commit is contained in:
parent
deb22b264e
commit
f83b385487
1 changed files with 12 additions and 12 deletions
|
@ -116,7 +116,7 @@ fn tutorial_main() -> Result<(), Error> {
|
||||||
|
|
||||||
let pipeline_weak_ = pipeline.downgrade();
|
let pipeline_weak_ = pipeline.downgrade();
|
||||||
let timeout_id = glib::timeout_add_seconds(1, move || {
|
let timeout_id = glib::timeout_add_seconds(1, move || {
|
||||||
use gst::GenericFormattedValue::Percent;
|
use gst::{format::Percent, GenericFormattedValue as GFV};
|
||||||
|
|
||||||
let pipeline = match pipeline_weak_.upgrade() {
|
let pipeline = match pipeline_weak_.upgrade() {
|
||||||
Some(pipeline) => pipeline,
|
Some(pipeline) => pipeline,
|
||||||
|
@ -129,21 +129,21 @@ fn tutorial_main() -> Result<(), Error> {
|
||||||
for range in &ranges {
|
for range in &ranges {
|
||||||
let start = range.0;
|
let start = range.0;
|
||||||
let stop = range.1;
|
let stop = range.1;
|
||||||
let start = if let Percent(start) = start {
|
let start = if let GFV::Percent(start) = start {
|
||||||
*start.unwrap()
|
start.unwrap()
|
||||||
} else {
|
} else {
|
||||||
0
|
Percent::ZERO
|
||||||
} / *gst::format::Percent::MAX;
|
} / Percent::MAX;
|
||||||
let stop = if let Percent(stop) = stop {
|
let stop = if let GFV::Percent(stop) = stop {
|
||||||
*stop.unwrap()
|
stop.unwrap()
|
||||||
} else {
|
} else {
|
||||||
0
|
Percent::ZERO
|
||||||
} / *gst::format::Percent::MAX;
|
} / Percent::MAX;
|
||||||
if start == 0 && stop == 0 {
|
if start.is_zero() && stop.is_zero() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let start_ = (start * GRAPH_LENGTH as u32) / (stop - start);
|
let start_ = *((start * GRAPH_LENGTH as u32) / (stop - start));
|
||||||
let stop_ = (stop * GRAPH_LENGTH as u32) / (stop - start);
|
let stop_ = *((stop * GRAPH_LENGTH as u32) / (stop - start));
|
||||||
for j in start_..stop_ {
|
for j in start_..stop_ {
|
||||||
graph[j as usize] = b'-';
|
graph[j as usize] = b'-';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue