未验证 提交 9537a909 编写于 作者: J Jonas Vautherin 提交者: GitHub

Merge pull request #20801 from JonasVautherin:fix-gst-error-handling

* Fix gst error handling

* Use the return value instead of the error, which gives no guarantee of being NULL in case of error
* Test err pointer before accessing it
* Remove unreachable code

* videoio(gstreamer): restore check in writer code
Co-authored-by: NAlexander Alekhin <alexander.a.alekhin@gmail.com>
上级 dfc94c58
......@@ -761,7 +761,7 @@ bool GStreamerCapture::open(const String &filename_)
}
else
{
CV_WARN("Error opening file: " << filename << " (" << err->message << ")");
CV_WARN("Error opening file: " << filename << " (" << (err ? err->message : "<unknown reason>") << ")");
return false;
}
}
......@@ -769,9 +769,9 @@ bool GStreamerCapture::open(const String &filename_)
{
GSafePtr<GError> err;
uridecodebin.attach(gst_parse_launch(filename, err.getRef()));
if (err)
if (!uridecodebin)
{
CV_WARN("Error opening bin: " << err->message);
CV_WARN("Error opening bin: " << (err ? err->message : "<unknown reason>"));
return false;
}
manualpipeline = true;
......@@ -1979,7 +1979,7 @@ void handleMessage(GstElement * pipeline)
gst_message_parse_error(msg, err.getRef(), debug.getRef());
GSafePtr<gchar> name; name.attach(gst_element_get_name(GST_MESSAGE_SRC (msg)));
CV_WARN("Embedded video playback halted; module " << name.get() <<
" reported: " << err->message);
" reported: " << (err ? err->message : "<unknown reason>"));
CV_LOG_DEBUG(NULL, "GStreamer debug: " << debug.get());
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册