Segfault with rendering video with custom MediaService (QVideoRendererControl_iid)



  • I am getting segfault here in qopenglfunctions.h on d_ptr->f.TexImage2D(...).

    inline void QOpenGLFunctions::glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
    {
    #if defined(QT_OPENGL_ES_2) && defined(Q_OS_ANDROID)
        ::glTexImage2D(target, level, internalformat, width,height, border, format, type, pixels);
    #else
        Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
        // SEGFAULT HAPPENS HERE
        d_ptr->f.TexImage2D(target, level, internalformat, width,height, border, format, type, pixels);
    #endif
        Q_OPENGL_FUNCTIONS_DEBUG
    }
    

    Here is my code: https://gist.github.com/pauldotknopf/de3495a2581c65bac3cea2ddb8dc376c

    Take a look at the presentFrame frame method. I suspect the error is because videoServuce->present(...) is called with a buffer that is short lived and later deleted. However, I did create a class-level char* buffer that I memcpy to, transforing ownership of the bytes to the class itself, and it still happened.

    Here is the stack trace.

    https://gist.github.com/pauldotknopf/f53f8d7253a1faf5f69256be5806fa6b

    I am using Qt at the latest 5.10 branch.


  • Lifetime Qt Champion

    Hi,

    Why not create a QByteArray from your data and then trigger a copy when you pass it to QMemoryVideoBuffer ?

    Also, are you sure you are passing the right number of bytes per line ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.