diff mbox series

[FFmpeg-devel,v2] lavf/async: Fix ring_write return value

Message ID 20220929181134.93922-1-gsun@roblox.com
State Accepted
Commit fc6f7e2a3b2fff6c4df957684d939586a3de448f
Headers show
Series [FFmpeg-devel,v2] lavf/async: Fix ring_write return value | expand

Commit Message

Guangyu Sun Sept. 29, 2022, 6:11 p.m. UTC
his fixes a regression from commit 36117968ad.

wrapped_url_read() used to be able to return positive number from
ffurl_read(). It relies on the result to check if EOF is reached in
async_buffer_task().

But FIFO callbacks must return 0 on success. This should be handled
in ring_write() instead.

Test case:
  ffmpeg -f lavfi -i testsrc -t 1 test.mp4
  ffmpeg -i async:test.mp4

Signed-off-by: Guangyu Sun <gsun@roblox.com>
---
 libavformat/async.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Anton Khirnov Oct. 13, 2022, 2:55 p.m. UTC | #1
Quoting Guangyu Sun (2022-09-29 20:11:34)
> his fixes a regression from commit 36117968ad.
> 
> wrapped_url_read() used to be able to return positive number from
> ffurl_read(). It relies on the result to check if EOF is reached in
> async_buffer_task().
> 
> But FIFO callbacks must return 0 on success. This should be handled
> in ring_write() instead.
> 
> Test case:
>   ffmpeg -f lavfi -i testsrc -t 1 test.mp4
>   ffmpeg -i async:test.mp4
> 
> Signed-off-by: Guangyu Sun <gsun@roblox.com>
> ---
>  libavformat/async.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

Thank you, will push.
diff mbox series

Patch

diff --git a/libavformat/async.c b/libavformat/async.c
index 547417aa1e..3c6f89cab9 100644
--- a/libavformat/async.c
+++ b/libavformat/async.c
@@ -144,8 +144,14 @@  static int wrapped_url_read(void *src, void *dst, size_t *size)
 
 static int ring_write(RingBuffer *ring, URLContext *h, size_t size)
 {
+    int ret;
+
     av_assert2(size <= ring_space(ring));
-    return av_fifo_write_from_cb(ring->fifo, wrapped_url_read, h, &size);
+    ret = av_fifo_write_from_cb(ring->fifo, wrapped_url_read, h, &size);
+    if (ret < 0)
+        return ret;
+
+    return size;
 }
 
 static int ring_size_of_read_back(RingBuffer *ring)