On Sun, Jan 19, 2014 at 6:23 PM, Luca Barbato <[email protected]> wrote:
> From: Sam Lantinga <[email protected]>
>
> If the function returns E_PENDING retry for a fixed number of times.
>
> Signed-off-by: Luca Barbato <[email protected]>
> ---
>  libavcodec/dxva2.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
> index bc43cae..eb7267b 100644
> --- a/libavcodec/dxva2.c
> +++ b/libavcodec/dxva2.c
> @@ -87,12 +87,19 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, 
> Picture *pic,
>      unsigned               buffer_count = 0;
>      DXVA2_DecodeBufferDesc buffer[4];
>      DXVA2_DecodeExecuteParams exec = { 0 };
> -    int      result;
> -
> -    if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder,
> -                                               ff_dxva2_get_surface(pic),
> -                                               NULL))) {
> -        av_log(avctx, AV_LOG_ERROR, "Failed to begin frame\n");
> +    int result, runs = 0;
> +    HRESULT hr;
> +
> +    do {
> +        hr = IDirectXVideoDecoder_BeginFrame(ctx->decoder,
> +                                             ff_dxva2_get_surface(pic),
> +                                             NULL);
> +        if (hr == E_PENDING)
> +            av_usleep(2);

usleep is still in microseconds, sleeping for 100µs in total won't do
you any good.
Use 2000, for 100ms in total.

> +    } while (hr == E_PENDING && ++runs < 50);
> +
> +    if (FAILED(hr)) {
> +        av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", hr);
>          return -1;
>      }
>
> --
> 1.8.5.1
>
> _______________________________________________
> libav-devel mailing list
> [email protected]
> https://lists.libav.org/mailman/listinfo/libav-devel
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to