1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-16 20:27:23 +00:00

dxva2: use mp_HESULT_to_str on FAILED(hr)

This commit is contained in:
Kevin Mitchell 2016-02-15 17:52:56 -08:00
parent 88c83f450a
commit 3dfb07854b
2 changed files with 55 additions and 11 deletions

View File

@ -21,6 +21,7 @@
#include <windows.h>
#include <errors.h>
#include <audioclient.h>
#include <d3d9.h>
#include "windows_utils.h"
@ -83,6 +84,40 @@ static char *hresult_to_str(const HRESULT hr)
E(AUDCLNT_S_BUFFER_EMPTY)
E(AUDCLNT_S_THREAD_ALREADY_REGISTERED)
E(AUDCLNT_S_POSITION_STALLED)
E(D3DERR_WRONGTEXTUREFORMAT)
E(D3DERR_UNSUPPORTEDCOLOROPERATION)
E(D3DERR_UNSUPPORTEDCOLORARG)
E(D3DERR_UNSUPPORTEDALPHAOPERATION)
E(D3DERR_UNSUPPORTEDALPHAARG)
E(D3DERR_TOOMANYOPERATIONS)
E(D3DERR_CONFLICTINGTEXTUREFILTER)
E(D3DERR_UNSUPPORTEDFACTORVALUE)
E(D3DERR_CONFLICTINGRENDERSTATE)
E(D3DERR_UNSUPPORTEDTEXTUREFILTER)
E(D3DERR_CONFLICTINGTEXTUREPALETTE)
E(D3DERR_DRIVERINTERNALERROR)
E(D3DERR_NOTFOUND)
E(D3DERR_MOREDATA)
E(D3DERR_DEVICELOST)
E(D3DERR_DEVICENOTRESET)
E(D3DERR_NOTAVAILABLE)
E(D3DERR_OUTOFVIDEOMEMORY)
E(D3DERR_INVALIDDEVICE)
E(D3DERR_INVALIDCALL)
E(D3DERR_DRIVERINVALIDCALL)
E(D3DERR_WASSTILLDRAWING)
E(D3DOK_NOAUTOGEN)
E(D3DERR_DEVICEREMOVED)
E(D3DERR_DEVICEHUNG)
E(S_NOT_RESIDENT)
E(S_RESIDENT_IN_SHARED_MEMORY)
E(S_PRESENT_MODE_CHANGED)
E(S_PRESENT_OCCLUDED)
E(D3DERR_UNSUPPORTEDOVERLAY)
E(D3DERR_UNSUPPORTEDOVERLAYFORMAT)
E(D3DERR_CANNOTPROTECTCONTENT)
E(D3DERR_UNSUPPORTEDCRYPTO)
E(D3DERR_PRESENT_STATISTICS_DISJOINT)
default:
return "<Unknown>";
}

View File

@ -207,7 +207,8 @@ static struct mp_image *dxva2_retrieve_image(struct lavc_ctx *s,
hr = IDirect3DSurface9_LockRect(surface, &LockedRect, NULL, D3DLOCK_READONLY);
if (FAILED(hr)) {
MP_ERR(ctx, "Unable to lock DXVA2 surface\n");
MP_ERR(ctx, "Unable to lock DXVA2 surface: %s\n",
mp_HRESULT_to_str(hr));
talloc_free(sw_img);
return img;
}
@ -271,7 +272,8 @@ static int create_device(struct lavc_ctx *s)
D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE,
&d3dpp, &ctx->d3d9device);
if (FAILED(hr)) {
MP_ERR(ctx, "Failed to create Direct3D device\n");
MP_ERR(ctx, "Failed to create Direct3D device: %s\n",
mp_HRESULT_to_str(hr));
goto fail;
}
@ -317,25 +319,29 @@ static int dxva2_init(struct lavc_ctx *s)
hr = createDeviceManager(&resetToken, &ctx->d3d9devmgr);
if (FAILED(hr)) {
MP_ERR(ctx, "Failed to create Direct3D device manager\n");
MP_ERR(ctx, "Failed to create Direct3D device manager: %s\n",
mp_HRESULT_to_str(hr));
goto fail;
}
hr = IDirect3DDeviceManager9_ResetDevice(ctx->d3d9devmgr, ctx->d3d9device, resetToken);
if (FAILED(hr)) {
MP_ERR(ctx, "Failed to bind Direct3D device to device manager\n");
MP_ERR(ctx, "Failed to bind Direct3D device to device manager: %s\n",
mp_HRESULT_to_str(hr));
goto fail;
}
hr = IDirect3DDeviceManager9_OpenDeviceHandle(ctx->d3d9devmgr, &ctx->deviceHandle);
if (FAILED(hr)) {
MP_ERR(ctx, "Failed to open device handle\n");
MP_ERR(ctx, "Failed to open device handle: %s\n",
mp_HRESULT_to_str(hr));
goto fail;
}
hr = IDirect3DDeviceManager9_GetVideoService(ctx->d3d9devmgr, ctx->deviceHandle, &IID_IDirectXVideoDecoderService, (void **)&ctx->decoder_service);
if (FAILED(hr)) {
MP_ERR(ctx, "Failed to create IDirectXVideoDecoderService\n");
MP_ERR(ctx, "Failed to create IDirectXVideoDecoderService: %s\n",
mp_HRESULT_to_str(hr));
goto fail;
}
@ -364,7 +370,8 @@ static int dxva2_get_decoder_configuration(struct lavc_ctx *s,
hr = IDirectXVideoDecoderService_GetDecoderConfigurations(ctx->decoder_service, device_guid, desc, NULL, &cfg_count, &cfg_list);
if (FAILED(hr)) {
MP_ERR(ctx, "Unable to retrieve decoder configurations\n");
MP_ERR(ctx, "Unable to retrieve decoder configurations: %s\n",
mp_HRESULT_to_str(hr));
return -1;
}
@ -426,7 +433,8 @@ static int dxva2_create_decoder(struct lavc_ctx *s, int w, int h,
hr = IDirectXVideoDecoderService_GetDecoderDeviceGuids(ctx->decoder_service, &guid_count, &guid_list);
if (FAILED(hr)) {
MP_ERR(ctx, "Failed to retrieve decoder device GUIDs\n");
MP_ERR(ctx, "Failed to retrieve decoder device GUIDs: %s\n",
mp_HRESULT_to_str(hr));
goto fail;
}
@ -543,8 +551,8 @@ static int dxva2_create_decoder(struct lavc_ctx *s, int w, int h,
decoder->num_surfaces - 1, target_format, D3DPOOL_DEFAULT, 0,
DXVA2_VideoDecoderRenderTarget, decoder->surfaces, NULL);
if (FAILED(hr)) {
MP_ERR(ctx, "Failed to create %d video surfaces\n",
decoder->num_surfaces);
MP_ERR(ctx, "Failed to create %d video surfaces: %s\n",
decoder->num_surfaces, mp_HRESULT_to_str(hr));
goto fail;
}
@ -552,7 +560,8 @@ static int dxva2_create_decoder(struct lavc_ctx *s, int w, int h,
ctx->decoder_service, &device_guid, &desc, &decoder->config,
decoder->surfaces, decoder->num_surfaces, &decoder->decoder);
if (FAILED(hr)) {
MP_ERR(ctx, "Failed to create DXVA2 video decoder\n");
MP_ERR(ctx, "Failed to create DXVA2 video decoder: %s\n",
mp_HRESULT_to_str(hr));
goto fail;
}
decoder->pool = talloc_steal(decoder, mp_image_pool_new(decoder->num_surfaces));