forked from mirrors/gstreamer-rs
gstreamer: Use glib::StrV
internally instead of a custom version of it
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1180>
This commit is contained in:
parent
81bcf5c8dd
commit
0ed3d95c60
2 changed files with 9 additions and 27 deletions
|
@ -7,6 +7,7 @@ use glib::{
|
||||||
Cast, StaticType,
|
Cast, StaticType,
|
||||||
};
|
};
|
||||||
use libc::c_char;
|
use libc::c_char;
|
||||||
|
use std::ptr;
|
||||||
|
|
||||||
use crate::{BufferPool, BufferPoolAcquireParams, BufferPoolConfigRef};
|
use crate::{BufferPool, BufferPoolAcquireParams, BufferPoolConfigRef};
|
||||||
|
|
||||||
|
@ -278,17 +279,6 @@ impl<T: BufferPoolImpl> 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<T: BufferPoolImpl> IsSubclassable<T> for BufferPool {
|
unsafe impl<T: BufferPoolImpl> IsSubclassable<T> for BufferPool {
|
||||||
fn class_init(klass: &mut glib::Class<Self>) {
|
fn class_init(klass: &mut glib::Class<Self>) {
|
||||||
Self::parent_class_init::<T>(klass);
|
Self::parent_class_init::<T>(klass);
|
||||||
|
@ -312,8 +302,7 @@ unsafe impl<T: BufferPoolImpl> IsSubclassable<T> for BufferPool {
|
||||||
// Store the pool options in the instance data
|
// Store the pool options in the instance data
|
||||||
// for later retrieval in buffer_pool_get_options
|
// for later retrieval in buffer_pool_get_options
|
||||||
let options = T::options();
|
let options = T::options();
|
||||||
let options = options.to_glib_full();
|
instance.set_instance_data(T::type_(), glib::StrV::from(options));
|
||||||
instance.set_instance_data(T::type_(), CStrV(options));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,9 +457,9 @@ unsafe extern "C" fn buffer_pool_get_options<T: BufferPoolImpl>(
|
||||||
) -> *mut *const c_char {
|
) -> *mut *const c_char {
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
T::instance_data::<CStrV>(imp, T::type_())
|
T::instance_data::<glib::StrV>(imp, T::type_())
|
||||||
.unwrap_or(&CStrV(std::ptr::null_mut()))
|
.map(|p| p.as_ptr() as *mut *const _)
|
||||||
.0
|
.unwrap_or(ptr::null_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn buffer_pool_set_config<T: BufferPoolImpl>(
|
unsafe extern "C" fn buffer_pool_set_config<T: BufferPoolImpl>(
|
||||||
|
|
|
@ -78,11 +78,6 @@ impl<T: URIHandlerImpl> 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<T: URIHandlerImpl> IsImplementable<T> for URIHandler {
|
unsafe impl<T: URIHandlerImpl> IsImplementable<T> for URIHandler {
|
||||||
fn interface_init(iface: &mut glib::Interface<Self>) {
|
fn interface_init(iface: &mut glib::Interface<Self>) {
|
||||||
let iface = iface.as_mut();
|
let iface = iface.as_mut();
|
||||||
|
@ -91,10 +86,8 @@ unsafe impl<T: URIHandlerImpl> IsImplementable<T> for URIHandler {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut data = T::type_data();
|
let mut data = T::type_data();
|
||||||
let protocols = T::protocols();
|
let protocols = T::protocols();
|
||||||
let protocols = protocols.to_glib_full();
|
|
||||||
let data = data.as_mut();
|
let data = data.as_mut();
|
||||||
|
data.set_class_data(Self::static_type(), glib::StrV::from(protocols));
|
||||||
data.set_class_data(Self::static_type(), CStrV(protocols));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iface.get_type = Some(uri_handler_get_type::<T>);
|
iface.get_type = Some(uri_handler_get_type::<T>);
|
||||||
|
@ -115,9 +108,9 @@ unsafe extern "C" fn uri_handler_get_protocols<T: URIHandlerImpl>(
|
||||||
) -> *const *const libc::c_char {
|
) -> *const *const libc::c_char {
|
||||||
let data = <T as ObjectSubclassType>::type_data();
|
let data = <T as ObjectSubclassType>::type_data();
|
||||||
data.as_ref()
|
data.as_ref()
|
||||||
.class_data::<CStrV>(URIHandler::static_type())
|
.class_data::<glib::StrV>(URIHandler::static_type())
|
||||||
.unwrap_or(&CStrV(std::ptr::null()))
|
.map(|p| p.as_ptr() as *const *const _)
|
||||||
.0
|
.unwrap_or(ptr::null())
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn uri_handler_get_uri<T: URIHandlerImpl>(
|
unsafe extern "C" fn uri_handler_get_uri<T: URIHandlerImpl>(
|
||||||
|
|
Loading…
Reference in a new issue