From d0bfdda97f5a8f7137e10e5639ed5395d18bd8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 19 Mar 2020 13:22:20 +0200 Subject: [PATCH] examples: Update for new GLib boxed deriving API --- examples/src/bin/decodebin.rs | 15 ++++----------- examples/src/bin/encodebin.rs | 15 ++++----------- gstreamer/src/iterator.rs | 4 ++++ 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/examples/src/bin/decodebin.rs b/examples/src/bin/decodebin.rs index cc6914ec7..b505eb41d 100644 --- a/examples/src/bin/decodebin.rs +++ b/examples/src/bin/decodebin.rs @@ -35,6 +35,8 @@ use gst::prelude::*; #[cfg_attr(feature = "v1_10", macro_use)] extern crate glib; +#[cfg(feature = "v1_10")] +use glib::subclass::prelude::*; use std::env; use std::error::Error as StdError; @@ -68,19 +70,10 @@ struct ErrorMessage { } #[cfg(feature = "v1_10")] -#[derive(Clone, Debug)] +#[derive(Clone, Debug, GBoxed)] +#[gboxed(type_name = "ErrorValue")] struct ErrorValue(Arc>>); -#[cfg(feature = "v1_10")] -impl glib::subclass::boxed::BoxedType for ErrorValue { - const NAME: &'static str = "ErrorValue"; - - glib_boxed_type!(); -} - -#[cfg(feature = "v1_10")] -glib_boxed_derive_traits!(ErrorValue); - fn example_main() -> Result<(), Error> { gst::init()?; diff --git a/examples/src/bin/encodebin.rs b/examples/src/bin/encodebin.rs index a4aff5868..29a209e2e 100644 --- a/examples/src/bin/encodebin.rs +++ b/examples/src/bin/encodebin.rs @@ -21,6 +21,8 @@ use gst_pbutils::prelude::*; #[cfg_attr(feature = "v1_10", macro_use)] extern crate glib; +#[cfg(feature = "v1_10")] +use glib::subclass::prelude::*; use std::env; use std::error::Error as StdError; @@ -54,19 +56,10 @@ struct ErrorMessage { } #[cfg(feature = "v1_10")] -#[derive(Clone, Debug)] +#[derive(Clone, Debug, GBoxed)] +#[gboxed(type_name = "ErrorValue")] struct ErrorValue(Arc>>); -#[cfg(feature = "v1_10")] -impl glib::subclass::boxed::BoxedType for ErrorValue { - const NAME: &'static str = "ErrorValue"; - - glib_boxed_type!(); -} - -#[cfg(feature = "v1_10")] -glib_boxed_derive_traits!(ErrorValue); - fn configure_encodebin(encodebin: &gst::Element) -> Result<(), Error> { // To tell the encodebin what we want it to produce, we create an EncodingProfile // https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/GstEncodingProfile.html diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index aabf952e7..99ce2aa66 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -55,6 +55,8 @@ where let mut value = Value::uninitialized(); let res = gst_sys::gst_iterator_next(self.to_glib_none_mut().0, value.to_glib_none_mut().0); + + #[allow(clippy::wildcard_in_or_patterns)] match res { gst_sys::GST_ITERATOR_OK => match value.get::().expect("Iterator::next") { Some(value) => Ok(Some(value)), @@ -131,6 +133,7 @@ where func_ptr, ); + #[allow(clippy::wildcard_in_or_patterns)] match res { gst_sys::GST_ITERATOR_OK | gst_sys::GST_ITERATOR_DONE => Ok(()), gst_sys::GST_ITERATOR_RESYNC => Err(IteratorError::Resync), @@ -161,6 +164,7 @@ where func_ptr, ); + #[allow(clippy::wildcard_in_or_patterns)] match res { gst_sys::GST_ITERATOR_OK | gst_sys::GST_ITERATOR_DONE => Ok(accum.unwrap()), gst_sys::GST_ITERATOR_RESYNC => Err(IteratorError::Resync),