diff mbox series

[FFmpeg-devel] avcodec/audiotoolboxenc: return error value if encode failed

Message ID 20220624030217.12985-1-lq@chinaffmpeg.org
State New
Headers show
Series [FFmpeg-devel] avcodec/audiotoolboxenc: return error value if encode failed | 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
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Liu Steven June 24, 2022, 3:02 a.m. UTC
because the AudioConverterFillComplexBuffer can return 0 or 1 if
success.
so set the ret to 0 it AudioConverterFillComplexBuffer success and
return ret value for success or failed.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavcodec/audiotoolboxenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Zhao Zhili June 24, 2022, 5:03 a.m. UTC | #1
> On Jun 24, 2022, at 11:02 AM, Steven Liu <lq@chinaffmpeg.org> wrote:
> 
> because the AudioConverterFillComplexBuffer can return 0 or 1 if
> success.
> so set the ret to 0 it AudioConverterFillComplexBuffer success and
> return ret value for success or failed.
> 
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
> libavcodec/audiotoolboxenc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
> index f8305ab89b..50369f4f00 100644
> --- a/libavcodec/audiotoolboxenc.c
> +++ b/libavcodec/audiotoolboxenc.c
> @@ -554,11 +554,12 @@ static int ffat_encode(AVCodecContext *avctx, AVPacket *avpkt,
>                                      avctx->frame_size,
>                            &avpkt->pts,
>                            &avpkt->duration);
> +        ret = 0;
>     } else if (ret && ret != 1) {
>         av_log(avctx, AV_LOG_WARNING, "Encode error: %i\n", ret);

ret comes from AudioConverterFillComplexBuffer, which is defined by
macOS/iOS and isn’t the same as errno.h, so it should not be returned
directly.

Remap ret from `kAudioConverterErr_xxx` to AVERROR, or just return
AVERROR_EXTERNAL.

Since now the error code is treated as error, the log level should
be changed to AV_LOG_ERROR.

>     }
> 
> -    return 0;
> +    return ret;
> }
> 
> static av_cold void ffat_encode_flush(AVCodecContext *avctx)
> -- 
> 2.25.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".
Steven Liu June 24, 2022, 5:38 a.m. UTC | #2
"zhilizhao(赵志立)" <quinkblack@foxmail.com> 于2022年6月24日周五 13:03写道:
>
>
>
> > On Jun 24, 2022, at 11:02 AM, Steven Liu <lq@chinaffmpeg.org> wrote:
> >
> > because the AudioConverterFillComplexBuffer can return 0 or 1 if
> > success.
> > so set the ret to 0 it AudioConverterFillComplexBuffer success and
> > return ret value for success or failed.
> >
> > Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > ---
> > libavcodec/audiotoolboxenc.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
> > index f8305ab89b..50369f4f00 100644
> > --- a/libavcodec/audiotoolboxenc.c
> > +++ b/libavcodec/audiotoolboxenc.c
> > @@ -554,11 +554,12 @@ static int ffat_encode(AVCodecContext *avctx, AVPacket *avpkt,
> >                                      avctx->frame_size,
> >                            &avpkt->pts,
> >                            &avpkt->duration);
> > +        ret = 0;
> >     } else if (ret && ret != 1) {
> >         av_log(avctx, AV_LOG_WARNING, "Encode error: %i\n", ret);
>
> ret comes from AudioConverterFillComplexBuffer, which is defined by
> macOS/iOS and isn’t the same as errno.h, so it should not be returned
> directly.
>
> Remap ret from `kAudioConverterErr_xxx` to AVERROR, or just return
> AVERROR_EXTERNAL.
>
> Since now the error code is treated as error, the log level should
> be changed to AV_LOG_ERROR.

Good catch, will modify them.
>
> >     }
> >
> > -    return 0;
> > +    return ret;
> > }
> >
> > static av_cold void ffat_encode_flush(AVCodecContext *avctx)
> > --
> > 2.25.0
> >

Thanks
Steven
diff mbox series

Patch

diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index f8305ab89b..50369f4f00 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -554,11 +554,12 @@  static int ffat_encode(AVCodecContext *avctx, AVPacket *avpkt,
                                      avctx->frame_size,
                            &avpkt->pts,
                            &avpkt->duration);
+        ret = 0;
     } else if (ret && ret != 1) {
         av_log(avctx, AV_LOG_WARNING, "Encode error: %i\n", ret);
     }
 
-    return 0;
+    return ret;
 }
 
 static av_cold void ffat_encode_flush(AVCodecContext *avctx)