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 {
fn from(mut buf_de: BufferDe) -> Self {
// Move the `ByteBuff`'s byte array into the `gst::Buffer`
// 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();
fn from(buf_de: BufferDe) -> Self {
let mut buffer = Buffer::from_mut_slice(buf_de.buffer.to_vec()).unwrap();
{
let buffer = buffer.get_mut().unwrap();
buffer.set_pts(buf_de.pts);
@ -228,4 +224,4 @@ mod tests {
assert_eq!(data.as_slice(), vec![1, 2, 3, 4].as_slice());
}
}
}
}