Some minor buffer changes

This commit is contained in:
Sebastian Dröge 2016-09-17 13:16:53 -04:00
parent 1751b5c400
commit cef8d28974

View file

@ -264,8 +264,11 @@ impl Buffer {
} }
} }
pub fn share(&self) -> Buffer { pub fn copy(&self) -> Buffer {
unsafe { Buffer::new_from_ptr(self.raw) } extern "C" {
fn gst_mini_object_copy(obj: *const c_void) -> *mut c_void;
}
unsafe { Buffer::new_from_ptr_owned(gst_mini_object_copy(self.raw)) }
} }
pub fn append(self, other: Buffer) -> Buffer { pub fn append(self, other: Buffer) -> Buffer {
@ -583,13 +586,16 @@ impl Drop for Buffer {
} }
} }
unsafe impl Sync for Buffer {}
unsafe impl Send for Buffer {}
impl Clone for Buffer { impl Clone for Buffer {
fn clone(&self) -> Buffer { fn clone(&self) -> Buffer {
extern "C" { extern "C" {
fn gst_mini_object_copy(obj: *const c_void) -> *mut c_void; fn gst_mini_object_ref(obj: *mut c_void) -> *mut c_void;
} }
let raw = unsafe { gst_mini_object_copy(self.raw) }; let raw = unsafe { gst_mini_object_ref(self.raw) };
Buffer { Buffer {
raw: raw, raw: raw,
@ -672,6 +678,9 @@ impl Drop for ReadMappedBuffer {
} }
} }
unsafe impl Sync for ReadMappedBuffer {}
unsafe impl Send for ReadMappedBuffer {}
impl ReadWriteMappedBuffer { impl ReadWriteMappedBuffer {
pub fn as_mut_slice(&mut self) -> &mut [u8] { pub fn as_mut_slice(&mut self) -> &mut [u8] {
unsafe { slice::from_raw_parts_mut(self.map_info.data as *mut u8, self.map_info.size) } unsafe { slice::from_raw_parts_mut(self.map_info.data as *mut u8, self.map_info.size) }
@ -702,6 +711,9 @@ impl Drop for ReadWriteMappedBuffer {
} }
} }
unsafe impl Sync for ReadWriteMappedBuffer {}
unsafe impl Send for ReadWriteMappedBuffer {}
#[repr(C)] #[repr(C)]
pub struct ScopedBufferPtr(*mut c_void); pub struct ScopedBufferPtr(*mut c_void);