[vlc-commits] dxva2: clean error handling

Steve Lhomme git at videolan.org
Wed Jan 17 16:13:06 CET 2018


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jan 16 13:34:46 2018 +0100| [bbd3e66546e9a14976492640d8ca8d43dbcccded] | committer: Jean-Baptiste Kempf

dxva2: clean error handling

(cherry picked from commit 5262e7edb2f60dfd3d36a36835dadbaf98a898dc)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=bbd3e66546e9a14976492640d8ca8d43dbcccded
---

 modules/codec/avcodec/dxva2.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 077c118b77..3836c7394a 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -607,9 +607,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
                                                          NULL);
     if (FAILED(hr)) {
         msg_Err(va, "extra buffer impossible, avoid a crash (hr=0x%0lx)", hr);
-        for (unsigned i = 0; i < surface_count; i++)
-            IDirect3DSurface9_Release( sys->hw_surface[i] );
-        return VLC_EGENERIC;
+        goto error;
     }
     IDirect3DSurface9_Release(tstCrash);
 
@@ -650,9 +648,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
                                                                     &cfg_count,
                                                                     &cfg_list))) {
         msg_Err(va, "IDirectXVideoDecoderService_GetDecoderConfigurations failed");
-        for (unsigned i = 0; i < surface_count; i++)
-            IDirect3DSurface9_Release( sys->hw_surface[i] );
-        return VLC_EGENERIC;
+        goto error;
     }
     msg_Dbg(va, "we got %d decoder configurations", cfg_count);
 
@@ -697,14 +693,16 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
                                                               surface_count,
                                                               &decoder))) {
         msg_Err(va, "IDirectXVideoDecoderService_CreateVideoDecoder failed");
-        for (unsigned i = 0; i < surface_count; i++)
-            IDirect3DSurface9_Release( sys->hw_surface[i] );
-        return VLC_EGENERIC;
+        goto error;
     }
     sys->decoder = decoder;
 
     msg_Dbg(va, "IDirectXVideoDecoderService_CreateVideoDecoder succeed");
     return VLC_SUCCESS;
+error:
+    for (unsigned i = 0; i < surface_count; i++)
+        IDirect3DSurface9_Release( sys->hw_surface[i] );
+    return VLC_EGENERIC;
 }
 
 static void DxDestroyVideoDecoder(vlc_va_t *va)



More information about the vlc-commits mailing list