HRESULT CreateDuplicationExpectedErrors[] = {
DXGI_ERROR_DEVICE_REMOVED,
static_cast<HRESULT>(E_ACCESSDENIED),
- DXGI_ERROR_UNSUPPORTED,
DXGI_ERROR_SESSION_DISCONNECTED,
S_OK
};
return GST_FLOW_ERROR;
}
+ /* Seems to be one limitation of Desktop Duplication API design
+ * See
+ * https://docs.microsoft.com/en-US/troubleshoot/windows-client/shell-experience/error-when-dda-capable-app-is-against-gpu
+ */
+ if (hr == DXGI_ERROR_UNSUPPORTED) {
+ GST_WARNING ("IDXGIOutput1::DuplicateOutput returned "
+ "DXGI_ERROR_UNSUPPORTED, possiblely application is run against a "
+ "discrete GPU");
+ return GST_D3D11_DESKTOP_DUP_FLOW_UNSUPPORTED;
+ }
+
return gst_d3d11_desktop_dup_return_from_hr (d3d11_device.Get(), hr,
CreateDuplicationExpectedErrors);
}
gst_d3d11_desktop_dup_src_start (GstBaseSrc * bsrc)
{
GstD3D11DesktopDupSrc *self = GST_D3D11_DESKTOP_DUP_SRC (bsrc);
+ GstFlowReturn ret;
/* FIXME: this element will use only the first adapter, but
* this might cause issue in case of multi-gpu environment and
}
self->dupl = gst_d3d11_desktop_dup_new (self->device, self->monitor_index);
- if (!self->dupl) {
- GST_ELEMENT_ERROR (self, RESOURCE, NOT_FOUND,
- ("Failed to prepare duplication for output index %d",
- self->monitor_index), (NULL));
-
- return FALSE;
+ if (!self->dupl)
+ goto error;
+
+ /* Check if we can open device */
+ ret = gst_d3d11_desktop_dup_prepare (self->dupl);
+ switch (ret) {
+ case GST_D3D11_DESKTOP_DUP_FLOW_EXPECTED_ERROR:
+ case GST_FLOW_OK:
+ break;
+ case GST_D3D11_DESKTOP_DUP_FLOW_UNSUPPORTED:
+ goto unsupported;
+ default:
+ goto error;
}
self->last_frame_no = -1;
self->min_latency = self->max_latency = GST_CLOCK_TIME_NONE;
return TRUE;
+
+error:
+ {
+ GST_ELEMENT_ERROR (self, RESOURCE, NOT_FOUND,
+ ("Failed to prepare duplication for output index %d",
+ self->monitor_index), (NULL));
+ }
+ return FALSE;
+
+unsupported:
+ {
+ GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ,
+ ("Failed to prepare duplication for output index %d",
+ self->monitor_index),
+ ("Try run the application on the integrated GPU"));
+ return FALSE;
+ }
}
static gboolean
gboolean update_latency = FALSE;
guint64 next_frame_no;
gboolean draw_mouse;
+ /* Just magic number... */
+ gint unsupported_retry_count = 100;
if (!self->dupl) {
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ,
GST_WARNING_OBJECT (self, "Got expected error, try again");
gst_clear_object (&clock);
goto again;
+ } else if (ret == GST_D3D11_DESKTOP_DUP_FLOW_UNSUPPORTED) {
+ GST_WARNING_OBJECT (self, "Got DXGI_ERROR_UNSUPPORTED error");
+ unsupported_retry_count--;
+
+ if (unsupported_retry_count < 0) {
+ ret = GST_FLOW_ERROR;
+ goto out;
+ }
+
+ gst_clear_object (&clock);
+ goto again;
}
after_capture = gst_clock_get_time (clock);