diff mbox series

[FFmpeg-devel,v2] avcodec/v4l2_context: suppress POLLERR when buffers are uninitialized

Message ID 20230725213838.199190-2-mailingradian@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2] avcodec/v4l2_context: suppress POLLERR when buffers are uninitialized | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Richard Acayan July 25, 2023, 9:38 p.m. UTC
A POLLERR occurs when libavcodec attempts to dequeue output buffers
before enqueuing capture buffers. This could happen to an application
deciding to send the first coded packet. Suppress these POLLERRs when
the buffers are uninitialized.

See https://trac.ffmpeg.org/ticket/9957 for the original bug report.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
---
Changes since v1 (20230718220017.3336-1-mailingradian@gmail.com):
 - stopped emitting POLLERR logs for this case (thanks to feedback from
   Marton Balint)

 libavcodec/v4l2_context.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Marton Balint July 27, 2023, 7:18 p.m. UTC | #1
On Tue, 25 Jul 2023, Richard Acayan wrote:

> A POLLERR occurs when libavcodec attempts to dequeue output buffers
> before enqueuing capture buffers. This could happen to an application
> deciding to send the first coded packet. Suppress these POLLERRs when
> the buffers are uninitialized.

Will apply, thanks.

Marton

>
> See https://trac.ffmpeg.org/ticket/9957 for the original bug report.
>
> Signed-off-by: Richard Acayan <mailingradian@gmail.com>
> ---
> Changes since v1 (20230718220017.3336-1-mailingradian@gmail.com):
> - stopped emitting POLLERR logs for this case (thanks to feedback from
>   Marton Balint)
>
> libavcodec/v4l2_context.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
> index a40be94690..f20f713e1d 100644
> --- a/libavcodec/v4l2_context.c
> +++ b/libavcodec/v4l2_context.c
> @@ -325,9 +325,13 @@ start:
>
>     /* 0. handle errors */
>     if (pfd.revents & POLLERR) {
> -        /* if we are trying to get free buffers but none have been queued yet
> -           no need to raise a warning */
> +        /* if we are trying to get free buffers but none have been queued yet,
> +         * or if no buffers have been allocated yet, no need to raise a warning
> +         */
>         if (timeout == 0) {
> +            if (!ctx->buffers)
> +                return NULL;
> +
>             for (i = 0; i < ctx->num_buffers; i++) {
>                 if (ctx->buffers[i].status != V4L2BUF_AVAILABLE)
>                     av_log(logger(ctx), AV_LOG_WARNING, "%s POLLERR\n", ctx->name);
> -- 
> 2.41.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
diff mbox series

Patch

diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index a40be94690..f20f713e1d 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -325,9 +325,13 @@  start:
 
     /* 0. handle errors */
     if (pfd.revents & POLLERR) {
-        /* if we are trying to get free buffers but none have been queued yet
-           no need to raise a warning */
+        /* if we are trying to get free buffers but none have been queued yet,
+         * or if no buffers have been allocated yet, no need to raise a warning
+         */
         if (timeout == 0) {
+            if (!ctx->buffers)
+                return NULL;
+
             for (i = 0; i < ctx->num_buffers; i++) {
                 if (ctx->buffers[i].status != V4L2BUF_AVAILABLE)
                     av_log(logger(ctx), AV_LOG_WARNING, "%s POLLERR\n", ctx->name);