From 37bfb78fdce51c967fb6f88ecae3240cbcbbf306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 25 Dec 2022 12:47:02 +0200 Subject: [PATCH] Change some assertions to debug assertions These assertions can only trigger because of bugs in the bindings implementation or in the C code and not because of bugs in calling code, so using debug assertions is perfectly fine for them and reduces the number of assertions inlined everywhere in release builds. Part-of: --- gstreamer-allocators/src/dma_buf_allocator.rs | 6 +-- gstreamer-allocators/src/fd_allocator.rs | 4 +- gstreamer-allocators/src/phys_memory.rs | 2 +- gstreamer-audio/src/audio_buffer.rs | 4 +- gstreamer-audio/src/audio_channel_position.rs | 2 +- gstreamer-audio/src/audio_format_info.rs | 4 +- gstreamer-audio/src/functions.rs | 2 +- gstreamer-base/src/base_parse_frame.rs | 11 ++--- gstreamer-base/src/functions.rs | 10 ++--- gstreamer-check/src/harness.rs | 4 +- gstreamer-check/src/lib.rs | 4 ++ gstreamer-gl/src/functions.rs | 4 +- gstreamer-net/src/ptp_clock.rs | 2 +- gstreamer-pbutils/src/element_properties.rs | 2 +- gstreamer-pbutils/src/encoding_profile.rs | 2 +- gstreamer-play/src/config.rs | 12 ++--- .../src/play_video_overlay_video_renderer.rs | 4 +- gstreamer-player/src/config.rs | 12 ++--- .../player_video_overlay_video_renderer.rs | 4 +- gstreamer-rtp/src/rtp_buffer.rs | 2 +- gstreamer-rtsp-server/src/rtsp_context.rs | 2 +- gstreamer-rtsp-server/src/rtsp_token.rs | 2 +- gstreamer-sdp/src/sdp_bandwidth.rs | 2 +- gstreamer-sdp/src/sdp_connection.rs | 2 +- gstreamer-sdp/src/sdp_media.rs | 8 ++-- gstreamer-sdp/src/sdp_message.rs | 10 +++-- gstreamer-sdp/src/sdp_time.rs | 2 +- gstreamer-sdp/src/sdp_zone.rs | 2 +- gstreamer-video/src/enums.rs | 4 +- gstreamer-video/src/functions.rs | 2 +- gstreamer-video/src/video_buffer_pool.rs | 2 +- gstreamer-video/src/video_codec_frame.rs | 11 ++--- gstreamer-video/src/video_converter.rs | 2 +- gstreamer-video/src/video_event.rs | 10 +++-- gstreamer-video/src/video_format_info.rs | 6 +-- gstreamer-video/src/video_frame.rs | 4 +- gstreamer-video/src/video_hdr.rs | 4 +- gstreamer-video/src/video_info.rs | 2 +- gstreamer-video/src/video_message.rs | 14 +++--- .../src/video_overlay_composition.rs | 2 +- gstreamer-video/src/video_time_code.rs | 3 +- gstreamer-webrtc/src/lib.rs | 8 ---- .../src/web_rtc_session_description.rs | 2 +- gstreamer/src/allocation_params.rs | 2 +- gstreamer/src/buffer.rs | 4 +- gstreamer/src/buffer_cursor.rs | 6 +-- gstreamer/src/buffer_pool.rs | 4 +- gstreamer/src/caps.rs | 18 +++----- gstreamer/src/caps_features.rs | 41 ++++++++--------- gstreamer/src/clock.rs | 1 - gstreamer/src/device_monitor.rs | 2 +- gstreamer/src/device_provider.rs | 2 +- gstreamer/src/element.rs | 4 +- gstreamer/src/element_factory.rs | 10 ++--- gstreamer/src/error.rs | 4 +- gstreamer/src/event.rs | 5 +-- gstreamer/src/functions.rs | 6 +-- gstreamer/src/iterator.rs | 12 ++--- gstreamer/src/log.rs | 4 +- gstreamer/src/memory.rs | 2 +- gstreamer/src/message.rs | 1 - gstreamer/src/meta.rs | 10 ++--- gstreamer/src/miniobject.rs | 18 ++++---- gstreamer/src/pad.rs | 10 ++--- gstreamer/src/pad_template.rs | 4 +- gstreamer/src/param_spec.rs | 4 +- gstreamer/src/query.rs | 10 ++--- gstreamer/src/sample.rs | 4 +- gstreamer/src/segment.rs | 1 - gstreamer/src/static_caps.rs | 6 +-- gstreamer/src/static_pad_template.rs | 6 +-- gstreamer/src/structure.rs | 30 ++++++------- gstreamer/src/tags.rs | 2 +- gstreamer/src/task_pool.rs | 2 +- gstreamer/src/tracer.rs | 2 +- gstreamer/src/typefind.rs | 2 +- gstreamer/src/value.rs | 44 +++++++++---------- 77 files changed, 229 insertions(+), 257 deletions(-) diff --git a/gstreamer-allocators/src/dma_buf_allocator.rs b/gstreamer-allocators/src/dma_buf_allocator.rs index 9333c5ad9..b6b347724 100644 --- a/gstreamer-allocators/src/dma_buf_allocator.rs +++ b/gstreamer-allocators/src/dma_buf_allocator.rs @@ -37,7 +37,7 @@ impl fmt::Debug for DmaBufMemoryRef { impl DmaBufMemoryRef { #[doc(alias = "gst_dmabuf_memory_get_fd")] pub fn fd(&self) -> RawFd { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { ffi::gst_dmabuf_memory_get_fd(self.as_mut_ptr()) } } } @@ -49,7 +49,7 @@ impl DmaBufAllocator { fd: A, size: usize, ) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Option::<_>::from_glib_full(ffi::gst_dmabuf_allocator_alloc( self.unsafe_cast_ref::().to_glib_none().0, fd.into_raw_fd(), @@ -67,7 +67,7 @@ impl DmaBufAllocator { size: usize, flags: FdMemoryFlags, ) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Option::<_>::from_glib_full(ffi::gst_dmabuf_allocator_alloc_with_flags( self.unsafe_cast_ref::().to_glib_none().0, fd, diff --git a/gstreamer-allocators/src/fd_allocator.rs b/gstreamer-allocators/src/fd_allocator.rs index be6679ec6..0169695e2 100644 --- a/gstreamer-allocators/src/fd_allocator.rs +++ b/gstreamer-allocators/src/fd_allocator.rs @@ -39,7 +39,7 @@ impl fmt::Debug for FdMemoryRef { impl FdMemoryRef { #[doc(alias = "gst_fd_memory_get_fd")] pub fn fd(&self) -> RawFd { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { ffi::gst_fd_memory_get_fd(self.as_mut_ptr()) } } } @@ -52,7 +52,7 @@ impl FdAllocator { size: usize, flags: FdMemoryFlags, ) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Option::<_>::from_glib_full(ffi::gst_fd_allocator_alloc( self.unsafe_cast_ref::().to_glib_none().0, fd, diff --git a/gstreamer-allocators/src/phys_memory.rs b/gstreamer-allocators/src/phys_memory.rs index cd277ecbc..1a82dc4be 100644 --- a/gstreamer-allocators/src/phys_memory.rs +++ b/gstreamer-allocators/src/phys_memory.rs @@ -37,7 +37,7 @@ impl fmt::Debug for PhysMemoryRef { impl PhysMemoryRef { #[doc(alias = "gst_phys_memory_get_phys_addr")] pub fn phys_addr(&self) -> libc::uintptr_t { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { ffi::gst_phys_memory_get_phys_addr(self.as_mut_ptr()) } } } diff --git a/gstreamer-audio/src/audio_buffer.rs b/gstreamer-audio/src/audio_buffer.rs index 6173c9244..ae907147f 100644 --- a/gstreamer-audio/src/audio_buffer.rs +++ b/gstreamer-audio/src/audio_buffer.rs @@ -397,7 +397,7 @@ impl AudioBufferRef { impl<'a> AudioBufferRef<&'a gst::BufferRef> { #[inline] pub unsafe fn from_glib_borrow(audio_buffer: *const ffi::GstAudioBuffer) -> Borrowed { - assert!(!audio_buffer.is_null()); + debug_assert!(!audio_buffer.is_null()); let info = crate::AudioInfo::from_glib_none( &(*audio_buffer).info as *const _ as *mut ffi::GstAudioInfo, @@ -455,7 +455,7 @@ impl<'a> AudioBufferRef<&'a gst::BufferRef> { impl<'a> AudioBufferRef<&'a mut gst::BufferRef> { #[inline] pub unsafe fn from_glib_borrow_mut(audio_buffer: *mut ffi::GstAudioBuffer) -> Borrowed { - assert!(!audio_buffer.is_null()); + debug_assert!(!audio_buffer.is_null()); let info = crate::AudioInfo::from_glib_none( &(*audio_buffer).info as *const _ as *mut ffi::GstAudioInfo, diff --git a/gstreamer-audio/src/audio_channel_position.rs b/gstreamer-audio/src/audio_channel_position.rs index 7ac019db9..8bac50dc0 100644 --- a/gstreamer-audio/src/audio_channel_position.rs +++ b/gstreamer-audio/src/audio_channel_position.rs @@ -164,7 +164,7 @@ pub fn buffer_reorder_channels( from: &[AudioChannelPosition], to: &[AudioChannelPosition], ) -> Result<(), glib::BoolError> { - assert_initialized_main_thread!(); + skip_assert_initialized!(); if from.len() != to.len() || from.len() > 64 { return Err(glib::bool_error!("Invalid number of channels")); diff --git a/gstreamer-audio/src/audio_format_info.rs b/gstreamer-audio/src/audio_format_info.rs index 2fa07624f..99a591042 100644 --- a/gstreamer-audio/src/audio_format_info.rs +++ b/gstreamer-audio/src/audio_format_info.rs @@ -18,7 +18,7 @@ impl FromGlib for AudioEndianness { #[allow(unused_unsafe)] #[inline] unsafe fn from_glib(value: i32) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); match value { 1234 => Self::LittleEndian, @@ -52,7 +52,7 @@ impl AudioFormatInfo { unsafe { let info = ffi::gst_audio_format_get_info(format.into_glib()); - assert!(!info.is_null()); + debug_assert!(!info.is_null()); Self(&*info) } diff --git a/gstreamer-audio/src/functions.rs b/gstreamer-audio/src/functions.rs index bcd5b90c8..a90fe4ce7 100644 --- a/gstreamer-audio/src/functions.rs +++ b/gstreamer-audio/src/functions.rs @@ -48,7 +48,7 @@ pub fn audio_make_raw_caps( formats: &[crate::AudioFormat], layout: crate::AudioLayout, ) -> crate::AudioCapsBuilder { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let formats = formats.iter().copied().map(|f| match f { crate::AudioFormat::Encoded => panic!("Invalid encoded format"), diff --git a/gstreamer-base/src/base_parse_frame.rs b/gstreamer-base/src/base_parse_frame.rs index b5f093cb8..a8c1aefbe 100644 --- a/gstreamer-base/src/base_parse_frame.rs +++ b/gstreamer-base/src/base_parse_frame.rs @@ -80,7 +80,7 @@ impl<'a> BaseParseFrame<'a> { #[inline] pub(crate) unsafe fn new(frame: *mut ffi::GstBaseParseFrame, _parse: &'a BaseParse) -> Self { skip_assert_initialized!(); - assert!(!frame.is_null()); + debug_assert!(!frame.is_null()); Self(ptr::NonNull::new_unchecked(frame), PhantomData) } @@ -146,19 +146,14 @@ impl<'a> BaseParseFrame<'a> { pub fn set_output_buffer(&mut self, output_buffer: gst::Buffer) { unsafe { + assert!(output_buffer.is_writable()); let prev = (*self.to_glib_none().0).out_buffer; if !prev.is_null() { gst::ffi::gst_mini_object_unref(prev as *mut gst::ffi::GstMiniObject); } - let ptr = output_buffer.into_glib_ptr(); - let writable: bool = from_glib(gst::ffi::gst_mini_object_is_writable( - ptr as *const gst::ffi::GstMiniObject, - )); - assert!(writable); - - (*self.to_glib_none().0).out_buffer = ptr; + (*self.to_glib_none().0).out_buffer = output_buffer.into_glib_ptr(); } } diff --git a/gstreamer-base/src/functions.rs b/gstreamer-base/src/functions.rs index 639c8008a..d8fca5a26 100644 --- a/gstreamer-base/src/functions.rs +++ b/gstreamer-base/src/functions.rs @@ -61,7 +61,7 @@ pub fn type_find_helper_for_buffer>( obj: Option<&P>, buf: &gst::BufferRef, ) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let mut prob = mem::MaybeUninit::uninit(); let ret = ffi::gst_type_find_helper_for_buffer( @@ -85,7 +85,7 @@ pub fn type_find_helper_for_buffer_with_extension>( buf: &gst::BufferRef, extension: Option<&str>, ) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let mut prob = mem::MaybeUninit::uninit(); let ret = ffi::gst_type_find_helper_for_buffer_with_extension( @@ -110,7 +110,7 @@ pub fn type_find_helper_for_buffer_with_caps( buf: &gst::BufferRef, caps: &gst::CapsRef, ) -> (Option, gst::TypeFindProbability) { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let mut prob = mem::MaybeUninit::uninit(); let ret = from_glib_full(ffi::gst_type_find_helper_for_buffer_with_caps( @@ -131,7 +131,7 @@ pub fn type_find_helper_for_data_with_caps( data: &[u8], caps: &gst::CapsRef, ) -> (Option, gst::TypeFindProbability) { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let size = data.len() as _; unsafe { let mut prob = mem::MaybeUninit::uninit(); @@ -153,7 +153,7 @@ pub fn type_find_list_factories_for_caps( obj: Option<&impl IsA>, caps: &gst::CapsRef, ) -> glib::List { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { glib::collections::List::from_glib_full(ffi::gst_type_find_list_factories_for_caps( obj.map(|p| p.as_ref()).to_glib_none().0, diff --git a/gstreamer-check/src/harness.rs b/gstreamer-check/src/harness.rs index a57ccf08b..3b2f5a33a 100644 --- a/gstreamer-check/src/harness.rs +++ b/gstreamer-check/src/harness.rs @@ -595,7 +595,7 @@ impl Harness { #[inline] unsafe fn from_glib_full(ptr: *mut ffi::GstHarness) -> Harness { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); Harness(ptr::NonNull::new_unchecked(ptr)) } @@ -646,7 +646,7 @@ impl Harness { element_sinkpad_name: Option<&str>, element_srcpad_name: Option<&str>, ) -> Harness { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let element_sinkpad_name = element_sinkpad_name.to_glib_none(); let element_srcpad_name = element_srcpad_name.to_glib_none(); unsafe { diff --git a/gstreamer-check/src/lib.rs b/gstreamer-check/src/lib.rs index 8367ae794..e7a9a491c 100644 --- a/gstreamer-check/src/lib.rs +++ b/gstreamer-check/src/lib.rs @@ -17,6 +17,10 @@ macro_rules! assert_initialized_main_thread { }; } +macro_rules! skip_assert_initialized { + () => {}; +} + #[allow(clippy::unreadable_literal)] #[allow(clippy::too_many_arguments)] #[allow(clippy::match_same_arms)] diff --git a/gstreamer-gl/src/functions.rs b/gstreamer-gl/src/functions.rs index 6e95a5314..c706b6b8b 100644 --- a/gstreamer-gl/src/functions.rs +++ b/gstreamer-gl/src/functions.rs @@ -12,7 +12,7 @@ pub fn gl_handle_context_query( context: Option<&impl IsA>, other_context: Option<&impl IsA>, ) -> bool { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { from_glib(ffi::gst_gl_handle_context_query( element.as_ref().to_glib_none().0, @@ -29,7 +29,7 @@ pub fn gl_handle_set_context( element: &impl IsA, context: &gst::Context, ) -> (Option, Option) { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let mut display = ptr::null_mut(); let mut other_context = ptr::null_mut(); diff --git a/gstreamer-net/src/ptp_clock.rs b/gstreamer-net/src/ptp_clock.rs index 68aa96781..61ef7246a 100644 --- a/gstreamer-net/src/ptp_clock.rs +++ b/gstreamer-net/src/ptp_clock.rs @@ -87,7 +87,7 @@ impl PtpClock { Box::into_raw(user_data) as glib::ffi::gpointer, Some(destroy::), ); - assert_ne!(id, 0); + debug_assert_ne!(id, 0); PtpStatisticsCallback(NonZeroU64::new_unchecked(id as _)) } diff --git a/gstreamer-pbutils/src/element_properties.rs b/gstreamer-pbutils/src/element_properties.rs index 2959124b0..7cdb28b51 100644 --- a/gstreamer-pbutils/src/element_properties.rs +++ b/gstreamer-pbutils/src/element_properties.rs @@ -90,7 +90,7 @@ impl ElementProperties { let structure_name = self.0.name(); if structure_name != "element-properties" { - assert_eq!(structure_name, "element-properties-map"); + debug_assert_eq!(structure_name, "element-properties-map"); return false; } diff --git a/gstreamer-pbutils/src/encoding_profile.rs b/gstreamer-pbutils/src/encoding_profile.rs index bc1b98784..d37c63da4 100644 --- a/gstreamer-pbutils/src/encoding_profile.rs +++ b/gstreamer-pbutils/src/encoding_profile.rs @@ -312,7 +312,7 @@ impl EncodingContainerProfile { profile.upcast().into_glib_ptr(), ); // Can't possibly fail unless we pass random pointers - assert_ne!(res, glib::ffi::GFALSE); + debug_assert_ne!(res, glib::ffi::GFALSE); } } } diff --git a/gstreamer-play/src/config.rs b/gstreamer-play/src/config.rs index e1a90ea54..57e494a32 100644 --- a/gstreamer-play/src/config.rs +++ b/gstreamer-play/src/config.rs @@ -41,13 +41,13 @@ impl PlayConfig { #[doc(alias = "get_position_update_interval")] #[doc(alias = "gst_play_config_get_position_update_interval")] pub fn position_update_interval(&self) -> u32 { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { ffi::gst_play_config_get_position_update_interval(self.0.to_glib_none().0) } } #[doc(alias = "get_seek_accurate")] pub fn is_seek_accurate(&self) -> bool { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { from_glib(ffi::gst_play_config_get_seek_accurate( self.0.to_glib_none().0, @@ -58,13 +58,13 @@ impl PlayConfig { #[doc(alias = "get_user_agent")] #[doc(alias = "gst_play_config_get_user_agent")] pub fn user_agent(&self) -> Option { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { from_glib_full(ffi::gst_play_config_get_user_agent(self.0.to_glib_none().0)) } } #[doc(alias = "gst_play_config_set_position_update_interval")] pub fn set_position_update_interval(&mut self, interval: u32) { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { ffi::gst_play_config_set_position_update_interval( self.0.to_glib_none_mut().0, @@ -74,7 +74,7 @@ impl PlayConfig { } pub fn set_seek_accurate(&mut self, accurate: bool) { - assert_initialized_main_thread!(); + skip_assert_initialized!(); // FIXME: Work-around for // http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=cc58bd6ae071dec4ea7b4be626034accd0372755 self.set("accurate-seek", accurate); @@ -82,7 +82,7 @@ impl PlayConfig { #[doc(alias = "gst_play_config_set_user_agent")] pub fn set_user_agent(&mut self, agent: &str) { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { ffi::gst_play_config_set_user_agent( self.0.to_glib_none_mut().0, diff --git a/gstreamer-play/src/play_video_overlay_video_renderer.rs b/gstreamer-play/src/play_video_overlay_video_renderer.rs index d2250235b..07251f133 100644 --- a/gstreamer-play/src/play_video_overlay_video_renderer.rs +++ b/gstreamer-play/src/play_video_overlay_video_renderer.rs @@ -20,7 +20,7 @@ impl PlayVideoOverlayVideoRenderer { window_handle: uintptr_t, video_sink: &P, ) -> PlayVideoOverlayVideoRenderer { - assert_initialized_main_thread!(); + skip_assert_initialized!(); from_glib_full(ffi::gst_play_video_overlay_video_renderer_new_with_sink( window_handle as *mut _, @@ -30,7 +30,7 @@ impl PlayVideoOverlayVideoRenderer { #[doc(alias = "gst_play_video_overlay_video_renderer_new_with_sink")] pub fn with_sink>(video_sink: &P) -> PlayVideoOverlayVideoRenderer { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { from_glib_full(ffi::gst_play_video_overlay_video_renderer_new_with_sink( diff --git a/gstreamer-player/src/config.rs b/gstreamer-player/src/config.rs index e809c6877..4ae85ec11 100644 --- a/gstreamer-player/src/config.rs +++ b/gstreamer-player/src/config.rs @@ -41,13 +41,13 @@ impl PlayerConfig { #[doc(alias = "get_position_update_interval")] #[doc(alias = "gst_player_config_get_position_update_interval")] pub fn position_update_interval(&self) -> u32 { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { ffi::gst_player_config_get_position_update_interval(self.0.to_glib_none().0) } } #[doc(alias = "get_seek_accurate")] pub fn is_seek_accurate(&self) -> bool { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { from_glib(ffi::gst_player_config_get_seek_accurate( self.0.to_glib_none().0, @@ -58,7 +58,7 @@ impl PlayerConfig { #[doc(alias = "get_user_agent")] #[doc(alias = "gst_player_config_get_user_agent")] pub fn user_agent(&self) -> Option { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { from_glib_full(ffi::gst_player_config_get_user_agent( self.0.to_glib_none().0, @@ -68,7 +68,7 @@ impl PlayerConfig { #[doc(alias = "gst_player_config_set_position_update_interval")] pub fn set_position_update_interval(&mut self, interval: u32) { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { ffi::gst_player_config_set_position_update_interval( self.0.to_glib_none_mut().0, @@ -78,7 +78,7 @@ impl PlayerConfig { } pub fn set_seek_accurate(&mut self, accurate: bool) { - assert_initialized_main_thread!(); + skip_assert_initialized!(); // FIXME: Work-around for // http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=cc58bd6ae071dec4ea7b4be626034accd0372755 self.set("accurate-seek", accurate); @@ -86,7 +86,7 @@ impl PlayerConfig { #[doc(alias = "gst_player_config_set_user_agent")] pub fn set_user_agent(&mut self, agent: &str) { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { ffi::gst_player_config_set_user_agent( self.0.to_glib_none_mut().0, diff --git a/gstreamer-player/src/player_video_overlay_video_renderer.rs b/gstreamer-player/src/player_video_overlay_video_renderer.rs index 0a8fef68c..11ad957e5 100644 --- a/gstreamer-player/src/player_video_overlay_video_renderer.rs +++ b/gstreamer-player/src/player_video_overlay_video_renderer.rs @@ -20,7 +20,7 @@ impl PlayerVideoOverlayVideoRenderer { window_handle: uintptr_t, video_sink: &P, ) -> PlayerVideoOverlayVideoRenderer { - assert_initialized_main_thread!(); + skip_assert_initialized!(); from_glib_full(ffi::gst_player_video_overlay_video_renderer_new_with_sink( window_handle as *mut _, @@ -30,7 +30,7 @@ impl PlayerVideoOverlayVideoRenderer { #[doc(alias = "gst_player_video_overlay_video_renderer_new_with_sink")] pub fn with_sink>(video_sink: &P) -> PlayerVideoOverlayVideoRenderer { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { from_glib_full(ffi::gst_player_video_overlay_video_renderer_new_with_sink( diff --git a/gstreamer-rtp/src/rtp_buffer.rs b/gstreamer-rtp/src/rtp_buffer.rs index 6dacb6158..683ba1b14 100644 --- a/gstreamer-rtp/src/rtp_buffer.rs +++ b/gstreamer-rtp/src/rtp_buffer.rs @@ -319,7 +319,7 @@ impl<'a, T> RTPBuffer<'a, T> { unsafe { let ptr = self.rtp_buffer.buffer; - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); gst::BufferRef::from_ptr(ptr) } diff --git a/gstreamer-rtsp-server/src/rtsp_context.rs b/gstreamer-rtsp-server/src/rtsp_context.rs index fb5d17906..cda3e3c2c 100644 --- a/gstreamer-rtsp-server/src/rtsp_context.rs +++ b/gstreamer-rtsp-server/src/rtsp_context.rs @@ -29,7 +29,7 @@ impl RTSPContext { impl FromGlibPtrBorrow<*mut ffi::GstRTSPContext> for RTSPContext { #[inline] unsafe fn from_glib_borrow(ptr: *mut ffi::GstRTSPContext) -> Borrowed { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); Borrowed::new(RTSPContext(ptr::NonNull::new_unchecked(ptr))) } } diff --git a/gstreamer-rtsp-server/src/rtsp_token.rs b/gstreamer-rtsp-server/src/rtsp_token.rs index cf63eb13b..0f0baef7d 100644 --- a/gstreamer-rtsp-server/src/rtsp_token.rs +++ b/gstreamer-rtsp-server/src/rtsp_token.rs @@ -16,7 +16,7 @@ impl RTSPToken { } pub fn new(values: &[(&str, &(dyn ToSendValue + Sync))]) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let mut token = RTSPToken::new_empty(); { diff --git a/gstreamer-sdp/src/sdp_bandwidth.rs b/gstreamer-sdp/src/sdp_bandwidth.rs index 54ecab984..5098525d8 100644 --- a/gstreamer-sdp/src/sdp_bandwidth.rs +++ b/gstreamer-sdp/src/sdp_bandwidth.rs @@ -38,7 +38,7 @@ impl SDPBandwidth { impl Clone for SDPBandwidth { fn clone(&self) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let mut bw = mem::MaybeUninit::uninit(); ffi::gst_sdp_bandwidth_set(bw.as_mut_ptr(), self.0.bwtype, self.0.bandwidth); diff --git a/gstreamer-sdp/src/sdp_connection.rs b/gstreamer-sdp/src/sdp_connection.rs index ec4132660..d0d4a750f 100644 --- a/gstreamer-sdp/src/sdp_connection.rs +++ b/gstreamer-sdp/src/sdp_connection.rs @@ -69,7 +69,7 @@ impl SDPConnection { impl Clone for SDPConnection { fn clone(&self) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let mut conn = mem::MaybeUninit::uninit(); ffi::gst_sdp_connection_set( diff --git a/gstreamer-sdp/src/sdp_media.rs b/gstreamer-sdp/src/sdp_media.rs index acb71006c..18ce5f65d 100644 --- a/gstreamer-sdp/src/sdp_media.rs +++ b/gstreamer-sdp/src/sdp_media.rs @@ -21,11 +21,13 @@ glib::wrapper! { match fn { copy => |ptr| { let mut copy = ptr::null_mut(); - assert_eq!(ffi::gst_sdp_media_copy(ptr, &mut copy), ffi::GST_SDP_OK); + let res = ffi::gst_sdp_media_copy(ptr, &mut copy); + debug_assert_eq!(res, ffi::GST_SDP_OK); copy }, free => |ptr| { - ffi::gst_sdp_media_free(ptr); + let res = ffi::gst_sdp_media_free(ptr); + debug_assert_eq!(res, ffi::GST_SDP_OK); }, } } @@ -612,7 +614,7 @@ impl SDPMediaRef { caps: &gst::CapsRef, media: &mut SDPMedia, ) -> Result<(), glib::BoolError> { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let result = unsafe { ffi::gst_sdp_media_set_media_from_caps(caps.as_ptr(), media.to_glib_none_mut().0) }; diff --git a/gstreamer-sdp/src/sdp_message.rs b/gstreamer-sdp/src/sdp_message.rs index e752bb6e7..0ece3d421 100644 --- a/gstreamer-sdp/src/sdp_message.rs +++ b/gstreamer-sdp/src/sdp_message.rs @@ -27,10 +27,14 @@ glib::wrapper! { match fn { copy => |ptr| { let mut copy = std::ptr::null_mut(); - assert_eq!(ffi::gst_sdp_message_copy(ptr, &mut copy), ffi::GST_SDP_OK); + let res = ffi::gst_sdp_message_copy(ptr, &mut copy); + debug_assert_eq!(res, ffi::GST_SDP_OK); copy }, - free => |ptr| assert_eq!(ffi::gst_sdp_message_free(ptr), ffi::GST_SDP_OK), + free => |ptr| { + let res = ffi::gst_sdp_message_free(ptr); + debug_assert_eq!(res, ffi::GST_SDP_OK); + }, type_ => || ffi::gst_sdp_message_get_type(), } } @@ -887,7 +891,7 @@ impl SDPMessageRef { #[doc(alias = "gst_sdp_message_as_uri")] pub fn as_uri(&self, scheme: &str) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { match from_glib_full(ffi::gst_sdp_message_as_uri( scheme.to_glib_none().0, diff --git a/gstreamer-sdp/src/sdp_time.rs b/gstreamer-sdp/src/sdp_time.rs index c85bae480..9e09446dd 100644 --- a/gstreamer-sdp/src/sdp_time.rs +++ b/gstreamer-sdp/src/sdp_time.rs @@ -66,7 +66,7 @@ impl SDPTime { impl Clone for SDPTime { fn clone(&self) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); #[allow(clippy::cast_ptr_alignment)] unsafe { let mut time = mem::MaybeUninit::uninit(); diff --git a/gstreamer-sdp/src/sdp_zone.rs b/gstreamer-sdp/src/sdp_zone.rs index d6f85d9a0..6cc7c14d4 100644 --- a/gstreamer-sdp/src/sdp_zone.rs +++ b/gstreamer-sdp/src/sdp_zone.rs @@ -48,7 +48,7 @@ impl SDPZone { impl Clone for SDPZone { fn clone(&self) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let mut zone = mem::MaybeUninit::uninit(); ffi::gst_sdp_zone_set(zone.as_mut_ptr(), self.0.time, self.0.typed_time); diff --git a/gstreamer-video/src/enums.rs b/gstreamer-video/src/enums.rs index 6e64fef48..4660d3dfd 100644 --- a/gstreamer-video/src/enums.rs +++ b/gstreamer-video/src/enums.rs @@ -16,7 +16,7 @@ use crate::VideoOrientationMethod; impl VideoCaptionType { #[doc(alias = "gst_video_caption_type_from_caps")] pub fn from_caps(caps: &gst::CapsRef) -> VideoCaptionType { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { from_glib(ffi::gst_video_caption_type_from_caps(caps.as_ptr())) } } } @@ -28,7 +28,7 @@ impl VideoOrientationMethod { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] #[doc(alias = "gst_video_orientation_from_tag")] pub fn from_tag(taglist: &gst::TagListRef) -> Option { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { use std::mem; diff --git a/gstreamer-video/src/functions.rs b/gstreamer-video/src/functions.rs index b1dd6ea6d..a53622102 100644 --- a/gstreamer-video/src/functions.rs +++ b/gstreamer-video/src/functions.rs @@ -212,7 +212,7 @@ pub fn is_common_aspect_ratio(width: u32, height: u32, par: gst::Fraction) -> bo pub fn video_make_raw_caps( formats: &[crate::VideoFormat], ) -> crate::VideoCapsBuilder { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let formats = formats.iter().copied().map(|f| match f { crate::VideoFormat::Encoded => panic!("Invalid encoded format"), diff --git a/gstreamer-video/src/video_buffer_pool.rs b/gstreamer-video/src/video_buffer_pool.rs index 68c740755..08d610f68 100644 --- a/gstreamer-video/src/video_buffer_pool.rs +++ b/gstreamer-video/src/video_buffer_pool.rs @@ -66,7 +66,7 @@ impl VideoAlignment { padding_right: u32, stride_align: &[u32; ffi::GST_VIDEO_MAX_PLANES as usize], ) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let videoalignment = ffi::GstVideoAlignment { padding_top, diff --git a/gstreamer-video/src/video_codec_frame.rs b/gstreamer-video/src/video_codec_frame.rs index 67a8f5646..83960ccc5 100644 --- a/gstreamer-video/src/video_codec_frame.rs +++ b/gstreamer-video/src/video_codec_frame.rs @@ -192,7 +192,7 @@ impl<'a> VideoCodecFrame<'a> { let writable: bool = from_glib(gst::ffi::gst_mini_object_is_writable( ptr as *const gst::ffi::GstMiniObject, )); - assert!(writable); + debug_assert!(writable); Some(gst::BufferRef::from_mut_ptr(ptr)) } @@ -201,19 +201,14 @@ impl<'a> VideoCodecFrame<'a> { pub fn set_output_buffer(&mut self, output_buffer: gst::Buffer) { unsafe { + assert!(output_buffer.is_writable()); let prev = (*self.to_glib_none().0).output_buffer; if !prev.is_null() { gst::ffi::gst_mini_object_unref(prev as *mut gst::ffi::GstMiniObject); } - let ptr = output_buffer.into_glib_ptr(); - let writable: bool = from_glib(gst::ffi::gst_mini_object_is_writable( - ptr as *const gst::ffi::GstMiniObject, - )); - assert!(writable); - - (*self.to_glib_none().0).output_buffer = ptr; + (*self.to_glib_none().0).output_buffer = output_buffer.into_glib_ptr(); } } diff --git a/gstreamer-video/src/video_converter.rs b/gstreamer-video/src/video_converter.rs index ebee06cc5..ff6eb5c0c 100644 --- a/gstreamer-video/src/video_converter.rs +++ b/gstreamer-video/src/video_converter.rs @@ -27,7 +27,7 @@ impl VideoConverter { out_info: &crate::VideoInfo, config: Option, ) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); if in_info.fps() != out_info.fps() { return Err(glib::bool_error!("Can't do framerate conversion")); } diff --git a/gstreamer-video/src/video_event.rs b/gstreamer-video/src/video_event.rs index f44134b92..f07919807 100644 --- a/gstreamer-video/src/video_event.rs +++ b/gstreamer-video/src/video_event.rs @@ -43,7 +43,7 @@ macro_rules! event_builder_generic_impl { #[must_use = "Building the event without using it has no effect"] pub fn build(mut self) -> gst::Event { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let event = $new_fn(&mut self); if let Some(seqnum) = self.seqnum { @@ -151,6 +151,7 @@ pub struct DownstreamForceKeyUnitEvent { impl DownstreamForceKeyUnitEvent { pub fn builder<'a>() -> DownstreamForceKeyUnitEventBuilder<'a> { + assert_initialized_main_thread!(); DownstreamForceKeyUnitEventBuilder::new() } @@ -246,6 +247,7 @@ pub struct UpstreamForceKeyUnitEvent { impl UpstreamForceKeyUnitEvent { pub fn builder<'a>() -> UpstreamForceKeyUnitEventBuilder<'a> { + assert_initialized_main_thread!(); UpstreamForceKeyUnitEventBuilder::new() } @@ -370,7 +372,7 @@ macro_rules! nav_event_builder { } impl<'a> $builder<'a> { - pub fn new($($event_field: $event_type)?) -> Self { + fn new($($event_field: $event_type)?) -> Self { skip_assert_initialized!(); Self { seqnum: None, @@ -500,7 +502,7 @@ pub struct CommandEventBuilder<'a> { } impl<'a> CommandEventBuilder<'a> { - pub fn new(command: NavigationCommand) -> Self { + fn new(command: NavigationCommand) -> Self { skip_assert_initialized!(); Self { seqnum: None, @@ -958,7 +960,7 @@ impl NavigationEvent { #[doc(alias = "gst_navigation_event_get_type")] pub fn type_(event: &gst::EventRef) -> NavigationEventType { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { from_glib(ffi::gst_navigation_event_get_type(event.as_mut_ptr())) } } diff --git a/gstreamer-video/src/video_format_info.rs b/gstreamer-video/src/video_format_info.rs index 25be3d1b3..4a13fd2e9 100644 --- a/gstreamer-video/src/video_format_info.rs +++ b/gstreamer-video/src/video_format_info.rs @@ -11,18 +11,16 @@ pub struct VideoFormatInfo(&'static ffi::GstVideoFormatInfo); impl VideoFormatInfo { #[inline] pub unsafe fn from_ptr(format_info: *const ffi::GstVideoFormatInfo) -> Self { - assert_initialized_main_thread!(); - assert!(!format_info.is_null()); + debug_assert!(!format_info.is_null()); Self(&*format_info) } #[inline] pub fn from_format(format: crate::VideoFormat) -> Self { assert_initialized_main_thread!(); - unsafe { let info = ffi::gst_video_format_get_info(format.into_glib()); - assert!(!info.is_null()); + debug_assert!(!info.is_null()); Self(&*info) } diff --git a/gstreamer-video/src/video_frame.rs b/gstreamer-video/src/video_frame.rs index 1c83df8cc..e92e89777 100644 --- a/gstreamer-video/src/video_frame.rs +++ b/gstreamer-video/src/video_frame.rs @@ -732,7 +732,7 @@ impl VideoFrameRef { impl<'a> VideoFrameRef<&'a gst::BufferRef> { #[inline] pub unsafe fn from_glib_borrow(frame: *const ffi::GstVideoFrame) -> Borrowed { - assert!(!frame.is_null()); + debug_assert!(!frame.is_null()); let frame = ptr::read(frame); let info = crate::VideoInfo(ptr::read(&frame.info)); @@ -832,7 +832,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> { impl<'a> VideoFrameRef<&'a mut gst::BufferRef> { #[inline] pub unsafe fn from_glib_borrow_mut(frame: *mut ffi::GstVideoFrame) -> Self { - assert!(!frame.is_null()); + debug_assert!(!frame.is_null()); let frame = ptr::read(frame); let info = crate::VideoInfo(ptr::read(&frame.info)); diff --git a/gstreamer-video/src/video_hdr.rs b/gstreamer-video/src/video_hdr.rs index ae99629b9..afe96fffd 100644 --- a/gstreamer-video/src/video_hdr.rs +++ b/gstreamer-video/src/video_hdr.rs @@ -10,7 +10,7 @@ pub struct VideoContentLightLevel(ffi::GstVideoContentLightLevel); impl VideoContentLightLevel { pub fn new(max_content_light_level: u16, max_frame_average_light_level: u16) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); VideoContentLightLevel(ffi::GstVideoContentLightLevel { max_content_light_level, @@ -148,7 +148,7 @@ impl VideoMasteringDisplayInfo { max_display_mastering_luminance: u32, min_display_mastering_luminance: u32, ) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); VideoMasteringDisplayInfo(ffi::GstVideoMasteringDisplayInfo { display_primaries: unsafe { mem::transmute(display_primaries) }, diff --git a/gstreamer-video/src/video_info.rs b/gstreamer-video/src/video_info.rs index 39e18bb9a..e171fe386 100644 --- a/gstreamer-video/src/video_info.rs +++ b/gstreamer-video/src/video_info.rs @@ -101,7 +101,7 @@ impl VideoColorimetry { transfer: crate::VideoTransferFunction, primaries: crate::VideoColorPrimaries, ) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let colorimetry = ffi::GstVideoColorimetry { range: range.into_glib(), diff --git a/gstreamer-video/src/video_message.rs b/gstreamer-video/src/video_message.rs index de52f54e9..4cc37b3a4 100644 --- a/gstreamer-video/src/video_message.rs +++ b/gstreamer-video/src/video_message.rs @@ -42,7 +42,7 @@ macro_rules! message_builder_generic_impl { #[must_use = "Building the message without using it has no effect"] pub fn build(mut self) -> Message { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let src = self.builder.src.to_glib_none().0; let msg = $new_fn(&mut self, src); @@ -77,8 +77,8 @@ struct MessageBuilder<'a> { } impl<'a> MessageBuilder<'a> { - pub fn new() -> Self { - assert_initialized_main_thread!(); + pub(crate) fn new() -> Self { + skip_assert_initialized!(); Self { src: None, seqnum: None, @@ -151,18 +151,18 @@ impl NavigationEventMessage { #[doc(alias = "gst_navigation_message_new_event")] #[allow(clippy::new_ret_no_self)] pub fn new(event: gst::Event) -> gst::Message { - assert_initialized_main_thread!(); + skip_assert_initialized!(); NavigationEventMessageBuilder::new(event).build() } pub fn builder<'a>(event: gst::Event) -> NavigationEventMessageBuilder<'a> { - assert_initialized_main_thread!(); + skip_assert_initialized!(); NavigationEventMessageBuilder::new(event) } #[doc(alias = "gst_navigation_message_parse_event")] pub fn parse(msg: &gst::MessageRef) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let mut event = ptr::null_mut(); let ret = from_glib(ffi::gst_navigation_message_parse_event( @@ -188,7 +188,7 @@ pub enum NavigationMessage { impl NavigationMessage { #[doc(alias = "gst_navigation_message_get_type")] pub fn type_(msg: &gst::MessageRef) -> NavigationMessageType { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { from_glib(ffi::gst_navigation_message_get_type(msg.as_mut_ptr())) } } diff --git a/gstreamer-video/src/video_overlay_composition.rs b/gstreamer-video/src/video_overlay_composition.rs index 7b9c39e22..f3eab7f7c 100644 --- a/gstreamer-video/src/video_overlay_composition.rs +++ b/gstreamer-video/src/video_overlay_composition.rs @@ -37,7 +37,7 @@ impl VideoOverlayRectangle { render_height: u32, flags: crate::VideoOverlayFormatFlags, ) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); assert!(buffer.meta::().is_some()); unsafe { from_glib_full(ffi::gst_video_overlay_rectangle_new_raw( diff --git a/gstreamer-video/src/video_time_code.rs b/gstreamer-video/src/video_time_code.rs index 264868a13..d9e3f340e 100644 --- a/gstreamer-video/src/video_time_code.rs +++ b/gstreamer-video/src/video_time_code.rs @@ -203,7 +203,7 @@ impl ValidVideoTimeCode { frames: u32, field_count: u32, ) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let tc = VideoTimeCode::new( fps, latest_daily_jam, @@ -233,7 +233,6 @@ impl ValidVideoTimeCode { #[doc(alias = "gst_video_time_code_add_frames")] pub fn add_frames(&mut self, frames: i64) { - skip_assert_initialized!(); unsafe { ffi::gst_video_time_code_add_frames(self.to_glib_none_mut().0, frames); } diff --git a/gstreamer-webrtc/src/lib.rs b/gstreamer-webrtc/src/lib.rs index bb4bd4116..84f180169 100644 --- a/gstreamer-webrtc/src/lib.rs +++ b/gstreamer-webrtc/src/lib.rs @@ -10,14 +10,6 @@ pub use glib; pub use gst; pub use gst_sdp; -macro_rules! assert_initialized_main_thread { - () => { - if !gst::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) { - gst::assert_initialized(); - } - }; -} - macro_rules! skip_assert_initialized { () => {}; } diff --git a/gstreamer-webrtc/src/web_rtc_session_description.rs b/gstreamer-webrtc/src/web_rtc_session_description.rs index cd4aafdde..81f597124 100644 --- a/gstreamer-webrtc/src/web_rtc_session_description.rs +++ b/gstreamer-webrtc/src/web_rtc_session_description.rs @@ -9,7 +9,7 @@ use crate::{WebRTCSDPType, WebRTCSessionDescription}; impl WebRTCSessionDescription { #[doc(alias = "gst_webrtc_session_description_new")] pub fn new(type_: WebRTCSDPType, sdp: gst_sdp::SDPMessage) -> WebRTCSessionDescription { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let mut sdp = mem::ManuallyDrop::new(sdp); from_glib_full(ffi::gst_webrtc_session_description_new( diff --git a/gstreamer/src/allocation_params.rs b/gstreamer/src/allocation_params.rs index 6aaaede6f..1795335c9 100644 --- a/gstreamer/src/allocation_params.rs +++ b/gstreamer/src/allocation_params.rs @@ -82,7 +82,7 @@ impl FromGlib for AllocationParams { #[allow(unused_unsafe)] #[inline] unsafe fn from_glib(value: ffi::GstAllocationParams) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Self::from(value) } } diff --git a/gstreamer/src/buffer.rs b/gstreamer/src/buffer.rs index 953b9e090..836209e4e 100644 --- a/gstreamer/src/buffer.rs +++ b/gstreamer/src/buffer.rs @@ -163,7 +163,6 @@ impl Buffer { #[doc(alias = "gst_buffer_append")] pub fn append(&mut self, other: Self) { - skip_assert_initialized!(); unsafe { let ptr = ffi::gst_buffer_append(self.as_mut_ptr(), other.into_glib_ptr()); self.replace_ptr(ptr); @@ -1001,8 +1000,7 @@ impl<'a> IntoIterator for &'a BufferRef { impl std::iter::FromIterator for Buffer { fn from_iter>(iter: T) -> Self { - assert_initialized_main_thread!(); - + skip_assert_initialized!(); let iter = iter.into_iter(); let mut buffer = Buffer::new(); diff --git a/gstreamer/src/buffer_cursor.rs b/gstreamer/src/buffer_cursor.rs index bef2f6f10..7572df504 100644 --- a/gstreamer/src/buffer_cursor.rs +++ b/gstreamer/src/buffer_cursor.rs @@ -112,7 +112,7 @@ macro_rules! define_read_write_fn_impl( buffer_ref($self).as_mut_ptr(), $self.cur_mem_idx, ); - assert!(!memory.is_null()); + debug_assert!(!memory.is_null()); if ffi::gst_memory_map(memory, &mut $self.map_info, $map_flags) == glib::ffi::GFALSE @@ -124,10 +124,10 @@ macro_rules! define_read_write_fn_impl( } } - assert!($self.cur_mem_offset < $self.map_info.size); + debug_assert!($self.cur_mem_offset < $self.map_info.size); } - assert!(!$self.map_info.memory.is_null()); + debug_assert!(!$self.map_info.memory.is_null()); // Copy all data we can currently copy let data_left = $self.map_info.size - $self.cur_mem_offset; diff --git a/gstreamer/src/buffer_pool.rs b/gstreamer/src/buffer_pool.rs index 5152b8d5f..473e616f8 100644 --- a/gstreamer/src/buffer_pool.rs +++ b/gstreamer/src/buffer_pool.rs @@ -52,7 +52,7 @@ pub struct BufferPoolConfigRef(StructureRef); impl BufferPoolConfigRef { #[inline] pub unsafe fn from_glib_borrow<'a>(ptr: *const ffi::GstStructure) -> &'a BufferPoolConfigRef { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); &*(ptr as *mut StructureRef as *mut BufferPoolConfigRef) } @@ -61,7 +61,7 @@ impl BufferPoolConfigRef { pub unsafe fn from_glib_borrow_mut<'a>( ptr: *mut ffi::GstStructure, ) -> &'a mut BufferPoolConfigRef { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); &mut *(ptr as *mut StructureRef as *mut BufferPoolConfigRef) } diff --git a/gstreamer/src/caps.rs b/gstreamer/src/caps.rs index 0a12097c7..aab365c7d 100644 --- a/gstreamer/src/caps.rs +++ b/gstreamer/src/caps.rs @@ -51,7 +51,7 @@ impl Caps { #[doc(alias = "gst_caps_new_simple")] pub fn new_simple(name: &str, values: &[(&str, &(dyn ToSendValue + Sync))]) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let mut caps = Caps::new_empty(); let structure = Structure::new(name, values); @@ -68,7 +68,6 @@ impl Caps { #[doc(alias = "gst_caps_fixate")] pub fn fixate(&mut self) { - skip_assert_initialized!(); unsafe { // See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/388 assert!(!self.is_any()); @@ -83,7 +82,6 @@ impl Caps { #[doc(alias = "gst_caps_merge")] pub fn merge(&mut self, other: Self) { - skip_assert_initialized!(); unsafe { let ptr = ffi::gst_caps_merge(self.as_mut_ptr(), other.into_glib_ptr()); self.replace_ptr(ptr); @@ -92,7 +90,6 @@ impl Caps { #[doc(alias = "gst_caps_merge_structure")] pub fn merge_structure(&mut self, structure: Structure) { - skip_assert_initialized!(); unsafe { let ptr = ffi::gst_caps_merge_structure(self.as_mut_ptr(), structure.into_glib_ptr()); self.replace_ptr(ptr); @@ -101,7 +98,6 @@ impl Caps { #[doc(alias = "gst_caps_merge_structure_full")] pub fn merge_structure_full(&mut self, structure: Structure, features: Option) { - skip_assert_initialized!(); unsafe { let ptr = ffi::gst_caps_merge_structure_full( self.as_mut_ptr(), @@ -116,7 +112,6 @@ impl Caps { #[doc(alias = "gst_caps_normalize")] pub fn normalize(&mut self) { - skip_assert_initialized!(); unsafe { let ptr = ffi::gst_caps_normalize(self.as_mut_ptr()); self.replace_ptr(ptr); @@ -125,7 +120,6 @@ impl Caps { #[doc(alias = "gst_caps_simplify")] pub fn simplify(&mut self) { - skip_assert_initialized!(); unsafe { let ptr = ffi::gst_caps_simplify(self.as_mut_ptr()); self.replace_ptr(ptr); @@ -134,7 +128,6 @@ impl Caps { #[doc(alias = "gst_caps_truncate")] pub fn truncate(&mut self) { - skip_assert_initialized!(); unsafe { let ptr = ffi::gst_caps_truncate(self.as_mut_ptr()); self.replace_ptr(ptr); @@ -157,7 +150,7 @@ impl str::FromStr for Caps { impl std::iter::FromIterator for Caps { fn from_iter>(iter: T) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let mut caps = Caps::new_empty(); { @@ -171,7 +164,7 @@ impl std::iter::FromIterator for Caps { impl std::iter::FromIterator<(Structure, CapsFeatures)> for Caps { fn from_iter>(iter: T) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let mut caps = Caps::new_empty(); { @@ -186,7 +179,7 @@ impl std::iter::FromIterator<(Structure, CapsFeatures)> for Caps { impl std::iter::FromIterator<(Structure, Option)> for Caps { fn from_iter)>>(iter: T) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let mut caps = Caps::new_empty(); { @@ -201,7 +194,7 @@ impl std::iter::FromIterator<(Structure, Option)> for Caps { impl std::iter::FromIterator for Caps { fn from_iter>(iter: T) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let mut caps = Caps::new_empty(); { @@ -493,7 +486,6 @@ impl CapsRef { #[doc(alias = "gst_caps_subtract")] pub fn subtract(&self, other: &Self) -> Caps { - skip_assert_initialized!(); unsafe { from_glib_full(ffi::gst_caps_subtract( self.as_mut_ptr(), diff --git a/gstreamer/src/caps_features.rs b/gstreamer/src/caps_features.rs index b19e1fdbd..7abad52f1 100644 --- a/gstreamer/src/caps_features.rs +++ b/gstreamer/src/caps_features.rs @@ -22,7 +22,7 @@ unsafe impl Sync for CapsFeatures {} impl CapsFeatures { #[doc(alias = "gst_caps_features_new")] pub fn new(features: &[&str]) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let mut f = Self::new_empty(); for feature in features { @@ -34,7 +34,7 @@ impl CapsFeatures { #[doc(alias = "gst_caps_features_new_id")] pub fn from_quarks(features: &[glib::Quark]) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let mut f = Self::new_empty(); for feature in features { @@ -104,7 +104,7 @@ impl Clone for CapsFeatures { fn clone(&self) -> Self { unsafe { let ptr = ffi::gst_caps_features_copy(self.0.as_ref()); - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); CapsFeatures(ptr::NonNull::new_unchecked(ptr)) } } @@ -218,9 +218,9 @@ impl<'a> ToGlibPtrMut<'a, *mut ffi::GstCapsFeatures> for CapsFeatures { impl FromGlibPtrNone<*const ffi::GstCapsFeatures> for CapsFeatures { #[inline] unsafe fn from_glib_none(ptr: *const ffi::GstCapsFeatures) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); let ptr = ffi::gst_caps_features_copy(ptr); - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); CapsFeatures(ptr::NonNull::new_unchecked(ptr)) } } @@ -228,9 +228,9 @@ impl FromGlibPtrNone<*const ffi::GstCapsFeatures> for CapsFeatures { impl FromGlibPtrNone<*mut ffi::GstCapsFeatures> for CapsFeatures { #[inline] unsafe fn from_glib_none(ptr: *mut ffi::GstCapsFeatures) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); let ptr = ffi::gst_caps_features_copy(ptr); - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); CapsFeatures(ptr::NonNull::new_unchecked(ptr)) } } @@ -238,7 +238,7 @@ impl FromGlibPtrNone<*mut ffi::GstCapsFeatures> for CapsFeatures { impl FromGlibPtrFull<*const ffi::GstCapsFeatures> for CapsFeatures { #[inline] unsafe fn from_glib_full(ptr: *const ffi::GstCapsFeatures) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); CapsFeatures(ptr::NonNull::new_unchecked( ptr as *mut ffi::GstCapsFeatures, )) @@ -248,7 +248,7 @@ impl FromGlibPtrFull<*const ffi::GstCapsFeatures> for CapsFeatures { impl FromGlibPtrFull<*mut ffi::GstCapsFeatures> for CapsFeatures { #[inline] unsafe fn from_glib_full(ptr: *mut ffi::GstCapsFeatures) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); CapsFeatures(ptr::NonNull::new_unchecked(ptr)) } } @@ -327,7 +327,7 @@ pub struct CapsFeaturesRef(ffi::GstCapsFeatures); impl CapsFeaturesRef { #[inline] pub unsafe fn from_glib_borrow<'a>(ptr: *const ffi::GstCapsFeatures) -> &'a CapsFeaturesRef { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); &*(ptr as *mut CapsFeaturesRef) } @@ -336,7 +336,7 @@ impl CapsFeaturesRef { pub unsafe fn from_glib_borrow_mut<'a>( ptr: *mut ffi::GstCapsFeatures, ) -> &'a mut CapsFeaturesRef { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); &mut *(ptr as *mut CapsFeaturesRef) } @@ -547,7 +547,7 @@ impl<'a> Iterator for Iter<'a> { unsafe { let feature = ffi::gst_caps_features_get_nth(self.caps_features.as_ptr(), self.idx as u32); - assert!(!feature.is_null()); + debug_assert!(!feature.is_null()); self.idx += 1; @@ -576,7 +576,7 @@ impl<'a> Iterator for Iter<'a> { self.idx = end + 1; let feature = ffi::gst_caps_features_get_nth(self.caps_features.as_ptr(), end as u32); - assert!(!feature.is_null()); + debug_assert!(!feature.is_null()); Some(CStr::from_ptr(feature).to_str().unwrap()) } } @@ -591,7 +591,7 @@ impl<'a> Iterator for Iter<'a> { self.caps_features.as_ptr(), self.n_features as u32 - 1, ); - assert!(!feature.is_null()); + debug_assert!(!feature.is_null()); Some(CStr::from_ptr(feature).to_str().unwrap()) } } @@ -609,7 +609,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> { unsafe { let feature = ffi::gst_caps_features_get_nth(self.caps_features.as_ptr(), self.n_features as u32); - assert!(!feature.is_null()); + debug_assert!(!feature.is_null()); Some(CStr::from_ptr(feature).to_str().unwrap()) } @@ -627,7 +627,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> { self.caps_features.as_ptr(), self.n_features as u32, ); - assert!(!feature.is_null()); + debug_assert!(!feature.is_null()); Some(CStr::from_ptr(feature).to_str().unwrap()) } @@ -650,8 +650,7 @@ impl<'a> IntoIterator for &'a CapsFeaturesRef { impl<'a> std::iter::FromIterator<&'a str> for CapsFeatures { fn from_iter>(iter: T) -> Self { - assert_initialized_main_thread!(); - + skip_assert_initialized!(); let mut features = CapsFeatures::new_empty(); iter.into_iter().for_each(|f| features.add(f)); @@ -662,8 +661,7 @@ impl<'a> std::iter::FromIterator<&'a str> for CapsFeatures { impl std::iter::FromIterator for CapsFeatures { fn from_iter>(iter: T) -> Self { - assert_initialized_main_thread!(); - + skip_assert_initialized!(); let mut features = CapsFeatures::new_empty(); iter.into_iter().for_each(|f| features.add(&f)); @@ -674,8 +672,7 @@ impl std::iter::FromIterator for CapsFeatures { impl std::iter::FromIterator for CapsFeatures { fn from_iter>(iter: T) -> Self { - assert_initialized_main_thread!(); - + skip_assert_initialized!(); let mut features = CapsFeatures::new_empty(); iter.into_iter().for_each(|f| features.add_from_quark(f)); diff --git a/gstreamer/src/clock.rs b/gstreamer/src/clock.rs index 62e2c8917..39c2ba543 100644 --- a/gstreamer/src/clock.rs +++ b/gstreamer/src/clock.rs @@ -469,7 +469,6 @@ impl> ClockExtManual for O { start_time: ClockTime, interval: ClockTime, ) -> Result<(), glib::BoolError> { - skip_assert_initialized!(); unsafe { let res: bool = from_glib(ffi::gst_clock_periodic_id_reinit( self.as_ref().to_glib_none().0, diff --git a/gstreamer/src/device_monitor.rs b/gstreamer/src/device_monitor.rs index 7191c4159..90a9cdd76 100644 --- a/gstreamer/src/device_monitor.rs +++ b/gstreamer/src/device_monitor.rs @@ -22,7 +22,7 @@ impl FromGlib for DeviceMonitorFilterId { #[inline] unsafe fn from_glib(val: libc::c_uint) -> DeviceMonitorFilterId { skip_assert_initialized!(); - assert_ne!(val, 0); + debug_assert_ne!(val, 0); DeviceMonitorFilterId(NonZeroU32::new_unchecked(val)) } } diff --git a/gstreamer/src/device_provider.rs b/gstreamer/src/device_provider.rs index 8c669ff68..9689b0c76 100644 --- a/gstreamer/src/device_provider.rs +++ b/gstreamer/src/device_provider.rs @@ -14,7 +14,7 @@ impl DeviceProvider { rank: Rank, type_: glib::types::Type, ) -> Result<(), glib::error::BoolError> { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { glib::result_from_gboolean!( ffi::gst_device_provider_register( diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index d22bb3584..8f3095b2a 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -56,7 +56,7 @@ impl Element { rank: Rank, type_: glib::types::Type, ) -> Result<(), glib::error::BoolError> { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { glib::result_from_gboolean!( ffi::gst_element_register( @@ -94,7 +94,7 @@ impl FromGlib for NotifyWatchId { #[inline] unsafe fn from_glib(val: libc::c_ulong) -> NotifyWatchId { skip_assert_initialized!(); - assert_ne!(val, 0); + debug_assert_ne!(val, 0); NotifyWatchId(NonZeroU64::new_unchecked(val as _)) } } diff --git a/gstreamer/src/element_factory.rs b/gstreamer/src/element_factory.rs index dfe953d39..3f8784b81 100644 --- a/gstreamer/src/element_factory.rs +++ b/gstreamer/src/element_factory.rs @@ -17,8 +17,6 @@ impl ElementFactory { &self, properties: &[(&str, &dyn ToValue)], ) -> Result { - assert_initialized_main_thread!(); - let mut builder = self.create(); builder.properties = properties .iter() @@ -33,8 +31,7 @@ impl ElementFactory { factoryname: &str, properties: &[(&str, &dyn ToValue)], ) -> Result { - assert_initialized_main_thread!(); - + skip_assert_initialized!(); let mut builder = Self::make(factoryname); builder.properties = properties .iter() @@ -47,6 +44,8 @@ impl ElementFactory { #[doc(alias = "gst_element_factory_create_with_properties")] #[track_caller] pub fn create(&self) -> ElementBuilder { + assert_initialized_main_thread!(); + ElementBuilder { name_or_factory: NameOrFactory::Factory(self), properties: Vec::new(), @@ -81,8 +80,7 @@ impl ElementFactory { factoryname: &str, name: Option<&str>, ) -> Result { - assert_initialized_main_thread!(); - + skip_assert_initialized!(); let mut builder = Self::make(factoryname); if let Some(name) = name { builder = builder.name(name); diff --git a/gstreamer/src/error.rs b/gstreamer/src/error.rs index ae3ed057e..e47d7580a 100644 --- a/gstreamer/src/error.rs +++ b/gstreamer/src/error.rs @@ -62,7 +62,7 @@ impl ErrorMessage { function: &'static str, line: u32, ) -> ErrorMessage { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let error_domain = T::domain(); let error_code = error.code(); @@ -115,7 +115,7 @@ pub struct LoggableError { impl LoggableError { pub fn new(category: crate::DebugCategory, bool_error: glib::BoolError) -> LoggableError { - assert_initialized_main_thread!(); + skip_assert_initialized!(); LoggableError { category, bool_error, diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 90aa26817..5700d6aa0 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -157,7 +157,7 @@ impl EventRef { pub fn seqnum(&self) -> Seqnum { unsafe { let seqnum = ffi::gst_event_get_seqnum(self.as_mut_ptr()); - assert_ne!(seqnum, 0); + debug_assert_ne!(seqnum, 0); Seqnum(NonZeroU32::new_unchecked(seqnum)) } } @@ -770,7 +770,7 @@ impl StreamGroupDone { ffi::gst_event_parse_stream_group_done(self.as_mut_ptr(), group_id.as_mut_ptr()); let group_id = group_id.assume_init(); - assert_ne!(group_id, 0); + debug_assert_ne!(group_id, 0); GroupId(NonZeroU32::new_unchecked(group_id)) } } @@ -1544,7 +1544,6 @@ macro_rules! event_builder_generic_impl { #[must_use = "Building the event without using it has no effect"] pub fn build(mut self) -> Event { - assert_initialized_main_thread!(); unsafe { let event = $new_fn(&mut self); if let Some(seqnum) = self.builder.seqnum { diff --git a/gstreamer/src/functions.rs b/gstreamer/src/functions.rs index ae154da87..ac4ef0458 100644 --- a/gstreamer/src/functions.rs +++ b/gstreamer/src/functions.rs @@ -16,7 +16,7 @@ pub fn parse_bin_from_description_with_name( ghost_unlinked_pads: bool, bin_name: &str, ) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let bin = parse_bin_from_description(bin_description, ghost_unlinked_pads)?; if !bin_name.is_empty() { let obj = bin.clone().upcast::(); @@ -34,7 +34,7 @@ pub fn parse_bin_from_description_full( mut context: Option<&mut ParseContext>, flags: ParseFlags, ) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let mut error = ptr::null_mut(); let ret = ffi::gst_parse_bin_from_description_full( @@ -59,7 +59,7 @@ pub fn parse_bin_from_description_with_name_full( context: Option<&mut ParseContext>, flags: ParseFlags, ) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let bin = parse_bin_from_description_full(bin_description, ghost_unlinked_pads, context, flags)?; if !bin_name.is_empty() { diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index d1ff6b6f8..156453b67 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -590,7 +590,7 @@ impl<'a, T: 'static> glib::translate::ToGlibPtrMut<'a, *mut ffi::GstIterator> fo impl glib::translate::FromGlibPtrNone<*const ffi::GstIterator> for Iterator { #[inline] unsafe fn from_glib_none(ptr: *const ffi::GstIterator) -> Self { - assert_ne!( + debug_assert_ne!( glib::gobject_ffi::g_type_is_a((*ptr).type_, T::static_type().into_glib()), glib::ffi::GFALSE ); @@ -602,7 +602,7 @@ impl glib::translate::FromGlibPtrNone<*const ffi::GstIterator> fo impl glib::translate::FromGlibPtrNone<*mut ffi::GstIterator> for Iterator { #[inline] unsafe fn from_glib_none(ptr: *mut ffi::GstIterator) -> Self { - assert_ne!( + debug_assert_ne!( glib::gobject_ffi::g_type_is_a((*ptr).type_, T::static_type().into_glib()), glib::ffi::GFALSE ); @@ -614,8 +614,8 @@ impl glib::translate::FromGlibPtrNone<*mut ffi::GstIterator> for impl glib::translate::FromGlibPtrBorrow<*mut ffi::GstIterator> for Iterator { #[inline] unsafe fn from_glib_borrow(ptr: *mut ffi::GstIterator) -> Borrowed { - assert!(!ptr.is_null()); - assert_ne!( + debug_assert!(!ptr.is_null()); + debug_assert_ne!( glib::gobject_ffi::g_type_is_a((*ptr).type_, T::static_type().into_glib()), glib::ffi::GFALSE ); @@ -630,8 +630,8 @@ impl glib::translate::FromGlibPtrBorrow<*mut ffi::GstIterator> fo impl glib::translate::FromGlibPtrFull<*mut ffi::GstIterator> for Iterator { #[inline] unsafe fn from_glib_full(ptr: *mut ffi::GstIterator) -> Self { - assert!(!ptr.is_null()); - assert_ne!( + debug_assert!(!ptr.is_null()); + debug_assert_ne!( glib::gobject_ffi::g_type_is_a((*ptr).type_, T::static_type().into_glib()), glib::ffi::GFALSE ); diff --git a/gstreamer/src/log.rs b/gstreamer/src/log.rs index d2dde9ff5..a338647c5 100644 --- a/gstreamer/src/log.rs +++ b/gstreamer/src/log.rs @@ -525,7 +525,7 @@ unsafe impl TransparentPtrType for DebugCategory {} impl FromGlibPtrNone<*mut ffi::GstDebugCategory> for DebugCategory { #[inline] unsafe fn from_glib_none(ptr: *mut ffi::GstDebugCategory) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); DebugCategory(Some(ptr::NonNull::new_unchecked(ptr))) } } @@ -533,7 +533,7 @@ impl FromGlibPtrNone<*mut ffi::GstDebugCategory> for DebugCategory { impl FromGlibPtrFull<*mut ffi::GstDebugCategory> for DebugCategory { #[inline] unsafe fn from_glib_full(ptr: *mut ffi::GstDebugCategory) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); DebugCategory(Some(ptr::NonNull::new_unchecked(ptr))) } } diff --git a/gstreamer/src/memory.rs b/gstreamer/src/memory.rs index 09b57f481..e2606e217 100644 --- a/gstreamer/src/memory.rs +++ b/gstreamer/src/memory.rs @@ -836,7 +836,7 @@ macro_rules! memory_object_wrapper { let value = &*(value as *const $crate::glib::Value as *const $crate::glib::gobject_ffi::GValue); let ptr = &value.data[0].v_pointer as *const $crate::glib::ffi::gpointer as *const *const $ffi_name; - assert!(!(*ptr).is_null()); + debug_assert!(!(*ptr).is_null()); &*(ptr as *const $name) } } diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index b96897aaa..ae185b98d 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -1853,7 +1853,6 @@ macro_rules! message_builder_generic_impl { #[must_use = "Building the message without using it has no effect"] pub fn build(mut self) -> Message { - assert_initialized_main_thread!(); unsafe { let src = self.builder.src.to_glib_none().0; let msg = $new_fn(&mut self, src); diff --git a/gstreamer/src/meta.rs b/gstreamer/src/meta.rs index 1ebe7f734..96f295804 100644 --- a/gstreamer/src/meta.rs +++ b/gstreamer/src/meta.rs @@ -17,11 +17,11 @@ pub unsafe trait MetaAPI: Sync + Send + Sized { #[inline] unsafe fn from_ptr(buffer: &BufferRef, ptr: *const Self::GstType) -> MetaRef { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); let meta_api = Self::meta_api(); if meta_api != glib::Type::INVALID { - assert_eq!( + debug_assert_eq!( meta_api, from_glib((*(*(ptr as *const ffi::GstMeta)).info).api) ) @@ -38,11 +38,11 @@ pub unsafe trait MetaAPI: Sync + Send + Sized { buffer: &mut BufferRef, ptr: *mut Self::GstType, ) -> MetaRefMut { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); let meta_api = Self::meta_api(); if meta_api != glib::Type::INVALID { - assert_eq!( + debug_assert_eq!( meta_api, from_glib((*(*(ptr as *const ffi::GstMeta)).info).api) ) @@ -278,7 +278,7 @@ impl<'a, T> MetaRefMut<'a, T, Standalone> { self.buffer.as_mut_ptr(), self.meta as *mut T as *mut ffi::GstMeta, ); - assert_ne!(res, glib::ffi::GFALSE); + debug_assert_ne!(res, glib::ffi::GFALSE); Ok(()) } diff --git a/gstreamer/src/miniobject.rs b/gstreamer/src/miniobject.rs index 8977a548f..71f7bea29 100644 --- a/gstreamer/src/miniobject.rs +++ b/gstreamer/src/miniobject.rs @@ -31,7 +31,7 @@ macro_rules! mini_object_wrapper ( #[inline] pub unsafe fn from_glib_none(ptr: *const $ffi_name) -> Self { skip_assert_initialized!(); - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); $crate::ffi::gst_mini_object_ref(ptr as *mut $crate::ffi::GstMiniObject); @@ -43,7 +43,7 @@ macro_rules! mini_object_wrapper ( #[inline] pub unsafe fn from_glib_full(ptr: *const $ffi_name) -> Self { skip_assert_initialized!(); - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); $name { obj: std::ptr::NonNull::new_unchecked(ptr as *mut $ffi_name), @@ -53,7 +53,7 @@ macro_rules! mini_object_wrapper ( #[inline] pub unsafe fn from_glib_borrow(ptr: *const $ffi_name) -> $crate::glib::translate::Borrowed { skip_assert_initialized!(); - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); $crate::glib::translate::Borrowed::new($name { obj: std::ptr::NonNull::new_unchecked(ptr as *mut $ffi_name), @@ -62,7 +62,7 @@ macro_rules! mini_object_wrapper ( #[inline] pub unsafe fn replace_ptr(&mut self, ptr: *mut $ffi_name) { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); self.obj = std::ptr::NonNull::new_unchecked(ptr); } @@ -78,7 +78,7 @@ macro_rules! mini_object_wrapper ( self.as_mut_ptr() as *mut $crate::ffi::GstMiniObject ); self.replace_ptr(ptr as *mut $ffi_name); - assert!(self.is_writable()); + debug_assert!(self.is_writable()); &mut *(self.obj.as_mut() as *mut $ffi_name as *mut $ref_name) } @@ -435,14 +435,14 @@ macro_rules! mini_object_wrapper ( #[inline] pub unsafe fn from_ptr<'a>(ptr: *const $ffi_name) -> &'a Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); &*(ptr as *const Self) } #[inline] pub unsafe fn from_mut_ptr<'a>(ptr: *mut $ffi_name) -> &'a mut Self { - assert!(!ptr.is_null()); - assert_ne!( + debug_assert!(!ptr.is_null()); + debug_assert_ne!( $crate::ffi::gst_mini_object_is_writable(ptr as *mut $crate::ffi::GstMiniObject), $crate::glib::ffi::GFALSE ); @@ -542,7 +542,7 @@ macro_rules! mini_object_wrapper ( assert_eq!(std::mem::size_of::<$name>(), std::mem::size_of::<$crate::glib::ffi::gpointer>()); let value = &*(value as *const $crate::glib::Value as *const $crate::glib::gobject_ffi::GValue); let ptr = &value.data[0].v_pointer as *const $crate::glib::ffi::gpointer as *const *const $ffi_name; - assert!(!(*ptr).is_null()); + debug_assert!(!(*ptr).is_null()); &*(ptr as *const $name) } } diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index 5ae3d5c25..6fabb7af9 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -33,7 +33,7 @@ impl FromGlib for PadProbeId { #[inline] unsafe fn from_glib(val: libc::c_ulong) -> PadProbeId { skip_assert_initialized!(); - assert_ne!(val, 0); + debug_assert_ne!(val, 0); PadProbeId(NonZeroU64::new_unchecked(val as _)) } } @@ -1364,7 +1364,7 @@ where { let func: &F = &*((*pad).getrangedata as *const F); - assert!(!buffer.is_null()); + debug_assert!(!buffer.is_null()); let pad = Pad::from_glib_borrow(pad); let pad = pad.unsafe_cast_ref(); @@ -1639,7 +1639,7 @@ impl + IsA + glib::object::IsClass> PadBuilder { unsafe { let res = ffi::gst_ghost_pad_construct(pad.to_glib_none().0); // This can't really fail... - assert_ne!(res, glib::ffi::GFALSE, "Failed to construct ghost pad"); + debug_assert_ne!(res, glib::ffi::GFALSE, "Failed to construct ghost pad"); } } @@ -1647,7 +1647,7 @@ impl + IsA + glib::object::IsClass> PadBuilder { } pub fn from_static_template(templ: &StaticPadTemplate, name: Option<&str>) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let templ = templ.get(); Self::from_template(&templ, name) @@ -1691,7 +1691,7 @@ impl + IsA + glib::object::IsClass> PadBuilder { unsafe { let res = ffi::gst_ghost_pad_construct(pad.to_glib_none().0); // This can't really fail... - assert_ne!(res, glib::ffi::GFALSE, "Failed to construct ghost pad"); + debug_assert_ne!(res, glib::ffi::GFALSE, "Failed to construct ghost pad"); } } diff --git a/gstreamer/src/pad_template.rs b/gstreamer/src/pad_template.rs index dad95e34c..308c7b13c 100644 --- a/gstreamer/src/pad_template.rs +++ b/gstreamer/src/pad_template.rs @@ -12,7 +12,7 @@ impl PadTemplate { pad_template: &StaticPadTemplate, pad_type: glib::types::Type, ) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { Option::<_>::from_glib_none( ffi::gst_pad_template_new_from_static_pad_template_with_gtype( @@ -83,7 +83,7 @@ impl PadTemplate { presence: PadPresence, caps: &'a Caps, ) -> PadTemplateBuilder<'a> { - assert_initialized_main_thread!(); + skip_assert_initialized!(); PadTemplateBuilder { name_template, diff --git a/gstreamer/src/param_spec.rs b/gstreamer/src/param_spec.rs index a79774eb7..b54b8f05b 100644 --- a/gstreamer/src/param_spec.rs +++ b/gstreamer/src/param_spec.rs @@ -127,7 +127,7 @@ pub struct ParamSpecFractionBuilder<'a> { impl<'a> ParamSpecFractionBuilder<'a> { fn new(name: &'a str) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Self { name, ..Default::default() @@ -292,7 +292,7 @@ pub struct ParamSpecArrayBuilder<'a> { impl<'a> ParamSpecArrayBuilder<'a> { fn new(name: &'a str) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Self { name, ..Default::default() diff --git a/gstreamer/src/query.rs b/gstreamer/src/query.rs index fb59e7010..ed6b9438f 100644 --- a/gstreamer/src/query.rs +++ b/gstreamer/src/query.rs @@ -274,7 +274,7 @@ macro_rules! declare_concrete_query( impl DerefMut for $name { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { - assert!(self.0.is_writable()); + debug_assert!(self.0.is_writable()); unsafe { &mut *(self.0.as_mut_ptr() as *mut Self::Target) } } } @@ -931,7 +931,7 @@ declare_concrete_query!(Custom, T); impl Custom { #[doc(alias = "gst_query_new_custom")] pub fn new(structure: crate::Structure) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { Self(from_glib_full(ffi::gst_query_new_custom( ffi::GST_QUERY_CUSTOM, @@ -1020,7 +1020,7 @@ declare_concrete_query!(Allocation, T); impl Allocation { #[doc(alias = "gst_query_new_allocation")] pub fn new(caps: &crate::Caps, need_pool: bool) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { Self(from_glib_full(ffi::gst_query_new_allocation( caps.as_mut_ptr(), @@ -1386,7 +1386,7 @@ declare_concrete_query!(AcceptCaps, T); impl AcceptCaps { #[doc(alias = "gst_query_new_accept_caps")] pub fn new(caps: &crate::Caps) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { Self(from_glib_full(ffi::gst_query_new_accept_caps( caps.as_mut_ptr(), @@ -1434,7 +1434,7 @@ declare_concrete_query!(Caps, T); impl Caps { #[doc(alias = "gst_query_new_caps")] pub fn new(filter: Option<&crate::Caps>) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { Self(from_glib_full(ffi::gst_query_new_caps( filter.to_glib_none().0, diff --git a/gstreamer/src/sample.rs b/gstreamer/src/sample.rs index c4e62515c..66fe2c5e4 100644 --- a/gstreamer/src/sample.rs +++ b/gstreamer/src/sample.rs @@ -63,8 +63,6 @@ impl<'a> SampleBuilder<'a> { #[must_use = "Building the sample without using it has no effect"] pub fn build(self) -> Sample { - assert_initialized_main_thread!(); - unsafe { let info = self .info @@ -92,6 +90,8 @@ impl<'a> SampleBuilder<'a> { impl Sample { pub fn builder<'a>() -> SampleBuilder<'a> { + assert_initialized_main_thread!(); + SampleBuilder { buffer: None, buffer_list: None, diff --git a/gstreamer/src/segment.rs b/gstreamer/src/segment.rs index eb2378fdc..4369dab65 100644 --- a/gstreamer/src/segment.rs +++ b/gstreamer/src/segment.rs @@ -156,7 +156,6 @@ impl FormattedSegment { stop_type: SeekType, stop: impl CompatibleFormattedValue, ) -> Option { - skip_assert_initialized!(); let start = start.try_into_checked_explicit(self.format()).unwrap(); let stop = stop.try_into_checked_explicit(self.format()).unwrap(); diff --git a/gstreamer/src/static_caps.rs b/gstreamer/src/static_caps.rs index a3262df5f..7919fb7a7 100644 --- a/gstreamer/src/static_caps.rs +++ b/gstreamer/src/static_caps.rs @@ -124,7 +124,7 @@ impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstStaticCaps> for StaticCap impl glib::translate::FromGlibPtrNone<*const ffi::GstStaticCaps> for StaticCaps { #[inline] unsafe fn from_glib_none(ptr: *const ffi::GstStaticCaps) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); StaticCaps(ptr::NonNull::new_unchecked(ptr as *mut _)) } } @@ -133,7 +133,7 @@ impl glib::translate::FromGlibPtrNone<*const ffi::GstStaticCaps> for StaticCaps impl glib::translate::FromGlibPtrNone<*mut ffi::GstStaticCaps> for StaticCaps { #[inline] unsafe fn from_glib_none(ptr: *mut ffi::GstStaticCaps) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); StaticCaps(ptr::NonNull::new_unchecked(ptr)) } } @@ -142,7 +142,7 @@ impl glib::translate::FromGlibPtrNone<*mut ffi::GstStaticCaps> for StaticCaps { impl glib::translate::FromGlibPtrBorrow<*mut ffi::GstStaticCaps> for StaticCaps { #[inline] unsafe fn from_glib_borrow(ptr: *mut ffi::GstStaticCaps) -> Borrowed { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); Borrowed::new(StaticCaps(ptr::NonNull::new_unchecked(ptr))) } } diff --git a/gstreamer/src/static_pad_template.rs b/gstreamer/src/static_pad_template.rs index 9db74f931..561f3f831 100644 --- a/gstreamer/src/static_pad_template.rs +++ b/gstreamer/src/static_pad_template.rs @@ -160,7 +160,7 @@ impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstStaticPadTemplate> for St impl glib::translate::FromGlibPtrNone<*const ffi::GstStaticPadTemplate> for StaticPadTemplate { #[inline] unsafe fn from_glib_none(ptr: *const ffi::GstStaticPadTemplate) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); StaticPadTemplate(ptr::NonNull::new_unchecked(ptr as *mut _)) } } @@ -169,7 +169,7 @@ impl glib::translate::FromGlibPtrNone<*const ffi::GstStaticPadTemplate> for Stat impl glib::translate::FromGlibPtrNone<*mut ffi::GstStaticPadTemplate> for StaticPadTemplate { #[inline] unsafe fn from_glib_none(ptr: *mut ffi::GstStaticPadTemplate) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); StaticPadTemplate(ptr::NonNull::new_unchecked(ptr)) } } @@ -178,7 +178,7 @@ impl glib::translate::FromGlibPtrNone<*mut ffi::GstStaticPadTemplate> for Static impl glib::translate::FromGlibPtrBorrow<*mut ffi::GstStaticPadTemplate> for StaticPadTemplate { #[inline] unsafe fn from_glib_borrow(ptr: *mut ffi::GstStaticPadTemplate) -> Borrowed { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); Borrowed::new(StaticPadTemplate(ptr::NonNull::new_unchecked(ptr))) } } diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index 489c34c66..4deaac5bc 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -51,7 +51,7 @@ unsafe impl Sync for Structure {} impl Structure { #[doc(alias = "gst_structure_new")] pub fn builder(name: &str) -> Builder { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Builder::new(name) } @@ -60,14 +60,14 @@ impl Structure { assert_initialized_main_thread!(); unsafe { let ptr = ffi::gst_structure_new_empty(name.to_glib_none().0); - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr)) } } #[doc(alias = "gst_structure_new")] pub fn new(name: &str, values: &[(&str, &(dyn ToSendValue + Sync))]) -> Structure { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let mut structure = Structure::new_empty(name); for &(f, v) in values { @@ -82,7 +82,7 @@ impl Structure { name: &str, iter: impl IntoIterator, ) -> Structure { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let mut structure = Structure::new_empty(name); iter.into_iter() @@ -135,7 +135,7 @@ impl Clone for Structure { fn clone(&self) -> Self { unsafe { let ptr = ffi::gst_structure_copy(self.0.as_ref()); - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr)) } } @@ -219,7 +219,7 @@ impl ToOwned for StructureRef { fn to_owned(&self) -> Structure { unsafe { let ptr = ffi::gst_structure_copy(&self.0); - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr)) } } @@ -277,9 +277,9 @@ impl<'a> ToGlibPtrMut<'a, *mut ffi::GstStructure> for Structure { impl FromGlibPtrNone<*const ffi::GstStructure> for Structure { #[inline] unsafe fn from_glib_none(ptr: *const ffi::GstStructure) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); let ptr = ffi::gst_structure_copy(ptr); - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr)) } } @@ -287,9 +287,9 @@ impl FromGlibPtrNone<*const ffi::GstStructure> for Structure { impl FromGlibPtrNone<*mut ffi::GstStructure> for Structure { #[inline] unsafe fn from_glib_none(ptr: *mut ffi::GstStructure) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); let ptr = ffi::gst_structure_copy(ptr); - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr)) } } @@ -297,7 +297,7 @@ impl FromGlibPtrNone<*mut ffi::GstStructure> for Structure { impl FromGlibPtrFull<*const ffi::GstStructure> for Structure { #[inline] unsafe fn from_glib_full(ptr: *const ffi::GstStructure) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr as *mut ffi::GstStructure)) } } @@ -305,7 +305,7 @@ impl FromGlibPtrFull<*const ffi::GstStructure> for Structure { impl FromGlibPtrFull<*mut ffi::GstStructure> for Structure { #[inline] unsafe fn from_glib_full(ptr: *mut ffi::GstStructure) -> Self { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); Structure(ptr::NonNull::new_unchecked(ptr)) } } @@ -404,14 +404,14 @@ unsafe impl Sync for StructureRef {} impl StructureRef { #[inline] pub unsafe fn from_glib_borrow<'a>(ptr: *const ffi::GstStructure) -> &'a StructureRef { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); &*(ptr as *mut StructureRef) } #[inline] pub unsafe fn from_glib_borrow_mut<'a>(ptr: *mut ffi::GstStructure) -> &'a mut StructureRef { - assert!(!ptr.is_null()); + debug_assert!(!ptr.is_null()); &mut *(ptr as *mut StructureRef) } @@ -631,7 +631,7 @@ impl StructureRef { unsafe { let field_name = ffi::gst_structure_nth_field_name(&self.0, idx); - assert!(!field_name.is_null()); + debug_assert!(!field_name.is_null()); Some(CStr::from_ptr(field_name).to_str().unwrap()) } diff --git a/gstreamer/src/tags.rs b/gstreamer/src/tags.rs index 94b71d344..78c8ac408 100644 --- a/gstreamer/src/tags.rs +++ b/gstreamer/src/tags.rs @@ -465,7 +465,7 @@ impl TagListRef { unsafe { let name = ffi::gst_tag_list_nth_tag_name(self.as_ptr(), idx); - assert!(!name.is_null()); + debug_assert!(!name.is_null()); Some(CStr::from_ptr(name).to_str().unwrap()) } } diff --git a/gstreamer/src/task_pool.rs b/gstreamer/src/task_pool.rs index 274596076..4edeb8f79 100644 --- a/gstreamer/src/task_pool.rs +++ b/gstreamer/src/task_pool.rs @@ -37,7 +37,7 @@ impl> TaskPoolExtManual for O { ); if !error.is_null() { - assert!(handle.is_null()); + debug_assert!(handle.is_null()); // Assume that task_pool_trampoline was // not called and will not be called diff --git a/gstreamer/src/tracer.rs b/gstreamer/src/tracer.rs index cd2bd9edf..2df9cd293 100644 --- a/gstreamer/src/tracer.rs +++ b/gstreamer/src/tracer.rs @@ -11,7 +11,7 @@ impl Tracer { name: &str, type_: glib::types::Type, ) -> Result<(), glib::error::BoolError> { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { glib::result_from_gboolean!( ffi::gst_tracer_register( diff --git a/gstreamer/src/typefind.rs b/gstreamer/src/typefind.rs index bdbd2aeaa..d578d17ff 100644 --- a/gstreamer/src/typefind.rs +++ b/gstreamer/src/typefind.rs @@ -33,7 +33,7 @@ impl TypeFind { where F: Fn(&mut TypeFind) + Send + Sync + 'static, { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let func: Box = Box::new(func); let func = Box::into_raw(func); diff --git a/gstreamer/src/value.rs b/gstreamer/src/value.rs index 8bf9598a8..a4f187eb4 100644 --- a/gstreamer/src/value.rs +++ b/gstreamer/src/value.rs @@ -11,17 +11,17 @@ pub struct Fraction(pub Rational32); impl Fraction { #[inline] pub fn new(num: i32, den: i32) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); (num, den).into() } pub fn approximate_f32(x: f32) -> Option { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Rational32::approximate_float(x).map(|r| r.into()) } pub fn approximate_f64(x: f64) -> Option { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Rational32::approximate_float(x).map(|r| r.into()) } @@ -232,7 +232,7 @@ impl ops::Neg for &Fraction { impl From for Fraction { #[inline] fn from(x: i32) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Fraction(x.into()) } } @@ -240,7 +240,7 @@ impl From for Fraction { impl From<(i32, i32)> for Fraction { #[inline] fn from(x: (i32, i32)) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Fraction(x.into()) } } @@ -256,7 +256,7 @@ impl From for (i32, i32) { impl From for Fraction { #[inline] fn from(x: Rational32) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Fraction(x) } } @@ -357,7 +357,7 @@ impl IntRangeType for i32 { #[inline] fn with_step(min: i32, max: i32, step: i32) -> IntRange { - assert_initialized_main_thread!(); + skip_assert_initialized!(); assert!(min <= max); assert!(step > 0); @@ -375,7 +375,7 @@ impl IntRangeType for i64 { #[inline] fn with_step(min: i64, max: i64, step: i64) -> IntRange { - assert_initialized_main_thread!(); + skip_assert_initialized!(); assert!(min <= max); assert!(step > 0); @@ -387,13 +387,13 @@ impl IntRangeType for i64 { impl IntRange { #[inline] pub fn new(min: T, max: T) -> IntRange { - assert_initialized_main_thread!(); + skip_assert_initialized!(); T::with_min_max(min, max) } #[inline] pub fn with_step(min: T, max: T, step: T) -> IntRange { - assert_initialized_main_thread!(); + skip_assert_initialized!(); T::with_step(min, max, step) } } @@ -548,7 +548,7 @@ pub struct FractionRange { impl FractionRange { #[inline] pub fn new, U: Into>(min: T, max: U) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); let min = min.into(); let max = max.into(); @@ -644,7 +644,7 @@ pub struct Bitmask(pub u64); impl Bitmask { #[inline] pub fn new(v: u64) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Bitmask(v) } } @@ -783,7 +783,7 @@ impl Array { } pub fn from_values(values: impl IntoIterator) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Self::new(values) } @@ -817,7 +817,7 @@ impl Array { impl Default for Array { fn default() -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let value = glib::Value::for_value_type::(); @@ -845,7 +845,7 @@ impl AsRef<[glib::SendValue]> for Array { impl std::iter::FromIterator for Array { fn from_iter>(iter: T) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Self::from_values(iter) } } @@ -903,7 +903,7 @@ unsafe impl<'a> Sync for ArrayRef<'a> {} impl<'a> ArrayRef<'a> { pub fn new(values: &'a [glib::SendValue]) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Self(values) } @@ -1010,7 +1010,7 @@ impl List { } pub fn from_values(values: impl IntoIterator) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Self::new(values) } @@ -1044,7 +1044,7 @@ impl List { impl Default for List { fn default() -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let value = glib::Value::for_value_type::(); @@ -1072,7 +1072,7 @@ impl AsRef<[glib::SendValue]> for List { impl std::iter::FromIterator for List { fn from_iter>(iter: T) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Self::from_values(iter) } } @@ -1130,7 +1130,7 @@ unsafe impl<'a> Sync for ListRef<'a> {} impl<'a> ListRef<'a> { pub fn new(values: &'a [glib::SendValue]) -> Self { - assert_initialized_main_thread!(); + skip_assert_initialized!(); Self(values) } @@ -1384,7 +1384,7 @@ impl GstValueExt for glib::Value { } fn deserialize(s: &str, type_: glib::Type) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let mut value = glib::Value::from_type(type_); @@ -1406,7 +1406,7 @@ impl GstValueExt for glib::Value { s: &str, pspec: &glib::ParamSpec, ) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); unsafe { let mut value = glib::Value::from_type_unchecked(pspec.value_type());