transcriberbin: switch to passthrough on transcriber error

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/569>
This commit is contained in:
Mathieu Duponchelle 2021-09-28 01:50:49 +02:00 committed by GStreamer Marge Bot
parent b1bd3020fa
commit 01cc9e23d8

View file

@ -854,4 +854,42 @@ impl ElementImpl for TranscriberBin {
}
}
impl BinImpl for TranscriberBin {}
impl BinImpl for TranscriberBin {
fn handle_message(&self, bin: &Self::Type, msg: gst::Message) {
use gst::MessageView;
match msg.view() {
MessageView::Error(ref m) => {
/* We must have a state here */
let s = self.state.lock().unwrap();
if let Some(state) = s.as_ref() {
if msg.src().as_ref() == Some(state.transcriber.upcast_ref()) {
gst_error!(
CAT,
obj: bin,
"Transcriber has posted an error ({:?}), going back to passthrough",
m
);
drop(s);
let mut settings = self.settings.lock().unwrap();
settings.passthrough = true;
bin.notify("passthrough");
drop(settings);
bin.call_async(move |bin| {
let thiz = TranscriberBin::from_instance(bin);
thiz.block_and_update(bin, true);
});
} else {
drop(s);
self.parent_handle_message(bin, msg);
}
} else {
drop(s);
self.parent_handle_message(bin, msg);
}
}
_ => self.parent_handle_message(bin, msg),
}
}
}