[vlc-commits] dxva2: release the surfaces early when there's a failure

Steve Lhomme git at videolan.org
Tue Aug 2 13:38:37 CEST 2016


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Tue Aug  2 13:28:54 2016 +0200| [51274f30cdf81703605fbcd8818c5ae4913f3da5] | committer: Jean-Baptiste Kempf

dxva2: release the surfaces early when there's a failure

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 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;



More information about the vlc-commits mailing list