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/1220>
This commit is contained in:
Sebastian Dröge 2023-02-13 14:27:10 +02:00
parent 6cb469934d
commit 2354cd6c4f

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]