mirror of https://github.com/mpv-player/mpv
hwdec: do not add hwdec device if it failed to create
This commit is contained in:
parent
a5b9290261
commit
4dfc2c50c1
|
@ -108,6 +108,12 @@ static int init(struct ra_hwdec *hw)
|
|||
.supported_formats = subfmts,
|
||||
.hw_imgfmt = IMGFMT_D3D11,
|
||||
};
|
||||
|
||||
if (!p->hwctx.av_device_ref) {
|
||||
MP_VERBOSE(hw, "Failed to create hwdevice_ctx\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
hwdec_devices_add(hw->devs, &p->hwctx);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -136,6 +136,12 @@ static int init(struct ra_hwdec *hw)
|
|||
.av_device_ref = d3d9_wrap_device_ref((IDirect3DDevice9 *)p->dev9),
|
||||
.hw_imgfmt = IMGFMT_DXVA2,
|
||||
};
|
||||
|
||||
if (!p->hwctx.av_device_ref) {
|
||||
MP_VERBOSE(hw, "Failed to create hwdevice_ctx\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
hwdec_devices_add(hw->devs, &p->hwctx);
|
||||
|
||||
ret = 0;
|
||||
|
|
|
@ -178,6 +178,12 @@ static int init(struct ra_hwdec *hw)
|
|||
.av_device_ref = create_mediacodec_device_ref(p->surface),
|
||||
.hw_imgfmt = IMGFMT_MEDIACODEC,
|
||||
};
|
||||
|
||||
if (!p->hwctx.av_device_ref) {
|
||||
MP_VERBOSE(hw, "Failed to create hwdevice_ctx\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
hwdec_devices_add(hw->devs, &p->hwctx);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -304,13 +304,19 @@ static int init(struct ra_hwdec *hw)
|
|||
};
|
||||
|
||||
char *device = drmGetDeviceNameFromFd2(p->ctx->fd);
|
||||
if (!av_hwdevice_ctx_create(&p->hwctx.av_device_ref, AV_HWDEVICE_TYPE_DRM,
|
||||
device, NULL, 0)) {
|
||||
hwdec_devices_add(hw->devs, &p->hwctx);
|
||||
}
|
||||
int ret = av_hwdevice_ctx_create(&p->hwctx.av_device_ref,
|
||||
AV_HWDEVICE_TYPE_DRM, device, NULL, 0);
|
||||
|
||||
if (device)
|
||||
free(device);
|
||||
|
||||
if (ret != 0) {
|
||||
MP_VERBOSE(hw, "Failed to create hwdevice_ctx: %s\n", av_err2str(ret));
|
||||
goto err;
|
||||
}
|
||||
|
||||
hwdec_devices_add(hw->devs, &p->hwctx);
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
|
|
|
@ -185,6 +185,12 @@ static int init(struct ra_hwdec *hw)
|
|||
.supported_formats = subfmts,
|
||||
.hw_imgfmt = IMGFMT_D3D11,
|
||||
};
|
||||
|
||||
if (!p->hwctx.av_device_ref) {
|
||||
MP_VERBOSE(hw, "Failed to create hwdevice_ctx\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
hwdec_devices_add(hw->devs, &p->hwctx);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -183,6 +183,12 @@ static int init(struct ra_hwdec *hw)
|
|||
.av_device_ref = d3d9_wrap_device_ref((IDirect3DDevice9 *)p->device9ex),
|
||||
.hw_imgfmt = IMGFMT_DXVA2,
|
||||
};
|
||||
|
||||
if (!p->hwctx.av_device_ref) {
|
||||
MP_VERBOSE(hw, "Failed to create hwdevice_ctx\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hwdec_devices_add(hw->devs, &p->hwctx);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -83,6 +83,12 @@ static int init(struct ra_hwdec *hw)
|
|||
.av_device_ref = d3d9_wrap_device_ref((IDirect3DDevice9 *)p->device),
|
||||
.hw_imgfmt = IMGFMT_DXVA2,
|
||||
};
|
||||
|
||||
if (!p->hwctx.av_device_ref) {
|
||||
MP_VERBOSE(hw, "Failed to create hwdevice_ctx\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
hwdec_devices_add(hw->devs, &p->hwctx);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -71,8 +71,12 @@ static int init(struct ra_hwdec *hw)
|
|||
.hw_imgfmt = IMGFMT_VIDEOTOOLBOX,
|
||||
};
|
||||
|
||||
av_hwdevice_ctx_create(&p->hwctx.av_device_ref, AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
|
||||
NULL, NULL, 0);
|
||||
int ret = av_hwdevice_ctx_create(&p->hwctx.av_device_ref,
|
||||
AV_HWDEVICE_TYPE_VIDEOTOOLBOX, NULL, NULL, 0);
|
||||
if (ret != 0) {
|
||||
MP_VERBOSE(hw, "Failed to create hwdevice_ctx: %s\n", av_err2str(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
hwdec_devices_add(hw->devs, &p->hwctx);
|
||||
|
||||
|
|
|
@ -72,8 +72,12 @@ static int init(struct ra_hwdec *hw)
|
|||
.hw_imgfmt = IMGFMT_VIDEOTOOLBOX,
|
||||
};
|
||||
|
||||
av_hwdevice_ctx_create(&p->hwctx.av_device_ref, AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
|
||||
NULL, NULL, 0);
|
||||
int ret = av_hwdevice_ctx_create(&p->hwctx.av_device_ref,
|
||||
AV_HWDEVICE_TYPE_VIDEOTOOLBOX, NULL, NULL, 0);
|
||||
if (ret != 0) {
|
||||
MP_VERBOSE(hw, "Failed to create hwdevice_ctx: %s\n", av_err2str(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
hwdec_devices_add(hw->devs, &p->hwctx);
|
||||
|
||||
|
|
|
@ -55,6 +55,12 @@ static int preinit(struct vo *vo)
|
|||
.av_device_ref = create_mediacodec_device_ref(vo),
|
||||
.hw_imgfmt = IMGFMT_MEDIACODEC,
|
||||
};
|
||||
|
||||
if (!p->hwctx.av_device_ref) {
|
||||
MP_VERBOSE(hw, "Failed to create hwdevice_ctx\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
hwdec_devices_add(vo->hwdec_devs, &p->hwctx);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue