Commit f1025170 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Use while-let and CLOCK_TIME_NONE for the bus.timed_pop() loops in the examples/tutorials

parent a1679f62
......@@ -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) => {
......
......@@ -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) => {
......
......@@ -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) => {
......
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) => {
......
......@@ -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) => {
......
......@@ -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) => {
......
......@@ -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) => {
......
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) => {
......
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