]> git.sesse.net Git - vlc/blobdiff - modules/access/avio.c
mmdevice: fix crash if several channel volumes change (fixes #12086)
[vlc] / modules / access / avio.c
index 47dc34a9e8156aaf4df585b89929295c4853ffe6..47615e6d939ddded86fc24ea7cddc28b1228532b 100644 (file)
@@ -140,7 +140,7 @@ int OpenAvio(vlc_object_t *object)
     }
 
     /* */
-    vlc_init_avformat();
+    vlc_init_avformat(object);
 
     int ret;
 #if LIBAVFORMAT_VERSION_MAJOR < 54
@@ -163,8 +163,8 @@ int OpenAvio(vlc_object_t *object)
     av_dict_free(&options);
 #endif
     if (ret < 0) {
-        errno = AVUNERROR(ret);
-        msg_Err(access, "Failed to open %s: %m", url);
+        msg_Err(access, "Failed to open %s: %s", url,
+                vlc_strerror_c(AVUNERROR(ret)));
         free(url);
         goto error;
     }
@@ -224,7 +224,7 @@ int OutOpenAvio(vlc_object_t *object)
     sys->context = NULL;
 
     /* */
-    vlc_init_avformat();
+    vlc_init_avformat(object);
 
     if (!access->psz_path)
         goto error;
@@ -307,8 +307,10 @@ static ssize_t Read(access_t *access, uint8_t *data, size_t size)
     int r = avio_read(access->p_sys->context, data, size);
     if (r > 0)
         access->info.i_pos += r;
-    else
+    else {
         access->info.b_eof = true;
+        r = 0;
+    }
     return r;
 }
 
@@ -317,24 +319,22 @@ static ssize_t Read(access_t *access, uint8_t *data, size_t size)
  *****************************************************************************/
 static ssize_t Write(sout_access_out_t *p_access, block_t *p_buffer)
 {
-    access_sys_t *p_sys = (access_sys_t*)p_access->p_sys;
+    sout_access_out_sys_t *p_sys = (sout_access_out_sys_t*)p_access->p_sys;
     size_t i_write = 0;
+    int val;
 
     while (p_buffer != NULL) {
         block_t *p_next = p_buffer->p_next;
 
 #if LIBAVFORMAT_VERSION_MAJOR < 54
-        int written = url_write(p_sys->context, p_buffer->p_buffer, p_buffer->i_buffer);
-        if (written < 0) {
-            errno = AVUNERROR(written);
+        val = url_write(p_sys->context, p_buffer->p_buffer, p_buffer->i_buffer);
+        if (val < 0)
             goto error;
-        }
-        i_write += written;
+        i_write += val;
 #else
         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);
+        if ((val = p_sys->context->error) != 0) {
             p_sys->context->error = 0; /* FIXME? */
             goto error;
         }
@@ -349,7 +349,8 @@ 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);
+    msg_Err(p_access, "Wrote only %zu bytes: %s", i_write,
+            vlc_strerror_c(AVUNERROR(val)));
     block_ChainRelease( p_buffer );
     return i_write;
 }
@@ -368,8 +369,8 @@ static int Seek(access_t *access, uint64_t position)
     else
         ret = avio_seek(sys->context, position, SEEK_SET);
     if (ret < 0) {
-        errno = AVUNERROR(ret);
-        msg_Err(access, "Seek to %"PRIu64" failed: %m", position);
+        msg_Err(access, "Seek to %"PRIu64" failed: %s", position,
+                vlc_strerror_c(AVUNERROR(ret)));
         if (sys->size == 0 || position != sys->size)
             return VLC_EGENERIC;
     }
@@ -438,7 +439,7 @@ static int Control(access_t *access, int query, va_list args)
         return VLC_SUCCESS;
     case ACCESS_GET_PTS_DELAY: {
         int64_t *delay = va_arg(args, int64_t *);
-        *delay = DEFAULT_PTS_DELAY; /* FIXME */
+        *delay = INT64_C(1000) * var_InheritInteger(access, "network-caching");
         return VLC_SUCCESS;
     }
     case ACCESS_SET_PAUSE_STATE: {