diff --git a/examples/src/bin/appsink.rs b/examples/src/bin/appsink.rs index f6f6d7f41..2f7e5ee6a 100644 --- a/examples/src/bin/appsink.rs +++ b/examples/src/bin/appsink.rs @@ -140,7 +140,9 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> { MessageView::Error(err) => { pipeline.set_state(gst::State::Null).into_result()?; Err(ErrorMessage { - src: msg.get_src().get_path_string(), + src: msg.get_src() + .map(|s| s.get_path_string()) + .unwrap_or(String::from("None")), error: err.get_error().description().into(), debug: err.get_debug(), cause: err.get_error(), diff --git a/examples/src/bin/appsrc.rs b/examples/src/bin/appsrc.rs index c95978a3a..ee4747aee 100644 --- a/examples/src/bin/appsrc.rs +++ b/examples/src/bin/appsrc.rs @@ -111,7 +111,9 @@ fn main_loop(pipeline: gst::Pipeline, appsrc: gst_app::AppSrc) -> Result<(), Err MessageView::Error(err) => { pipeline.set_state(gst::State::Null).into_result()?; Err(ErrorMessage { - src: msg.get_src().get_path_string(), + src: msg.get_src() + .map(|s| s.get_path_string()) + .unwrap_or(String::from("None")), error: err.get_error().description().into(), debug: err.get_debug(), cause: err.get_error(), diff --git a/examples/src/bin/decodebin.rs b/examples/src/bin/decodebin.rs index 3525e898d..8cc77fc12 100644 --- a/examples/src/bin/decodebin.rs +++ b/examples/src/bin/decodebin.rs @@ -6,6 +6,7 @@ extern crate glib; use std::env; use std::error::Error as StdError; +#[cfg(feature = "v1_10")] use std::sync::{Arc, Mutex}; extern crate failure; @@ -137,7 +138,12 @@ fn example_main() -> Result<(), Error> { ); #[cfg(not(feature = "v1_10"))] - gst_element_error!(dbin, gst::LibraryError::Failed, ("Failed to insert sink")); + gst_element_error!( + dbin, + gst::LibraryError::Failed, + ("Failed to insert sink"), + ["{}", err] + ); } }); @@ -169,7 +175,9 @@ fn example_main() -> Result<(), Error> { .expect("error-details message without actual error"), _ => Err( ErrorMessage { - src: msg.get_src().get_path_string(), + src: msg.get_src() + .map(|s| s.get_path_string()) + .unwrap_or(String::from("None")), error: err.get_error().description().into(), debug: err.get_debug(), cause: err.get_error(), @@ -180,7 +188,9 @@ fn example_main() -> Result<(), Error> { #[cfg(not(feature = "v1_10"))] { Err(ErrorMessage { - src: msg.get_src().get_path_string(), + src: msg.get_src() + .map(|s| s.get_path_string()) + .unwrap_or(String::from("None")), error: err.get_error().description().into(), debug: err.get_debug(), cause: err.get_error(), @@ -190,8 +200,8 @@ fn example_main() -> Result<(), Error> { } MessageView::StateChanged(s) => { println!( - "State changed from {}: {:?} -> {:?} ({:?})", - msg.get_src().get_path_string(), + "State changed from {:?}: {:?} -> {:?} ({:?})", + msg.get_src().map(|s| s.get_path_string()), s.get_old(), s.get_current(), s.get_pending() diff --git a/examples/src/bin/events.rs b/examples/src/bin/events.rs index 584e051b9..9dcd2eff6 100644 --- a/examples/src/bin/events.rs +++ b/examples/src/bin/events.rs @@ -44,8 +44,8 @@ fn example_main() { } MessageView::Error(err) => { println!( - "Error from {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error from {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); diff --git a/examples/src/bin/gtksink.rs b/examples/src/bin/gtksink.rs index c277d04ba..b1af1fd75 100644 --- a/examples/src/bin/gtksink.rs +++ b/examples/src/bin/gtksink.rs @@ -92,8 +92,8 @@ fn create_ui(app: >k::Application) { MessageView::Eos(..) => gtk::main_quit(), MessageView::Error(err) => { println!( - "Error from {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error from {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); diff --git a/examples/src/bin/gtkvideooverlay.rs b/examples/src/bin/gtkvideooverlay.rs index aa136b4b9..593757bf9 100644 --- a/examples/src/bin/gtkvideooverlay.rs +++ b/examples/src/bin/gtkvideooverlay.rs @@ -162,8 +162,8 @@ fn create_ui(app: >k::Application) { MessageView::Eos(..) => gtk::main_quit(), MessageView::Error(err) => { println!( - "Error from {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error from {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); diff --git a/examples/src/bin/launch.rs b/examples/src/bin/launch.rs index 1b6a4dce7..cb54b64ba 100644 --- a/examples/src/bin/launch.rs +++ b/examples/src/bin/launch.rs @@ -38,8 +38,8 @@ fn example_main() { MessageView::Eos(..) => break, MessageView::Error(err) => { println!( - "Error from {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error from {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); diff --git a/examples/src/bin/launch_glib_main.rs b/examples/src/bin/launch_glib_main.rs index cf6f5db5d..0e429d076 100644 --- a/examples/src/bin/launch_glib_main.rs +++ b/examples/src/bin/launch_glib_main.rs @@ -33,8 +33,8 @@ fn example_main() { MessageView::Eos(..) => main_loop.quit(), MessageView::Error(err) => { println!( - "Error from {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error from {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); diff --git a/examples/src/bin/pad_probes.rs b/examples/src/bin/pad_probes.rs index 927488b0b..adb010600 100644 --- a/examples/src/bin/pad_probes.rs +++ b/examples/src/bin/pad_probes.rs @@ -60,8 +60,8 @@ fn example_main() { MessageView::Eos(..) => break, MessageView::Error(err) => { println!( - "Error from {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error from {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); diff --git a/examples/src/bin/playbin.rs b/examples/src/bin/playbin.rs index 4be959652..b671b7c98 100644 --- a/examples/src/bin/playbin.rs +++ b/examples/src/bin/playbin.rs @@ -75,8 +75,8 @@ fn example_main() { MessageView::Eos(..) => break, MessageView::Error(err) => { println!( - "Error from {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error from {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); diff --git a/examples/src/bin/queries.rs b/examples/src/bin/queries.rs index 2bb02e695..22ad377cb 100644 --- a/examples/src/bin/queries.rs +++ b/examples/src/bin/queries.rs @@ -72,8 +72,8 @@ fn example_main() { MessageView::Eos(..) => main_loop.quit(), MessageView::Error(err) => { println!( - "Error from {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error from {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); diff --git a/examples/src/bin/toc.rs b/examples/src/bin/toc.rs index 18bbb8d3f..597e9728d 100644 --- a/examples/src/bin/toc.rs +++ b/examples/src/bin/toc.rs @@ -62,8 +62,8 @@ fn example_main() { MessageView::Eos(_) | MessageView::AsyncDone(_) => break, MessageView::Error(err) => { println!( - "Error from {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error from {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); diff --git a/examples/src/bin/tokio.rs b/examples/src/bin/tokio.rs index 36f570803..557562303 100644 --- a/examples/src/bin/tokio.rs +++ b/examples/src/bin/tokio.rs @@ -40,8 +40,8 @@ fn example_main() { MessageView::Eos(..) => true, MessageView::Error(err) => { println!( - "Error from {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error from {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); diff --git a/tutorials/src/bin/basic-tutorial-1.rs b/tutorials/src/bin/basic-tutorial-1.rs index 62980de86..0de814a77 100644 --- a/tutorials/src/bin/basic-tutorial-1.rs +++ b/tutorials/src/bin/basic-tutorial-1.rs @@ -26,8 +26,8 @@ fn tutorial_main() { MessageView::Eos(..) => break, MessageView::Error(err) => { println!( - "Error from {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error from {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); diff --git a/tutorials/src/bin/basic-tutorial-2.rs b/tutorials/src/bin/basic-tutorial-2.rs index 8a0ac9b06..f5c016c02 100644 --- a/tutorials/src/bin/basic-tutorial-2.rs +++ b/tutorials/src/bin/basic-tutorial-2.rs @@ -39,8 +39,8 @@ fn tutorial_main() { match msg.view() { MessageView::Error(err) => { eprintln!( - "Error received from element {}: {}", - msg.get_src().get_path_string(), + "Error received from element {:?}: {}", + msg.get_src().map(|s| s.get_path_string()), err.get_error() ); eprintln!("Debugging information: {:?}", err.get_debug()); diff --git a/tutorials/src/bin/basic-tutorial-3.rs b/tutorials/src/bin/basic-tutorial-3.rs index aad8ab823..36991defa 100644 --- a/tutorials/src/bin/basic-tutorial-3.rs +++ b/tutorials/src/bin/basic-tutorial-3.rs @@ -92,20 +92,22 @@ fn tutorial_main() { match msg.view() { MessageView::Error(err) => { eprintln!( - "Error received from element {}: {}", - msg.get_src().get_path_string(), + "Error received from element {:?} {}", + msg.get_src().map(|s| s.get_path_string()), err.get_error() ); eprintln!("Debugging information: {:?}", err.get_debug()); break; } - MessageView::StateChanged(s) => if msg.get_src() == pipeline { - println!( - "Pipeline state changed from {:?} to {:?}", - s.get_old(), - s.get_current() - ); - }, + MessageView::StateChanged(s) => { + if msg.get_src().map(|s| s == pipeline).unwrap_or(false) { + println!( + "Pipeline state changed from {:?} to {:?}", + s.get_old(), + s.get_current() + ); + } + } MessageView::Eos(..) => break, _ => (), } diff --git a/tutorials/src/bin/basic-tutorial-4.rs b/tutorials/src/bin/basic-tutorial-4.rs index 64e4470a9..39a71482f 100644 --- a/tutorials/src/bin/basic-tutorial-4.rs +++ b/tutorials/src/bin/basic-tutorial-4.rs @@ -101,8 +101,8 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::GstRc { println!( - "Error received from element {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error received from element {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); @@ -116,7 +116,10 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::GstRc if msg.get_src() == custom_data.playbin { + MessageView::StateChanged(state) => if msg.get_src() + .map(|s| s == custom_data.playbin) + .unwrap_or(false) + { let new_state = state.get_current(); let old_state = state.get_old(); diff --git a/tutorials/src/bin/basic-tutorial-5.rs b/tutorials/src/bin/basic-tutorial-5.rs index 4cc45083c..42ef7d181 100644 --- a/tutorials/src/bin/basic-tutorial-5.rs +++ b/tutorials/src/bin/basic-tutorial-5.rs @@ -337,17 +337,19 @@ mod tutorial5 { // This is called when an error message is posted on the bus gst::MessageView::Error(err) => { println!( - "Error from {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error from {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); } // This is called when the pipeline changes states. We use it to // keep track of the current state. - gst::MessageView::StateChanged(view) => if msg.get_src() == pipeline { - println!("State set to {:?}", view.get_current()); - }, + gst::MessageView::StateChanged(view) => { + if msg.get_src().map(|s| s == pipeline).unwrap_or(false) { + println!("State set to {:?}", view.get_current()); + } + } _ => (), } }); diff --git a/tutorials/src/bin/basic-tutorial-6.rs b/tutorials/src/bin/basic-tutorial-6.rs index b3ddd1140..b6351aee7 100644 --- a/tutorials/src/bin/basic-tutorial-6.rs +++ b/tutorials/src/bin/basic-tutorial-6.rs @@ -125,8 +125,8 @@ fn tutorial_main() { match msg.view() { MessageView::Error(err) => { println!( - "Error received from element {}: {} ({:?})", - msg.get_src().get_path_string(), + "Error received from element {:?}: {} ({:?})", + msg.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); @@ -138,7 +138,7 @@ fn tutorial_main() { } MessageView::StateChanged(state) => // We are only interested in state-changed messages from the pipeline - if msg.get_src() == pipeline { + if msg.get_src().map(|s| s == pipeline).unwrap_or(false) { let new_state = state.get_current(); let old_state = state.get_old(); diff --git a/tutorials/src/bin/basic-tutorial-7.rs b/tutorials/src/bin/basic-tutorial-7.rs index 0ba3445e5..bf9d1cc96 100644 --- a/tutorials/src/bin/basic-tutorial-7.rs +++ b/tutorials/src/bin/basic-tutorial-7.rs @@ -78,8 +78,8 @@ fn tutorial_main() { match msg.view() { MessageView::Error(err) => { eprintln!( - "Error received from element {}: {}", - msg.get_src().get_path_string(), + "Error received from element {:?}: {}", + msg.get_src().map(|s| s.get_path_string()), err.get_error() ); eprintln!("Debugging information: {:?}", err.get_debug());