diff mbox

[FFmpeg-devel] videotoolbox: log errors

Message ID 20170524134736.22631-1-nfxjfg@googlemail.com
State New
Headers show

Commit Message

wm4 May 24, 2017, 1:47 p.m. UTC
With the new decode API, you can't handle errors directly in the API
user - you only know that the hwaccel did not initialize at all.

Add some approximate logging.
---
 libavcodec/videotoolbox.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

wm4 May 31, 2017, 10:19 a.m. UTC | #1
On Wed, 24 May 2017 15:47:36 +0200
wm4 <nfxjfg@googlemail.com> wrote:

> With the new decode API, you can't handle errors directly in the API
> user - you only know that the hwaccel did not initialize at all.
> 
> Add some approximate logging.
> ---
>  libavcodec/videotoolbox.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 

Applied, with a small correction.
Aman Karmani Sept. 25, 2017, 11:14 p.m. UTC | #2
On Wed, May 24, 2017 at 6:47 AM, wm4 <nfxjfg@googlemail.com> wrote:

> With the new decode API, you can't handle errors directly in the API
> user - you only know that the hwaccel did not initialize at all.
>
> Add some approximate logging.
> ---
>  libavcodec/videotoolbox.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
> index d36a33efcd..85cd2215c9 100644
> --- a/libavcodec/videotoolbox.c
> +++ b/libavcodec/videotoolbox.c
> @@ -648,15 +648,21 @@ static int videotoolbox_default_init(AVCodecContext
> *avctx)
>
>      switch (status) {
>      case kVTVideoDecoderNotAvailableNowErr:
> +        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox session not
> available.\n");
> +        return AVERROR(ENOSYS);
>      case kVTVideoDecoderUnsupportedDataFormatErr:
> +        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox does not support this
> format.\n");
>          return AVERROR(ENOSYS);
>      case kVTVideoDecoderMalfunctionErr:
> +        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox malfunction.\n");
>          return AVERROR(EINVAL);
>      case kVTVideoDecoderBadDataErr :
> +        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox reported invalid
> data.\n");
>          return AVERROR_INVALIDDATA;
>      case 0:
>          return 0;
>      default:
> +        av_log(avctx, "Unknown VideoToolbox session creation error %u\n",
> (unsigned)status);
>

Is OSStatus really unsigned? When I've encountered VT errors in the past
they've usually been negative integers.


>          return AVERROR_UNKNOWN;
>      }
>  }
> --
> 2.11.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
wm4 Sept. 26, 2017, 12:08 p.m. UTC | #3
On Mon, 25 Sep 2017 16:14:08 -0700
Aman Gupta <ffmpeg@tmm1.net> wrote:

> On Wed, May 24, 2017 at 6:47 AM, wm4 <nfxjfg@googlemail.com> wrote:
> 
> > With the new decode API, you can't handle errors directly in the API
> > user - you only know that the hwaccel did not initialize at all.
> >
> > Add some approximate logging.
> > ---
> >  libavcodec/videotoolbox.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
> > index d36a33efcd..85cd2215c9 100644
> > --- a/libavcodec/videotoolbox.c
> > +++ b/libavcodec/videotoolbox.c
> > @@ -648,15 +648,21 @@ static int videotoolbox_default_init(AVCodecContext
> > *avctx)
> >
> >      switch (status) {
> >      case kVTVideoDecoderNotAvailableNowErr:
> > +        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox session not
> > available.\n");
> > +        return AVERROR(ENOSYS);
> >      case kVTVideoDecoderUnsupportedDataFormatErr:
> > +        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox does not support this
> > format.\n");
> >          return AVERROR(ENOSYS);
> >      case kVTVideoDecoderMalfunctionErr:
> > +        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox malfunction.\n");
> >          return AVERROR(EINVAL);
> >      case kVTVideoDecoderBadDataErr :
> > +        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox reported invalid
> > data.\n");
> >          return AVERROR_INVALIDDATA;
> >      case 0:
> >          return 0;
> >      default:
> > +        av_log(avctx, "Unknown VideoToolbox session creation error %u\n",
> > (unsigned)status);
> >  
> 
> Is OSStatus really unsigned? When I've encountered VT errors in the past
> they've usually been negative integers.

Don't know. Aren't they usually fourccs? In any case it should be good
enough to reconstruct the original error code from logs.
diff mbox

Patch

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index d36a33efcd..85cd2215c9 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -648,15 +648,21 @@  static int videotoolbox_default_init(AVCodecContext *avctx)
 
     switch (status) {
     case kVTVideoDecoderNotAvailableNowErr:
+        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox session not available.\n");
+        return AVERROR(ENOSYS);
     case kVTVideoDecoderUnsupportedDataFormatErr:
+        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox does not support this format.\n");
         return AVERROR(ENOSYS);
     case kVTVideoDecoderMalfunctionErr:
+        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox malfunction.\n");
         return AVERROR(EINVAL);
     case kVTVideoDecoderBadDataErr :
+        av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox reported invalid data.\n");
         return AVERROR_INVALIDDATA;
     case 0:
         return 0;
     default:
+        av_log(avctx, "Unknown VideoToolbox session creation error %u\n", (unsigned)status);
         return AVERROR_UNKNOWN;
     }
 }