[vlc-devel] [PATCH 2/2] dxva2: release the surfaces early when there's a failure

Steve Lhomme robux4 at videolabs.io
Tue Aug 2 13:28:54 CEST 2016


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

diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 4357d29..e1d3ddb 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -731,6 +731,9 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id, const video_format_t
                                                          NULL);
     if (FAILED(hr)) {
         msg_Err(va, "extra buffer impossible, avoid a crash (hr=0x%0lx)", hr);
+        for (int i = 0; i < sys->surface_count; i++)
+            IDirect3DSurface9_Release( (IDirect3DSurface9*) sys->hw_surface[i] );
+        sys->surface_count = 0;
         return VLC_EGENERIC;
     }
     IDirect3DSurface9_Release(tstCrash);
@@ -772,6 +775,9 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id, const video_format_t
                                                                     &cfg_count,
                                                                     &cfg_list))) {
         msg_Err(va, "IDirectXVideoDecoderService_GetDecoderConfigurations failed");
+        for (int i = 0; i < sys->surface_count; i++)
+            IDirect3DSurface9_Release( (IDirect3DSurface9*) sys->hw_surface[i] );
+        sys->surface_count = 0;
         return VLC_EGENERIC;
     }
     msg_Dbg(va, "we got %d decoder configurations", cfg_count);
@@ -817,6 +823,9 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id, const video_format_t
                                                               sys->surface_count,
                                                               &decoder))) {
         msg_Err(va, "IDirectXVideoDecoderService_CreateVideoDecoder failed");
+        for (int i = 0; i < sys->surface_count; i++)
+            IDirect3DSurface9_Release( (IDirect3DSurface9*) sys->hw_surface[i] );
+        sys->surface_count = 0;
         return VLC_EGENERIC;
     }
     sys->decoder = (IUnknown*) decoder;
-- 
2.8.2



More information about the vlc-devel mailing list