Buffer: fix instanstiation during deserialization

This commit is contained in:
François Laignel 2018-07-16 21:57:17 +02:00 committed by Sebastian Dröge
parent 90b046fbcf
commit 693121bc55

View file

@ -50,12 +50,8 @@ struct BufferDe {
} }
impl From<BufferDe> for Buffer { impl From<BufferDe> for Buffer {
fn from(mut buf_de: BufferDe) -> Self { fn from(buf_de: BufferDe) -> Self {
// Move the `ByteBuff`'s byte array into the `gst::Buffer` let mut buffer = Buffer::from_mut_slice(buf_de.buffer.to_vec()).unwrap();
// Are we really avoiding copies with that?
let drained_buffer: &mut Vec<u8> = buf_de.buffer.as_mut();
let mut buffer =
Buffer::from_slice(drained_buffer.drain(..).collect::<Vec<u8>>()).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(buf_de.pts); buffer.set_pts(buf_de.pts);