I am trying to query the EGL stream for new frames in the cudaHistogram sample but I am getting segmentation fault inside the eglQueryStreamKHR function. To reproduce use the following patch
--- main.cpp 2019-07-18 09:24:37.635346869 +0000
+++ ../../../samples/cudaHistogram/main.cpp 2019-07-18 09:26:44.681268938 +0000
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <string.h>
#include <Argus/Argus.h>
+#include "EGLGlobal.h"
#include "Error.h"
#include "Options.h"
@@ -123,6 +124,18 @@
ORIGINATE_ERROR("Failed to allocate histogram");
for (unsigned int frame = 0; frame < options.frameCount; ++frame)
{
+ EGLint streamState = 0;
+ while (streamState != EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR && streamState != EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR)
+ {
+ if (!eglQueryStreamKHR(iStream->getEGLDisplay(), iStream->getEGLStream(), EGL_STREAM_STATE_KHR, &streamState))
+ printf("eglQueryStreamKHR EGL_STREAM_STATE_KHR faile\n");
+ }
+
+ if (streamState == EGL_STREAM_STATE_DISCONNECTED_KHR)
+ {
+ printf("EGL Stream state: DISCONNECTED\n");
+ break;
+ }
/*
* For simplicity this example submits a capture then waits for an output.
* This pattern will not provide the best possible performance as the camera
Copy the above patch to a file cudaHistogram.patch and patch the main.cpp file of the cudaHistogram sample with the following command
First of all, there is no error message from the application, only from the OS (“Segmentation fault”) which indicates illegal access of memory inside the eglQueryStreamKHR function after debugging with gdb.
Second, the cudaHistogram sample uses CUDA as EGL consumer and acquires frames with the cudaEGLStreamConsumerAcquireFrame function. My intend here, since the argus lib creates a mailbox stream by default, is to check the stream for new frames before acquire, to avoid duplicate frames. Is there any other way to do that except with the eglQueryStreamKHR ?
In order to get the metadata you have to acquire the image from the EGL stream first. This has a performance cost, which can be significant if the consumer acquires in high frequency. This is why functions like eglQueryStreamKHR exists. The question a have asked is why I am getting segmentation fault when I run this the eglQueryStreamKHR function. Have you tried to reproduce my issue ?
I tried the patch. It seems to work, but at the end of the program I get this error
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused
(argus_cudahistogram:6172): Gtk-WARNING **: cannot open display:
I think it occurs because the XServer in my system is disabled
You can check this behavior by running