fix: enable buffering for the writer

This commit is contained in:
meh
2021-03-21 12:47:40 +01:00
parent 73dd26fa1c
commit 4a855c053e
+8 -3
View File
@@ -172,10 +172,11 @@ impl Io {
pub fn output(value: impl Write + 'static) -> Self {
unsafe {
let proxy = Box::into_raw(Box::new(Proxy::Output(Box::new(value))));
let buffer = av_malloc(4096);
let ptr = avio_alloc_context(
ptr::null_mut(),
0,
AVIO_FLAG_WRITE & AVIO_FLAG_DIRECT,
buffer.cast(),
4096,
AVIO_FLAG_WRITE,
proxy.cast(),
None,
Some(write_packet),
@@ -190,6 +191,10 @@ impl Io {
impl Drop for Io {
fn drop(&mut self) {
unsafe {
if !(*self.ptr).buffer.is_null() {
av_free((*self.ptr).buffer.cast());
}
avio_context_free(&mut self.ptr);
Box::from_raw(self.proxy);
}