How to get HDMI status realtime?

how to get HDMI status realtime on nvidia nx?
my project output image by hdmi ,and used the class NvDrmRenderer.
but if there was not link hdmi ,it would print
NvDrmRenderer.cpp:227) Requested connnector is not connected
and it would deadlock on code “delete renderer;”.

NvDrmRenderer *
NvDrmRenderer::createDrmRenderer(const char *name, uint32_t width,
                               uint32_t height, uint32_t w_x, uint32_t w_y,
                               uint32_t connector, uint32_t crtc,
                               struct drm_tegra_hdr_metadata_smpte_2086 metadata,
                               bool streamHDR)
{
  if (!width || ! height) {
    width = 640;
    height = 480;
  }

  NvDrmRenderer* renderer = new NvDrmRenderer(name, width, height, w_x, w_y, connector, crtc, metadata, streamHDR);
  if (renderer && renderer->isInError())
  {
    delete renderer;
    return NULL;
  }
  return renderer;
}

and my code is next:

struct drm_tegra_hdr_metadata_smpte_2086 drm_metadata;
memset(&drm_metadata,0,sizeof(struct drm_tegra_hdr_metadata_smpte_2086));

drm_renderer_ = NvDrmRenderer::createDrmRenderer("renderer0",
        1920, 1080, 0, 0,
         0, 0, drm_metadata, true);

if(NULL == drm_renderer_){
    printf("create NvDrmRenderer error \n");
    return false;
}
else{
    printf("create NvDrmRenderer ok \n");
}

what is the problem with class NvDrmRenderer?

maybe there is some way write image data to hdmi whatever linked or not

Will you hit this problem if you directly use the original MMAPI sample?

it is class NvDrmRenderer bug. if NvDrmRenderer not create ok in function NvDrmRenderer::createDrmRenderer, it will call destructor of class NvDrmRenderer. but some members about of lock and thread are not initialize well in constructor of NvDrmRenderer,in destructor of NvDrmRenderer ,try to distory the members about of lock and thread , it is why it deadlock.

Sounds reasonable. Let me try it on my side.

What is your scenario to hit error?

Disconnect the monitor and run NvDrmRenderer?

yes

What error did you see on your side? APP fails to terminate?

terminate print
NvDrmRenderer.cpp:227) Requested connnector is not connected
and my app not fails ,just deadlock in code
pthread_cond_broadcast(&enqueue_cond);
I changed your code of class NvDrmRenderer, and it works well now without monitor.
NvDrmRenderer.cpp (28.7 KB)

Hi,any official solution here?

Not yet. Maybe you can try the patch from @fanyj233 first.

Hi @fanyj233,

Just want to confirm, is your patch only moving the location of those pthread init function and check the render thread in destructor?

Because you gave the whole file here, not sure if there is anything else.

yes

What is your command to run the application?

Actually, I didn’t hit error in “delete renderer” but at something else.

Thus, I need to know what command is in use on your side.

hi
i didn’t run the example from you.
the code what i wrote is in the question.

So what kind of issue do you want NV to resolve…?

If you hit a problem with your own code, then is there anything to do with original mmapi code?