Commit 95dc336b authored by Luis de Bethencourt's avatar Luis de Bethencourt Committed by Sebastian Dröge

Use while let

When destructuring a single pattern in a loop it is nicer to use while let.

Fixes https://github.com/sdroege/gstreamer-rs/pull/46
Fixes https://github.com/sdroege/gstreamer-rs/issues/45
parent 342d89dd
...@@ -119,42 +119,35 @@ fn main() { ...@@ -119,42 +119,35 @@ fn main() {
// Wait until error, EOS or State Change // Wait until error, EOS or State Change
let bus = pipeline.get_bus().unwrap(); let bus = pipeline.get_bus().unwrap();
loop { while let Some(msg) = bus.timed_pop(gst::CLOCK_TIME_NONE) {
let msg = bus.timed_pop(gst::CLOCK_TIME_NONE); match msg.view() {
MessageView::Error(err) => {
match msg { println!(
Some(msg) => { "Error received from element {}: {} ({:?})",
match msg.view() { msg.get_src().get_path_string(),
MessageView::Error(err) => { err.get_error(),
println!( err.get_debug()
"Error received from element {}: {} ({:?})", );
msg.get_src().get_path_string(), break;
err.get_error(),
err.get_debug()
);
break;
}
MessageView::Eos(..) => {
println!("End-Of-Stream reached.");
break;
}
MessageView::StateChanged(state) =>
// We are only interested in state-changed messages from the pipeline
if msg.get_src() == pipeline {
let new_state = state.get_current();
let old_state = state.get_old();
println!(
"Pipeline state changed from {:?} to {:?}",
old_state,
new_state
);
print_pad_capabilities(&sink, "sink");
},
_ => (),
}
} }
None => (), MessageView::Eos(..) => {
println!("End-Of-Stream reached.");
break;
}
MessageView::StateChanged(state) =>
// We are only interested in state-changed messages from the pipeline
if msg.get_src() == pipeline {
let new_state = state.get_current();
let old_state = state.get_old();
println!(
"Pipeline state changed from {:?} to {:?}",
old_state,
new_state
);
print_pad_capabilities(&sink, "sink");
},
_ => (),
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment