Fix Player constructor on GStreamer 1.12 if a video renderer or signal dispatcher are given

This commit is contained in:
Sebastian Dröge 2017-09-10 15:20:58 +03:00
parent b4cb81cd56
commit 150527f779

View file

@ -19,17 +19,16 @@ impl Player {
signal_dispatcher: Option<&PlayerSignalDispatcher>,
) -> Player {
assert_initialized_main_thread!();
let video_renderer = video_renderer.to_glib_full();
let signal_dispatcher = signal_dispatcher.to_glib_full();
let (major, minor, _, _) = gst::version();
if (major, minor) > (1, 12) {
let video_renderer = video_renderer.to_glib_full();
let signal_dispatcher = signal_dispatcher.to_glib_full();
unsafe { from_glib_full(ffi::gst_player_new(video_renderer, signal_dispatcher)) }
} else {
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13 in
// https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/gst-libs/gst/player/gstplayer.c?id=634cd87c76f58b5e1383715bafd5614db825c7d1
let video_renderer = video_renderer.to_glib_none();
let signal_dispatcher = signal_dispatcher.to_glib_none();
unsafe { from_glib_none(ffi::gst_player_new(video_renderer.0, signal_dispatcher.0)) }
unsafe { from_glib_none(ffi::gst_player_new(video_renderer, signal_dispatcher)) }
}
}