video/video-info: Don't use bool return of gst_video_info_set_format()/align() when running with GStreamer < 1.11.1

The bool return value was added in 1.11.1 and using the return value
with older versions gives a random value that might be true or false,
and then causes spurious errors.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/236#note_399872
This commit is contained in:
Sebastian Dröge 2020-02-14 13:12:41 +01:00
parent 2f88dc6576
commit a2a1a87c46

View file

@ -267,7 +267,38 @@ impl<'a> VideoInfoBuilder<'a> {
unsafe {
let mut info = mem::MaybeUninit::uninit();
#[cfg(not(feature = "v1_16"))]
#[cfg(not(feature = "v1_12"))]
let res: bool = {
// The bool return value is new with 1.11.1, see
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/commit/17cdd369e6f2f73329d27dfceb50011f40f1ceb0
let res = if gst::version() < (1, 11, 1, 0) {
gst_video_sys::gst_video_info_set_format(
info.as_mut_ptr(),
self.format.to_glib(),
self.width,
self.height,
);
true
} else {
from_glib(gst_video_sys::gst_video_info_set_format(
info.as_mut_ptr(),
self.format.to_glib(),
self.width,
self.height,
))
};
if res {
if let Some(interlace_mode) = self.interlace_mode {
let info = info.as_mut_ptr();
(*info).interlace_mode = interlace_mode.to_glib();
}
}
res
};
#[cfg(all(feature = "v1_12", not(feature = "v1_16")))]
let res: bool = {
let res = from_glib(gst_video_sys::gst_video_info_set_format(
info.as_mut_ptr(),
@ -710,8 +741,23 @@ impl VideoInfo {
}
}
#[cfg(any(feature = "v1_12", feature = "dox"))]
pub fn align(&mut self, align: &mut ::VideoAlignment) -> bool {
#[cfg(not(feature = "v1_12"))]
unsafe {
// The bool return value is new with 1.11.1, see
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/commit/17cdd369e6f2f73329d27dfceb50011f40f1ceb0
if gst::version() < (1, 11, 1, 0) {
gst_video_sys::gst_video_info_align(&mut self.0, &mut align.0);
true
} else {
from_glib(gst_video_sys::gst_video_info_align(
&mut self.0,
&mut align.0,
))
}
}
#[cfg(feature = "v1_12")]
unsafe {
from_glib(gst_video_sys::gst_video_info_align(
&mut self.0,