From f1025170d9c54872aa8e4138791c775528932c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 13 Sep 2017 19:35:35 +0300 Subject: [PATCH] Use while-let and CLOCK_TIME_NONE for the bus.timed_pop() loops in the examples/tutorials --- examples/src/bin/appsink.rs | 8 +------- examples/src/bin/appsrc.rs | 8 +------- examples/src/bin/decodebin.rs | 8 +------- examples/src/bin/launch.rs | 8 +------- examples/src/bin/pad_probes.rs | 8 +------- examples/src/bin/playbin.rs | 8 +------- examples/src/bin/toc.rs | 8 +------- tutorials/src/bin/basic-tutorial-1.rs | 9 +-------- 8 files changed, 8 insertions(+), 57 deletions(-) diff --git a/examples/src/bin/appsink.rs b/examples/src/bin/appsink.rs index fba83a252..70a6045d8 100644 --- a/examples/src/bin/appsink.rs +++ b/examples/src/bin/appsink.rs @@ -6,7 +6,6 @@ extern crate gstreamer_audio as gst_audio; extern crate byte_slice_cast; use byte_slice_cast::*; -use std::u64; use std::i16; use std::i32; @@ -90,14 +89,9 @@ fn main_loop() -> Result<(), utils::ExampleError> { .get_bus() .expect("Pipeline without bus. Shouldn't happen!"); - loop { + while let Some(msg) = bus.timed_pop(gst::CLOCK_TIME_NONE) { use gst::MessageView; - let msg = match bus.timed_pop(u64::MAX) { - None => break, - Some(msg) => msg, - }; - match msg.view() { MessageView::Eos(..) => break, MessageView::Error(err) => { diff --git a/examples/src/bin/appsrc.rs b/examples/src/bin/appsrc.rs index bb9ee84a1..037dcc4e4 100644 --- a/examples/src/bin/appsrc.rs +++ b/examples/src/bin/appsrc.rs @@ -3,7 +3,6 @@ use gst::prelude::*; extern crate gstreamer_app as gst_app; extern crate gstreamer_video as gst_video; -use std::u64; use std::thread; pub mod utils; @@ -83,14 +82,9 @@ fn main_loop() -> Result<(), utils::ExampleError> { .get_bus() .expect("Pipeline without bus. Shouldn't happen!"); - loop { + while let Some(msg) = bus.timed_pop(gst::CLOCK_TIME_NONE) { use gst::MessageView; - let msg = match bus.timed_pop(u64::MAX) { - None => break, - Some(msg) => msg, - }; - match msg.view() { MessageView::Eos(..) => break, MessageView::Error(err) => { diff --git a/examples/src/bin/decodebin.rs b/examples/src/bin/decodebin.rs index efd838924..40b419f87 100644 --- a/examples/src/bin/decodebin.rs +++ b/examples/src/bin/decodebin.rs @@ -4,7 +4,6 @@ use gst::prelude::*; extern crate glib; use std::env; -use std::u64; fn main() { gst::init().unwrap(); @@ -81,14 +80,9 @@ fn main() { let bus = pipeline.get_bus().unwrap(); - loop { + while let Some(msg) = bus.timed_pop(gst::CLOCK_TIME_NONE) { use gst::MessageView; - let msg = match bus.timed_pop(u64::MAX) { - None => break, - Some(msg) => msg, - }; - match msg.view() { MessageView::Eos(..) => break, MessageView::Error(err) => { diff --git a/examples/src/bin/launch.rs b/examples/src/bin/launch.rs index f7a273b8d..78d847cba 100644 --- a/examples/src/bin/launch.rs +++ b/examples/src/bin/launch.rs @@ -1,7 +1,6 @@ extern crate gstreamer as gst; use gst::prelude::*; -use std::u64; use std::env; use std::process; @@ -29,14 +28,9 @@ fn main() { let ret = pipeline.set_state(gst::State::Playing); assert_ne!(ret, gst::StateChangeReturn::Failure); - loop { + while let Some(msg) = bus.timed_pop(gst::CLOCK_TIME_NONE) { use gst::MessageView; - let msg = match bus.timed_pop(u64::MAX) { - None => break, - Some(msg) => msg, - }; - match msg.view() { MessageView::Eos(..) => break, MessageView::Error(err) => { diff --git a/examples/src/bin/pad_probes.rs b/examples/src/bin/pad_probes.rs index 43d5cf35e..677759681 100644 --- a/examples/src/bin/pad_probes.rs +++ b/examples/src/bin/pad_probes.rs @@ -5,7 +5,6 @@ extern crate gstreamer_audio as gst_audio; extern crate byte_slice_cast; use byte_slice_cast::*; -use std::u64; use std::i16; fn main() { @@ -51,14 +50,9 @@ fn main() { let ret = pipeline.set_state(gst::State::Playing); assert_ne!(ret, gst::StateChangeReturn::Failure); - loop { + while let Some(msg) = bus.timed_pop(gst::CLOCK_TIME_NONE) { use gst::MessageView; - let msg = match bus.timed_pop(u64::MAX) { - None => break, - Some(msg) => msg, - }; - match msg.view() { MessageView::Eos(..) => break, MessageView::Error(err) => { diff --git a/examples/src/bin/playbin.rs b/examples/src/bin/playbin.rs index b9dc502c9..2fdbf554b 100644 --- a/examples/src/bin/playbin.rs +++ b/examples/src/bin/playbin.rs @@ -4,7 +4,6 @@ use gst::prelude::*; extern crate glib; use std::env; -use std::u64; fn main() { gst::init().unwrap(); @@ -65,14 +64,9 @@ fn main() { let ret = playbin.set_state(gst::State::Playing); assert_ne!(ret, gst::StateChangeReturn::Failure); - loop { + while let Some(msg) = bus.timed_pop(gst::CLOCK_TIME_NONE) { use gst::MessageView; - let msg = match bus.timed_pop(u64::MAX) { - None => break, - Some(msg) => msg, - }; - match msg.view() { MessageView::Eos(..) => break, MessageView::Error(err) => { diff --git a/examples/src/bin/toc.rs b/examples/src/bin/toc.rs index fed9e0be2..16fdff6c0 100644 --- a/examples/src/bin/toc.rs +++ b/examples/src/bin/toc.rs @@ -4,7 +4,6 @@ use gst::prelude::*; extern crate glib; use std::env; -use std::u64; fn main() { gst::init().unwrap(); @@ -52,14 +51,9 @@ fn main() { let bus = pipeline.get_bus().unwrap(); - loop { + while let Some(msg) = bus.timed_pop(gst::CLOCK_TIME_NONE) { use gst::MessageView; - let msg = match bus.timed_pop(u64::MAX) { - None => break, - Some(msg) => msg, - }; - match msg.view() { MessageView::Eos(_) | MessageView::AsyncDone(_) => break, MessageView::Error(err) => { diff --git a/tutorials/src/bin/basic-tutorial-1.rs b/tutorials/src/bin/basic-tutorial-1.rs index 166f857bf..aa0a353a2 100644 --- a/tutorials/src/bin/basic-tutorial-1.rs +++ b/tutorials/src/bin/basic-tutorial-1.rs @@ -1,8 +1,6 @@ extern crate gstreamer as gst; use gst::prelude::*; -use std::u64; - fn main() { // Initialize GStreamer gst::init().unwrap(); @@ -17,14 +15,9 @@ fn main() { // Wait until error or EOS let bus = pipeline.get_bus().unwrap(); - loop { + while let Some(msg) = bus.timed_pop(gst::CLOCK_TIME_NONE) { use gst::MessageView; - let msg = match bus.timed_pop(u64::MAX) { - None => break, - Some(msg) => msg, - }; - match msg.view() { MessageView::Eos(..) => break, MessageView::Error(err) => {