From 8d30bcbf4b9e0b73573e431434a51356b83fdbe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 4 Jan 2023 18:11:27 +0200 Subject: [PATCH] Use `IntoGlibPtr` trait instead of `to_glib_full()` where appropriate to reduce unnecessary refcounting/copying Part-of: --- examples/src/bin/encodebin.rs | 4 ++-- examples/src/bin/ges.rs | 4 ++-- gstreamer-audio/src/subclass/audio_decoder.rs | 2 +- gstreamer-audio/src/subclass/audio_encoder.rs | 2 +- gstreamer-base/src/subclass/aggregator.rs | 5 ++-- gstreamer-net/src/net_address_meta.rs | 4 ++-- gstreamer-pbutils/src/encoding_profile.rs | 24 +++++++++---------- .../src/subclass/rtp_base_payload.rs | 2 +- gstreamer-rtsp-server/src/rtsp_media.rs | 6 ++--- .../src/subclass/rtsp_client.rs | 4 ++-- .../src/subclass/rtsp_media.rs | 2 +- .../src/subclass/rtsp_media_factory.rs | 11 +++++---- .../src/subclass/rtsp_mount_points.rs | 2 +- .../src/subclass/rtsp_server.rs | 2 +- gstreamer-video/src/subclass/video_decoder.rs | 2 +- gstreamer-video/src/subclass/video_encoder.rs | 2 +- gstreamer-video/src/video_event.rs | 15 +++++------- gstreamer-video/src/video_time_code.rs | 4 ++-- gstreamer/src/allocator.rs | 11 +++++---- gstreamer/src/lib.rs | 3 ++- gstreamer/src/memory.rs | 2 +- gstreamer/src/stream_collection.rs | 13 ++++++---- gstreamer/src/subclass/allocator.rs | 2 +- gstreamer/src/subclass/child_proxy.rs | 4 ++-- gstreamer/src/subclass/device.rs | 9 +++---- gstreamer/src/subclass/element.rs | 2 +- 26 files changed, 73 insertions(+), 70 deletions(-) diff --git a/examples/src/bin/encodebin.rs b/examples/src/bin/encodebin.rs index a9b71d07e..de71c4dbe 100644 --- a/examples/src/bin/encodebin.rs +++ b/examples/src/bin/encodebin.rs @@ -61,8 +61,8 @@ fn configure_encodebin(encodebin: &gst::Element) { &gst::Caps::builder("video/x-matroska").build(), ) .name("container") - .add_profile(&(video_profile)) - .add_profile(&(audio_profile)) + .add_profile(video_profile) + .add_profile(audio_profile) .build(); // Finally, apply the EncodingProfile onto our encodebin element. diff --git a/examples/src/bin/ges.rs b/examples/src/bin/ges.rs index 6aaac517c..90bc10e1a 100644 --- a/examples/src/bin/ges.rs +++ b/examples/src/bin/ges.rs @@ -58,8 +58,8 @@ fn configure_pipeline(pipeline: &ges::Pipeline, output_name: &str) { let container_profile = gst_pbutils::EncodingContainerProfile::builder(&gst::Caps::builder("video/webm").build()) .name("container") - .add_profile(&video_profile) - .add_profile(&audio_profile) + .add_profile(video_profile) + .add_profile(audio_profile) .build(); // Apply the EncodingProfile to the pipeline, and set it to render mode diff --git a/gstreamer-audio/src/subclass/audio_decoder.rs b/gstreamer-audio/src/subclass/audio_decoder.rs index f464e0bc2..cd9b9caa8 100644 --- a/gstreamer-audio/src/subclass/audio_decoder.rs +++ b/gstreamer-audio/src/subclass/audio_decoder.rs @@ -736,7 +736,7 @@ unsafe extern "C" fn audio_decoder_getcaps( .as_ref(), ) }) - .to_glib_full() + .into_glib_ptr() } unsafe extern "C" fn audio_decoder_sink_event( diff --git a/gstreamer-audio/src/subclass/audio_encoder.rs b/gstreamer-audio/src/subclass/audio_encoder.rs index 3a6bb47fb..ffd7992d6 100644 --- a/gstreamer-audio/src/subclass/audio_encoder.rs +++ b/gstreamer-audio/src/subclass/audio_encoder.rs @@ -669,7 +669,7 @@ unsafe extern "C" fn audio_encoder_getcaps( .as_ref(), ) }) - .to_glib_full() + .into_glib_ptr() } unsafe extern "C" fn audio_encoder_sink_event( diff --git a/gstreamer-base/src/subclass/aggregator.rs b/gstreamer-base/src/subclass/aggregator.rs index db29a543b..b3e38472b 100644 --- a/gstreamer-base/src/subclass/aggregator.rs +++ b/gstreamer-base/src/subclass/aggregator.rs @@ -941,7 +941,7 @@ unsafe extern "C" fn aggregator_create_new_pad( .as_ref(), ) }) - .to_glib_full() + .into_glib_ptr() } unsafe extern "C" fn aggregator_update_src_caps( @@ -1074,5 +1074,6 @@ unsafe extern "C" fn aggregator_peek_next_sample( let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); - gst::panic_to_error!(imp, None, { imp.peek_next_sample(&from_glib_borrow(pad)) }).to_glib_full() + gst::panic_to_error!(imp, None, { imp.peek_next_sample(&from_glib_borrow(pad)) }) + .into_glib_ptr() } diff --git a/gstreamer-net/src/net_address_meta.rs b/gstreamer-net/src/net_address_meta.rs index 945de97e9..61abab38d 100644 --- a/gstreamer-net/src/net_address_meta.rs +++ b/gstreamer-net/src/net_address_meta.rs @@ -33,11 +33,11 @@ impl NetAddressMeta { unsafe { from_glib_none(self.0.addr) } } - pub fn set_addr>(&mut self, addr: &T) { + pub fn set_addr(&mut self, addr: impl IsA) { #![allow(clippy::cast_ptr_alignment)] unsafe { glib::gobject_ffi::g_object_unref(self.0.addr as *mut _); - self.0.addr = addr.as_ref().to_glib_full(); + self.0.addr = addr.upcast().into_glib_ptr(); } } } diff --git a/gstreamer-pbutils/src/encoding_profile.rs b/gstreamer-pbutils/src/encoding_profile.rs index 64c7017da..bc1b98784 100644 --- a/gstreamer-pbutils/src/encoding_profile.rs +++ b/gstreamer-pbutils/src/encoding_profile.rs @@ -154,7 +154,7 @@ impl> EncodingProfileBuilderCommon for O { // Split the trait as only the getter is public trait EncodingProfileHasRestrictionSetter { - fn set_restriction(&self, restriction: Option<&gst::Caps>); + fn set_restriction(&self, restriction: Option); } pub trait EncodingProfileHasRestrictionGetter { @@ -167,12 +167,12 @@ macro_rules! declare_encoding_profile_has_restriction( ($name:ident) => { impl EncodingProfileHasRestrictionSetter for $name { // checker-ignore-item - fn set_restriction(&self, restriction: Option<&gst::Caps>) { + fn set_restriction(&self, restriction: Option) { let profile: &EncodingProfile = glib::object::Cast::upcast_ref(self); unsafe { let restriction = match restriction { - Some(restriction) => restriction.to_glib_full(), + Some(restriction) => restriction.into_glib_ptr(), None => gst::ffi::gst_caps_new_any(), }; @@ -305,11 +305,11 @@ impl EncodingContainerProfile { } // checker-ignore-item - fn add_profile>(&self, profile: &P) { + fn add_profile(&self, profile: impl IsA) { unsafe { let res = ffi::gst_encoding_container_profile_add_profile( self.to_glib_none().0, - profile.as_ref().to_glib_full(), + profile.upcast().into_glib_ptr(), ); // Can't possibly fail unless we pass random pointers assert_ne!(res, glib::ffi::GFALSE); @@ -588,7 +588,7 @@ impl<'a> EncodingContainerProfileBuilder<'a> { ); for profile in self.profiles { - container_profile.add_profile(&profile); + container_profile.add_profile(profile); } set_common_fields(&container_profile, self.base); @@ -597,8 +597,8 @@ impl<'a> EncodingContainerProfileBuilder<'a> { } #[doc(alias = "gst_encoding_container_profile_add_profile")] - pub fn add_profile>(mut self, profile: &P) -> Self { - self.profiles.push(profile.as_ref().clone()); + pub fn add_profile(mut self, profile: impl IsA) -> Self { + self.profiles.push(profile.upcast()); self } } @@ -666,7 +666,7 @@ mod tests { let restriction = gst_audio::AudioCapsBuilder::new() .format(gst_audio::AudioFormat::S32be) .build(); - audio_profile.set_restriction(Some(&restriction)); + audio_profile.set_restriction(Some(restriction.clone())); assert_eq!(audio_profile.restriction().unwrap(), restriction); } @@ -714,7 +714,7 @@ mod tests { let restriction = gst_video::VideoCapsBuilder::new() .format(gst_video::VideoFormat::Nv12) .build(); - video_profile.set_restriction(Some(&restriction)); + video_profile.set_restriction(Some(restriction.clone())); assert_eq!(video_profile.restriction().unwrap(), restriction); } @@ -743,8 +743,8 @@ mod tests { .presence(PRESENCE) .allow_dynamic_output(ALLOW_DYNAMIC_OUTPUT) .enabled(ENABLED) - .add_profile(&audio_profile) - .add_profile(&video_profile) + .add_profile(audio_profile.clone()) + .add_profile(video_profile.clone()) .build(); assert_eq!(profile.name().unwrap(), CONTAINER_PROFILE_NAME); diff --git a/gstreamer-rtp/src/subclass/rtp_base_payload.rs b/gstreamer-rtp/src/subclass/rtp_base_payload.rs index f79dfd912..5a6ac07ef 100644 --- a/gstreamer-rtp/src/subclass/rtp_base_payload.rs +++ b/gstreamer-rtp/src/subclass/rtp_base_payload.rs @@ -205,7 +205,7 @@ unsafe extern "C" fn rtp_base_payload_get_caps( .as_ref(), ) }) - .to_glib_full() + .into_glib_ptr() } unsafe extern "C" fn rtp_base_payload_set_caps( diff --git a/gstreamer-rtsp-server/src/rtsp_media.rs b/gstreamer-rtsp-server/src/rtsp_media.rs index 4018b7800..65c26890e 100644 --- a/gstreamer-rtsp-server/src/rtsp_media.rs +++ b/gstreamer-rtsp-server/src/rtsp_media.rs @@ -6,13 +6,13 @@ use crate::RTSPMedia; pub trait RTSPMediaExtManual: 'static { #[doc(alias = "gst_rtsp_media_take_pipeline")] - fn take_pipeline>(&self, pipeline: &P); + fn take_pipeline(&self, pipeline: impl IsA); } impl> RTSPMediaExtManual for O { - fn take_pipeline>(&self, pipeline: &P) { + fn take_pipeline(&self, pipeline: impl IsA) { unsafe { - let pipeline = pipeline.as_ref().to_glib_full(); + let pipeline = pipeline.upcast().into_glib_ptr(); // See https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/merge_requests/109 glib::gobject_ffi::g_object_force_floating(pipeline as *mut _); ffi::gst_rtsp_media_take_pipeline(self.as_ref().to_glib_none().0, pipeline); diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_client.rs b/gstreamer-rtsp-server/src/subclass/rtsp_client.rs index d99752630..126bd9582 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_client.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_client.rs @@ -839,7 +839,7 @@ unsafe extern "C" fn client_make_path_from_uri( let imp = instance.imp(); imp.make_path_from_uri(&from_glib_borrow(url)) - .to_glib_full() + .into_glib_ptr() } unsafe extern "C" fn client_closed(ptr: *mut ffi::GstRTSPClient) { @@ -1000,7 +1000,7 @@ unsafe extern "C" fn client_check_requirements( let imp = instance.imp(); imp.check_requirements(&from_glib_borrow(ctx), Vec::from_glib_none(arr).as_slice()) - .to_glib_full() + .into_glib_ptr() } unsafe extern "C" fn client_pre_options_request( diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_media.rs b/gstreamer-rtsp-server/src/subclass/rtsp_media.rs index f259ca78f..132931996 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_media.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_media.rs @@ -553,7 +553,7 @@ unsafe extern "C" fn media_create_rtpbin( let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); - let res: *mut gst::ffi::GstElement = imp.create_rtpbin().to_glib_full(); + let res: *mut gst::ffi::GstElement = imp.create_rtpbin().into_glib_ptr(); if !res.is_null() { glib::gobject_ffi::g_object_force_floating(res as *mut _); diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs b/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs index 1c06dbce4..bc2ae465b 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs @@ -203,7 +203,7 @@ unsafe extern "C" fn factory_gen_key( let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); - imp.gen_key(&from_glib_borrow(url)).to_glib_full() + imp.gen_key(&from_glib_borrow(url)).into_glib_ptr() } unsafe extern "C" fn factory_create_element( @@ -213,7 +213,7 @@ unsafe extern "C" fn factory_create_element( let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); - let element = imp.create_element(&from_glib_borrow(url)).to_glib_full(); + let element = imp.create_element(&from_glib_borrow(url)).into_glib_ptr(); glib::gobject_ffi::g_object_force_floating(element as *mut _); element } @@ -225,7 +225,7 @@ unsafe extern "C" fn factory_construct( let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); - imp.construct(&from_glib_borrow(url)).to_glib_full() + imp.construct(&from_glib_borrow(url)).into_glib_ptr() } unsafe extern "C" fn factory_create_pipeline( @@ -240,8 +240,9 @@ unsafe extern "C" fn factory_create_pipeline( let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); - let pipeline: *mut gst::ffi::GstPipeline = - imp.create_pipeline(&from_glib_borrow(media)).to_glib_full(); + let pipeline: *mut gst::ffi::GstPipeline = imp + .create_pipeline(&from_glib_borrow(media)) + .into_glib_ptr(); // FIXME We somehow need to ensure the pipeline actually stays alive... glib::gobject_ffi::g_object_set_qdata_full( diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_mount_points.rs b/gstreamer-rtsp-server/src/subclass/rtsp_mount_points.rs index 6ef069b71..75e1fb59f 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_mount_points.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_mount_points.rs @@ -49,5 +49,5 @@ unsafe extern "C" fn mount_points_make_path( let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); - imp.make_path(&from_glib_borrow(url)).to_glib_full() + imp.make_path(&from_glib_borrow(url)).into_glib_ptr() } diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_server.rs b/gstreamer-rtsp-server/src/subclass/rtsp_server.rs index ca365b682..2e33d2c9d 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_server.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_server.rs @@ -64,7 +64,7 @@ unsafe extern "C" fn server_create_client( let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); - imp.create_client().to_glib_full() + imp.create_client().into_glib_ptr() } unsafe extern "C" fn server_client_connected( diff --git a/gstreamer-video/src/subclass/video_decoder.rs b/gstreamer-video/src/subclass/video_decoder.rs index 5cf30a031..2935d3801 100644 --- a/gstreamer-video/src/subclass/video_decoder.rs +++ b/gstreamer-video/src/subclass/video_decoder.rs @@ -806,7 +806,7 @@ unsafe extern "C" fn video_decoder_getcaps( .as_ref(), ) }) - .to_glib_full() + .into_glib_ptr() } unsafe extern "C" fn video_decoder_sink_event( diff --git a/gstreamer-video/src/subclass/video_encoder.rs b/gstreamer-video/src/subclass/video_encoder.rs index 9a2d87851..8c3c240a0 100644 --- a/gstreamer-video/src/subclass/video_encoder.rs +++ b/gstreamer-video/src/subclass/video_encoder.rs @@ -661,7 +661,7 @@ unsafe extern "C" fn video_encoder_getcaps( .as_ref(), ) }) - .to_glib_full() + .into_glib_ptr() } unsafe extern "C" fn video_encoder_sink_event( diff --git a/gstreamer-video/src/video_event.rs b/gstreamer-video/src/video_event.rs index f0982cfe6..f44134b92 100644 --- a/gstreamer-video/src/video_event.rs +++ b/gstreamer-video/src/video_event.rs @@ -1,10 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. use std::mem; -use glib::{ - translate::{from_glib, from_glib_full, IntoGlib, ToGlibPtr}, - ToSendValue, -}; +use glib::{translate::*, ToSendValue}; use gst::EventType; #[cfg(any(feature = "v1_22", feature = "dox"))] @@ -426,7 +423,7 @@ nav_event_builder!( modifier_state: s.modifier_state, }, }; - gst::ffi::gst_event_new_navigation(event.structure().to_glib_full()) + gst::ffi::gst_event_new_navigation(event.structure().into_glib_ptr()) } ); @@ -487,7 +484,7 @@ nav_event_builder!( modifier_state: s.modifier_state, }, }; - gst::ffi::gst_event_new_navigation(event.structure().to_glib_full()) + gst::ffi::gst_event_new_navigation(event.structure().into_glib_ptr()) } ); @@ -532,7 +529,7 @@ impl<'a> CommandEventBuilder<'a> { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] modifier_state: s.modifier_state, }; - gst::ffi::gst_event_new_navigation(event.structure().to_glib_full()) + gst::ffi::gst_event_new_navigation(event.structure().into_glib_ptr()) }); } @@ -573,7 +570,7 @@ nav_event_builder!( modifier_state: s.modifier_state, }, }; - gst::ffi::gst_event_new_navigation(event.structure().to_glib_full()) + gst::ffi::gst_event_new_navigation(event.structure().into_glib_ptr()) } ); @@ -599,7 +596,7 @@ nav_event_builder!( modifier_state: s.modifier_state, }, }; - gst::ffi::gst_event_new_navigation(event.structure().to_glib_full()) + gst::ffi::gst_event_new_navigation(event.structure().into_glib_ptr()) } ); diff --git a/gstreamer-video/src/video_time_code.rs b/gstreamer-video/src/video_time_code.rs index 1b5767cfd..0b18c0527 100644 --- a/gstreamer-video/src/video_time_code.rs +++ b/gstreamer-video/src/video_time_code.rs @@ -325,13 +325,13 @@ macro_rules! generic_impl { unsafe { from_glib_none(self.inner.config.latest_daily_jam) } } - pub fn set_latest_daily_jam(&mut self, latest_daily_jam: Option<&glib::DateTime>) { + pub fn set_latest_daily_jam(&mut self, latest_daily_jam: Option) { unsafe { if !self.inner.config.latest_daily_jam.is_null() { glib::ffi::g_date_time_unref(self.inner.config.latest_daily_jam); } - self.inner.config.latest_daily_jam = latest_daily_jam.to_glib_full() + self.inner.config.latest_daily_jam = latest_daily_jam.into_glib_ptr(); } } } diff --git a/gstreamer/src/allocator.rs b/gstreamer/src/allocator.rs index 4f32d95c9..9be7e5eae 100644 --- a/gstreamer/src/allocator.rs +++ b/gstreamer/src/allocator.rs @@ -1,21 +1,24 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::{translate::*, IsA}; +use glib::{translate::*, Cast, IsA}; use crate::Allocator; impl Allocator { #[doc(alias = "gst_allocator_register")] - pub fn register(name: &str, allocator: &impl IsA) { + pub fn register(name: &str, allocator: impl IsA) { skip_assert_initialized!(); unsafe { // See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3364 if crate::version() < (1, 20, 5, 0) { - ffi::gst_allocator_register(name.to_glib_full(), allocator.as_ref().to_glib_full()); + ffi::gst_allocator_register( + name.to_glib_full(), + allocator.upcast().into_glib_ptr(), + ); } else { ffi::gst_allocator_register( name.to_glib_none().0, - allocator.as_ref().to_glib_full(), + allocator.upcast().into_glib_ptr(), ); } } diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 2279bb808..29929e4c9 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -10,7 +10,6 @@ // Re-exported for the subclass gst_plugin_define! macro pub use ffi; pub use glib; -use glib::translate::{from_glib, from_glib_full}; pub use paste; #[doc(hidden)] @@ -256,6 +255,8 @@ use std::ptr; #[doc(alias = "gst_init_check")] pub fn init() -> Result<(), glib::Error> { unsafe { + use glib::translate::*; + let mut error = ptr::null_mut(); if from_glib(ffi::gst_init_check( ptr::null_mut(), diff --git a/gstreamer/src/memory.rs b/gstreamer/src/memory.rs index 6640f8ed7..79dd8f1f4 100644 --- a/gstreamer/src/memory.rs +++ b/gstreamer/src/memory.rs @@ -8,7 +8,7 @@ use std::{ ptr, slice, }; -use glib::translate::{from_glib, from_glib_full, from_glib_none, IntoGlibPtr, ToGlibPtr}; +use glib::translate::*; use crate::{AllocationParams, Allocator, MemoryFlags}; diff --git a/gstreamer/src/stream_collection.rs b/gstreamer/src/stream_collection.rs index d3f20f333..b4ed74eb5 100644 --- a/gstreamer/src/stream_collection.rs +++ b/gstreamer/src/stream_collection.rs @@ -104,20 +104,23 @@ pub struct StreamCollectionBuilder(StreamCollection); impl StreamCollectionBuilder { #[doc(alias = "gst_stream_collection_add_stream")] - pub fn stream(self, stream: &Stream) -> Self { + pub fn stream(self, stream: Stream) -> Self { unsafe { - ffi::gst_stream_collection_add_stream((self.0).to_glib_none().0, stream.to_glib_full()); + ffi::gst_stream_collection_add_stream( + (self.0).to_glib_none().0, + stream.into_glib_ptr(), + ); } self } - pub fn streams(self, streams: &[impl AsRef]) -> Self { - for stream in streams { + pub fn streams(self, streams: impl IntoIterator) -> Self { + for stream in streams.into_iter() { unsafe { ffi::gst_stream_collection_add_stream( (self.0).to_glib_none().0, - stream.as_ref().to_glib_full(), + stream.into_glib_ptr(), ); } } diff --git a/gstreamer/src/subclass/allocator.rs b/gstreamer/src/subclass/allocator.rs index 90f42da0c..361160624 100644 --- a/gstreamer/src/subclass/allocator.rs +++ b/gstreamer/src/subclass/allocator.rs @@ -167,7 +167,7 @@ mod tests { const TEST_ALLOCATOR_NAME: &str = "TestAllocator"; let allocator = TestAllocator::default(); - Allocator::register(TEST_ALLOCATOR_NAME, &allocator); + Allocator::register(TEST_ALLOCATOR_NAME, allocator); let allocator = Allocator::find(Some(TEST_ALLOCATOR_NAME)); diff --git a/gstreamer/src/subclass/child_proxy.rs b/gstreamer/src/subclass/child_proxy.rs index 4f24a85d4..cedcac877 100644 --- a/gstreamer/src/subclass/child_proxy.rs +++ b/gstreamer/src/subclass/child_proxy.rs @@ -132,7 +132,7 @@ unsafe extern "C" fn child_proxy_get_child_by_name( let imp = instance.imp(); imp.child_by_name(&glib::GString::from_glib_borrow(name)) - .to_glib_full() + .into_glib_ptr() } unsafe extern "C" fn child_proxy_get_child_by_index( @@ -142,7 +142,7 @@ unsafe extern "C" fn child_proxy_get_child_by_index( let instance = &*(child_proxy as *mut T::Instance); let imp = instance.imp(); - imp.child_by_index(index).to_glib_full() + imp.child_by_index(index).into_glib_ptr() } unsafe extern "C" fn child_proxy_get_children_count( diff --git a/gstreamer/src/subclass/device.rs b/gstreamer/src/subclass/device.rs index 0574ba19b..3123e9938 100644 --- a/gstreamer/src/subclass/device.rs +++ b/gstreamer/src/subclass/device.rs @@ -97,13 +97,10 @@ unsafe extern "C" fn device_create_element( Ok(element) => { // The reference we're going to return, the initial reference is going to // be dropped here now - let element_ptr = element.to_glib_full(); - drop(element); + let element = element.into_glib_ptr(); // See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/444 - glib::gobject_ffi::g_object_force_floating( - element_ptr as *mut glib::gobject_ffi::GObject, - ); - element_ptr + glib::gobject_ffi::g_object_force_floating(element as *mut glib::gobject_ffi::GObject); + element } Err(err) => { err.log_with_imp(imp); diff --git a/gstreamer/src/subclass/element.rs b/gstreamer/src/subclass/element.rs index b43b64079..db3701699 100644 --- a/gstreamer/src/subclass/element.rs +++ b/gstreamer/src/subclass/element.rs @@ -538,7 +538,7 @@ unsafe extern "C" fn element_provide_clock( let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); - panic_to_error!(imp, None, { imp.provide_clock() }).to_glib_full() + panic_to_error!(imp, None, { imp.provide_clock() }).into_glib_ptr() } unsafe extern "C" fn element_post_message(