mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 19:21:06 +00:00
cuda: Report device open error
Call gst_cuda_result() with CUDA_ERROR_NO_DEVICE error code if we could not open device, so that application can catch the error Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6006>
This commit is contained in:
parent
cd6d62ddf0
commit
51162acc31
5 changed files with 15 additions and 1 deletions
|
@ -489,6 +489,8 @@ and/or use gtk-doc annotations. -->
|
|||
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cuda.h"/>
|
||||
<member name="success" value="0" c:identifier="CUDA_SUCCESS">
|
||||
</member>
|
||||
<member name="error_no_device" value="100" c:identifier="CUDA_ERROR_NO_DEVICE">
|
||||
</member>
|
||||
<member name="error_already_mapped" value="208" c:identifier="CUDA_ERROR_ALREADY_MAPPED">
|
||||
</member>
|
||||
<member name="error_not_supported" value="801" c:identifier="CUDA_ERROR_NOT_SUPPORTED">
|
||||
|
|
|
@ -39,6 +39,7 @@ typedef gint CUdevice;
|
|||
typedef enum
|
||||
{
|
||||
CUDA_SUCCESS = 0,
|
||||
CUDA_ERROR_NO_DEVICE = 100,
|
||||
CUDA_ERROR_ALREADY_MAPPED = 208,
|
||||
CUDA_ERROR_NOT_SUPPORTED = 801,
|
||||
} CUresult;
|
||||
|
|
|
@ -460,7 +460,13 @@ gst_nv_base_enc_open_encode_session (GstNvBaseEnc * nvenc)
|
|||
params.deviceType = NV_ENC_DEVICE_TYPE_CUDA;
|
||||
nv_ret = NvEncOpenEncodeSessionEx (¶ms, &nvenc->encoder);
|
||||
|
||||
return nv_ret == NV_ENC_SUCCESS;
|
||||
if (nv_ret != NV_ENC_SUCCESS) {
|
||||
/* Report error to abort if GST_CUDA_CRITICAL_ERRORS is configured */
|
||||
gst_cuda_result (CUDA_ERROR_NO_DEVICE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -173,6 +173,8 @@ GstNvEncObject::CreateInstance (GstElement * client, GstObject * device,
|
|||
status = NvEncOpenEncodeSessionEx (params, &session);
|
||||
if (!NVENC_IS_SUCCESS (status, nullptr)) {
|
||||
GST_ERROR_OBJECT (device, "NvEncOpenEncodeSessionEx failed");
|
||||
/* Report error to abort if GST_CUDA_CRITICAL_ERRORS is configured */
|
||||
gst_cuda_result (CUDA_ERROR_NO_DEVICE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,6 +121,9 @@ plugin_init (GstPlugin * plugin)
|
|||
CuGetErrorString (cuda_ret, &err_desc);
|
||||
GST_ERROR ("Failed to init cuda, cuInit ret: 0x%x: %s: %s",
|
||||
(int) cuda_ret, err_name, err_desc);
|
||||
|
||||
/* to abort if GST_CUDA_CRITICAL_ERRORS is configured */
|
||||
gst_cuda_result (CUDA_ERROR_NO_DEVICE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue