Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. On a Linux terminal, there is a recursive lock issue when using both video playback and recording functions simultaneously
Qt 6.11 is out! See what's new in the release blog

On a Linux terminal, there is a recursive lock issue when using both video playback and recording functions simultaneously

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 354 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    a_Wu
    wrote last edited by a_Wu
    #1

    I encountered a recursive lock issue in the QT program on a Linux terminal while using both recording and video playback functions. After investigation, it was found to be a lock re-entry issue with the Pulsaiudio plugin on QT.
    I use QAudioInput to obtain data for sound input (i.e. recording) and QAudioOutput to obtain data for sound output (i.e. video playback)

    GDB infos:
    (gdb) bt
    #0 0x0000007fa5227978 in __pthread_mutex_lock_full () from /lib/aarch64-linux-gnu/libpthread.so.0
    #1 0x0000007fa0d0e61c in pa_mutex_lock () from /usr/lib/aarch64-linux-gnu/pulseaudio/libpulsecommon-12.2.so
    #2 0x0000007f9c43924c in ?? () from /usr/local/bin/audio/libqtmedia_pulse.so
    #3 0x0000007f9c43985c in ?? () from /usr/local/bin/audio/libqtmedia_pulse.so
    #4 0x0000007fa48b5eec in ?? () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
    #5 0x0000007fa48ba718 in QTimer::timeout(QTimer::QPrivateSignal) () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
    #6 0x0000007fa48ade04 in QObject::event(QEvent*) () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
    #7 0x0000007fa56d4d8c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/aarch64-linux-gnu/libQt5Widgets.so.5
    #8 0x0000007fa56db72c in QApplication::notify(QObject*, QEvent*) () from /usr/lib/aarch64-linux-gnu/libQt5Widgets.so.5
    #9 0x0000007fa48807c8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
    #10 0x0000007fa48d8350 in QTimerInfoList::activateTimers() () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
    #11 0x0000007fa48d8b98 in ?? () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
    #12 0x0000007fa7ebe674 in g_main_context_dispatch () from /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
    #13 0x0000007fa7ebe8e8 in ?? () from /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
    #14 0x0000007fa7ebe984 in g_main_context_iteration () from /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
    #15 0x0000007fa48d8eac in QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
    #16 0x0000007fa487f0f8 in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
    #17 0x0000007fa4887968 in QCoreApplication::exec() () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
    #18 0x0000000000484f9c in main ()

    (gdb) p (pthread_mutex_t)$x0
    $2 = pthread_mutex_t = {Type = Recursive, Status = Acquired, possibly with waiters, Owner ID = 24138, Robust = No, Shared = No, Protocol = Priority inherit, Times acquired by the owner = 13662}

    The following is the QT source code that may be related to the issue:

    class QPulseAudioEngine : public QObject
    {
        Q_OBJECT
    
    public:
        QPulseAudioEngine(QObject *parent = 0);
        ~QPulseAudioEngine();
    
        static QPulseAudioEngine *instance();
        pa_threaded_mainloop *mainloop() { return m_mainLoop; }
        pa_context *context() { return m_context; }
    
        inline void lock()
        {
            if (m_mainLoop)
                pa_threaded_mainloop_lock(m_mainLoop);
        }
    
        inline void unlock()
        {
            if (m_mainLoop)
                pa_threaded_mainloop_unlock(m_mainLoop);
        }
    
        inline void wait(pa_operation *op)
        {
            while (m_mainLoop && pa_operation_get_state(op) == PA_OPERATION_RUNNING)
                pa_threaded_mainloop_wait(m_mainLoop);
        }
    
    

    Has anyone encountered a similar situation before?

    JoeCFDJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote last edited by
      #2

      Hi and welcome to devnet,

      Which version of Qt 5 is it ?
      Please note that Qt 5 has reached end of life a long time ago. You should consider moving to Qt 6.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A a_Wu

        I encountered a recursive lock issue in the QT program on a Linux terminal while using both recording and video playback functions. After investigation, it was found to be a lock re-entry issue with the Pulsaiudio plugin on QT.
        I use QAudioInput to obtain data for sound input (i.e. recording) and QAudioOutput to obtain data for sound output (i.e. video playback)

        GDB infos:
        (gdb) bt
        #0 0x0000007fa5227978 in __pthread_mutex_lock_full () from /lib/aarch64-linux-gnu/libpthread.so.0
        #1 0x0000007fa0d0e61c in pa_mutex_lock () from /usr/lib/aarch64-linux-gnu/pulseaudio/libpulsecommon-12.2.so
        #2 0x0000007f9c43924c in ?? () from /usr/local/bin/audio/libqtmedia_pulse.so
        #3 0x0000007f9c43985c in ?? () from /usr/local/bin/audio/libqtmedia_pulse.so
        #4 0x0000007fa48b5eec in ?? () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
        #5 0x0000007fa48ba718 in QTimer::timeout(QTimer::QPrivateSignal) () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
        #6 0x0000007fa48ade04 in QObject::event(QEvent*) () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
        #7 0x0000007fa56d4d8c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/aarch64-linux-gnu/libQt5Widgets.so.5
        #8 0x0000007fa56db72c in QApplication::notify(QObject*, QEvent*) () from /usr/lib/aarch64-linux-gnu/libQt5Widgets.so.5
        #9 0x0000007fa48807c8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
        #10 0x0000007fa48d8350 in QTimerInfoList::activateTimers() () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
        #11 0x0000007fa48d8b98 in ?? () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
        #12 0x0000007fa7ebe674 in g_main_context_dispatch () from /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
        #13 0x0000007fa7ebe8e8 in ?? () from /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
        #14 0x0000007fa7ebe984 in g_main_context_iteration () from /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
        #15 0x0000007fa48d8eac in QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
        #16 0x0000007fa487f0f8 in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
        #17 0x0000007fa4887968 in QCoreApplication::exec() () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
        #18 0x0000000000484f9c in main ()

        (gdb) p (pthread_mutex_t)$x0
        $2 = pthread_mutex_t = {Type = Recursive, Status = Acquired, possibly with waiters, Owner ID = 24138, Robust = No, Shared = No, Protocol = Priority inherit, Times acquired by the owner = 13662}

        The following is the QT source code that may be related to the issue:

        class QPulseAudioEngine : public QObject
        {
            Q_OBJECT
        
        public:
            QPulseAudioEngine(QObject *parent = 0);
            ~QPulseAudioEngine();
        
            static QPulseAudioEngine *instance();
            pa_threaded_mainloop *mainloop() { return m_mainLoop; }
            pa_context *context() { return m_context; }
        
            inline void lock()
            {
                if (m_mainLoop)
                    pa_threaded_mainloop_lock(m_mainLoop);
            }
        
            inline void unlock()
            {
                if (m_mainLoop)
                    pa_threaded_mainloop_unlock(m_mainLoop);
            }
        
            inline void wait(pa_operation *op)
            {
                while (m_mainLoop && pa_operation_get_state(op) == PA_OPERATION_RUNNING)
                    pa_threaded_mainloop_wait(m_mainLoop);
            }
        
        

        Has anyone encountered a similar situation before?

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote last edited by
        #3

        @a_Wu use raw gstreamer pipeline code and drop Qt multimedia module.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          a_Wu
          wrote last edited by
          #4

          Hello! Version is 5.15.2
          I found that there is another dependency library that may be using the same plugin Pulselink as QT's QAudioInput/QAudioOutput
          I have considered using QT 6, but I would rather determine what caused it
          Thank you.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote last edited by
            #5

            One thing you can test is the latest version of the Qt 5.15 series to see if it behaves in the same manner.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A Offline
              A Offline
              a_Wu
              wrote last edited by
              #6

              Alright, thank you for your suggestion. I'll give it a try

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved