diff --git a/gstreamer/src/subclass/buffer_pool.rs b/gstreamer/src/subclass/buffer_pool.rs index 9fbd34933..9654ff5c9 100644 --- a/gstreamer/src/subclass/buffer_pool.rs +++ b/gstreamer/src/subclass/buffer_pool.rs @@ -7,6 +7,7 @@ use glib::{ Cast, StaticType, }; use libc::c_char; +use std::ptr; use crate::{BufferPool, BufferPoolAcquireParams, BufferPoolConfigRef}; @@ -278,17 +279,6 @@ impl BufferPoolImplExt for T { } } -// Send+Sync wrapper around a NULL-terminated C string array -struct CStrV(*mut *const libc::c_char); -unsafe impl Send for CStrV {} -unsafe impl Sync for CStrV {} - -impl Drop for CStrV { - fn drop(&mut self) { - unsafe { glib::ffi::g_strfreev(self.0 as *mut _) }; - } -} - unsafe impl IsSubclassable for BufferPool { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); @@ -312,8 +302,7 @@ unsafe impl IsSubclassable for BufferPool { // Store the pool options in the instance data // for later retrieval in buffer_pool_get_options let options = T::options(); - let options = options.to_glib_full(); - instance.set_instance_data(T::type_(), CStrV(options)); + instance.set_instance_data(T::type_(), glib::StrV::from(options)); } } @@ -468,9 +457,9 @@ unsafe extern "C" fn buffer_pool_get_options( ) -> *mut *const c_char { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); - T::instance_data::(imp, T::type_()) - .unwrap_or(&CStrV(std::ptr::null_mut())) - .0 + T::instance_data::(imp, T::type_()) + .map(|p| p.as_ptr() as *mut *const _) + .unwrap_or(ptr::null_mut()) } unsafe extern "C" fn buffer_pool_set_config( diff --git a/gstreamer/src/subclass/uri_handler.rs b/gstreamer/src/subclass/uri_handler.rs index eaef267cd..ccfa87e70 100644 --- a/gstreamer/src/subclass/uri_handler.rs +++ b/gstreamer/src/subclass/uri_handler.rs @@ -78,11 +78,6 @@ impl URIHandlerImplExt for T { } } -// Send+Sync wrapper around a NULL-terminated C string array -struct CStrV(*const *const libc::c_char); -unsafe impl Send for CStrV {} -unsafe impl Sync for CStrV {} - unsafe impl IsImplementable for URIHandler { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); @@ -91,10 +86,8 @@ unsafe impl IsImplementable for URIHandler { unsafe { let mut data = T::type_data(); let protocols = T::protocols(); - let protocols = protocols.to_glib_full(); let data = data.as_mut(); - - data.set_class_data(Self::static_type(), CStrV(protocols)); + data.set_class_data(Self::static_type(), glib::StrV::from(protocols)); } iface.get_type = Some(uri_handler_get_type::); @@ -115,9 +108,9 @@ unsafe extern "C" fn uri_handler_get_protocols( ) -> *const *const libc::c_char { let data = ::type_data(); data.as_ref() - .class_data::(URIHandler::static_type()) - .unwrap_or(&CStrV(std::ptr::null())) - .0 + .class_data::(URIHandler::static_type()) + .map(|p| p.as_ptr() as *const *const _) + .unwrap_or(ptr::null()) } unsafe extern "C" fn uri_handler_get_uri(