[vlc-commits] avio output: flush after writes

Rafaël Carré git at videolan.org
Mon Mar 5 05:57:09 CET 2012


vlc/vlc-2.0 | branch: master | Rafaël Carré <funman at videolan.org> | Tue Jan 31 19:40:38 2012 -0500| [1edbccb9edafb2faa8d2f6d860ea10d12568cea1] | committer: Rafaël Carré

avio output: flush after writes

detect errors and abort writing if they happen
(cherry picked from commit acf912ad543fd1a26a186bd5765c59c50955c0bb)

Signed-off-by: Rafaël Carré <funman at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=1edbccb9edafb2faa8d2f6d860ea10d12568cea1
---

 modules/access/avio.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/modules/access/avio.c b/modules/access/avio.c
index 7a17142..ddfe86f 100644
--- a/modules/access/avio.c
+++ b/modules/access/avio.c
@@ -293,13 +293,23 @@ static ssize_t Write(sout_access_out_t *p_access, block_t *p_buffer)
     size_t i_write = 0;
 
     while (p_buffer != NULL) {
-        block_t *p_next = p_buffer->p_next;;
+        block_t *p_next = p_buffer->p_next;
 
 #if LIBAVFORMAT_VERSION_MAJOR < 54
-        i_write += url_write(p_sys->context, p_buffer->p_buffer, p_buffer->i_buffer);
+        int written = url_write(p_sys->context, p_buffer->p_buffer, p_buffer->i_buffer);
+        if (written < 0) {
+            errno = AVUNERROR(written);
+            goto error;
+        }
+        i_write += written;
 #else
-        /* FIXME : how are errors notified ?? */
         avio_write(p_sys->context, p_buffer->p_buffer, p_buffer->i_buffer);
+        avio_flush(p_sys->context);
+        if (p_sys->context->error) {
+            errno = AVUNERROR(p_sys->context->error);
+            p_sys->context->error = 0; /* FIXME? */
+            goto error;
+        }
         i_write += p_buffer->i_buffer;
 #endif
 
@@ -309,6 +319,11 @@ static ssize_t Write(sout_access_out_t *p_access, block_t *p_buffer)
     }
 
     return i_write;
+
+error:
+    msg_Err(p_access, "Wrote only %zu bytes (%m)", i_write);
+    block_ChainRelease( p_buffer );
+    return i_write;
 }
 
 static int Seek(access_t *access, uint64_t position)



More information about the vlc-commits mailing list