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

Fix up tutorials and examples for Message::get_src() returning an Option now

parent 1dbc63dc
......@@ -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(),
......
......@@ -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(),
......
......@@ -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()
......
......@@ -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()
);
......
......@@ -92,8 +92,8 @@ fn create_ui(app: &gtk::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()
);
......
......@@ -162,8 +162,8 @@ fn create_ui(app: &gtk::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()
);
......
......@@ -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()
);
......
......@@ -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()
);
......
......@@ -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()
);
......
......@@ -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()
);
......
......@@ -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()
);
......
......@@ -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()
);
......
......@@ -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()
);
......
......@@ -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()
);
......
......@@ -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());
......
......@@ -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,
_ => (),
}
......
......@@ -101,8 +101,8 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::GstRc<gst::MessageRef
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()
);
......@@ -116,7 +116,10 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::GstRc<gst::MessageRef
// The duration has changed, mark the current one as invalid
custom_data.duration = gst::CLOCK_TIME_NONE;
}
MessageView::StateChanged(state) => 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();
......
......@@ -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());
}
}
_ => (),
}
});
......
......@@ -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();
......
......@@ -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());
......
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