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

This commit is contained in:
Sebastian Dröge 2017-09-13 19:35:35 +03:00
parent a1679f6216
commit f1025170d9
8 changed files with 8 additions and 57 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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