]> git.sesse.net Git - vlc/commitdiff
direct3d11: catch texture mapping errors
authorSteve Lhomme <robUx4@videolabs.io>
Tue, 24 Mar 2015 12:00:54 +0000 (13:00 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 24 Mar 2015 15:04:02 +0000 (16:04 +0100)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/video_output/msw/direct3d11.c

index f98858b76a32986b5e47d43f66237fa25a170551..d8c62c1aa984a6ff3b9085b9e431d7989e16325a 100644 (file)
@@ -85,6 +85,7 @@ struct picture_sys_t
 {
     ID3D11Texture2D     *texture;
     ID3D11DeviceContext *context;
+    vout_display_t      *vd;
 };
 
 static int  Open(vlc_object_t *);
@@ -877,6 +878,7 @@ static int Direct3D11CreateResources(vout_display_t *vd, video_format_t *fmt)
 
     picsys->texture  = sys->d3dtexture;
     picsys->context  = sys->d3dcontext;
+    picsys->vd       = vd;
 
     picture_resource_t resource = { .p_sys = picsys };
     for (int i = 0; i < PICTURE_PLANE_MAX; i++)
@@ -925,8 +927,15 @@ static void Direct3D11DestroyResources(vout_display_t *vd)
 static int Direct3D11MapTexture(picture_t *picture)
 {
     D3D11_MAPPED_SUBRESOURCE mappedResource;
-    ID3D11DeviceContext_Map(picture->p_sys->context, (ID3D11Resource *)picture->p_sys->texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
-    CommonUpdatePicture(picture, NULL, mappedResource.pData, mappedResource.RowPitch);
+    HRESULT hr;
+    int res;
+    hr = ID3D11DeviceContext_Map(picture->p_sys->context, (ID3D11Resource *)picture->p_sys->texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
+    if( FAILED(hr) )
+    {
+        msg_Dbg( picture->p_sys->vd, "failed to map the texture (hr=0x%lX)", hr );
+        return VLC_EGENERIC;
+    }
+    res = CommonUpdatePicture(picture, NULL, mappedResource.pData, mappedResource.RowPitch);
     ID3D11DeviceContext_Unmap(picture->p_sys->context,(ID3D11Resource *)picture->p_sys->texture, 0);
-    return VLC_SUCCESS;
+    return res;
 }