audio: Don't forget to unmap the AudioBuffer and drop the Box when converting into a gst::Buffer

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1219>
This commit is contained in:
Sebastian Dröge 2023-02-13 14:27:10 +02:00
parent 60ad9b5038
commit 2ac85cd8de

View file

@ -37,7 +37,14 @@ impl<T> AudioBuffer<T> {
#[inline]
pub fn into_buffer(self) -> gst::Buffer {
unsafe { ptr::read(&mem::ManuallyDrop::new(self).buffer) }
unsafe {
let mut s = mem::ManuallyDrop::new(self);
let buffer = ptr::read(&s.buffer);
ffi::gst_audio_buffer_unmap(&mut *s.audio_buffer);
ptr::drop_in_place(&mut s.audio_buffer);
buffer
}
}
#[inline]