Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

GUI Hang while playing audio in Infinite loop



  • Hello,

    We are developing an embedded application using Qt QML v 5.9.4 for an embedded application based on Yocto BSP.
    In our application we need to read from a device every 1 second over serial port. We are using QSerialPort for that.
    In addition to this we need to play a wav file continuously. We are using Audio of Multimedia component(QtMultimedia 5.8) and playing audio file like below:
    function playAudioLoop() {
    source = alarmSource
    loops = Audio.Infinite
    bindVolume(1)
    play()
    }
    Audio file length is of 8 seconds.

    If we don't play the audio, app runs smoothly. Whereas, if run the application with audio part, then GUI freezes after 3-4 hours or sometimes even after 12 hours. This freeze time varies from 3 hours to 12 hours.
    We also tried to add a delay timer of 3 seconds before replaying the wav file. With this, application ran for 26 hours and then GUI hang was again observed.

    Please let us know

    1. if there is any known issue with QML Multimedia component and whether we should try QSound as an alternative?
    2. Can this be due to synchronization? but then app plays fine without the audio part and hence we wonder.
    3. Is audio playing consuming too much processor and not letting UI responsive?
      Please note that we cannot debug the application and need to run the application in Release mode only on the device due to setup limitations

    Thanks.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    For possible issues, you should check the bug report system.

    One thing your should consider is to update Qt to a more recent version to check whether the situation has improved.



  • @SGaist Currently we cannot change the Qt version that we are using.
    Also, we couldn't find any open bug to related to GUI freeze due to Multimedia/Audio component


  • Lifetime Qt Champion

    @SKWH said in GUI Hang while playing audio in Infinite loop:

    @SGaist Currently we cannot change the Qt version that we are using.

    While it's an answer I was expecting, it's still valid to check with a more recent version. If it works correctly then you'll have at least a possible way to patch the Qt release you are currently using.



  • @SGaist
    We had added a timer(3 second Timer) which starts once OnStopped event from Audio is received and on timeout(3 sec), we were playing the Audio file.
    We observed that after some time, OnStopped event is not received and hence Audio playing stops.
    Does anyone know why we might not be receiving onStopped event even though Audio file completes playing?
    Also, rest of the application just hangs causing the GUI to freeze when onStopped event is not received. This should not happen right?
    Even though onStopped is not received, may be only Audio playing functionality should be paused, but rest of the application should proceed.

    Any help is very much appreciated.


  • Lifetime Qt Champion

    Did you check whether the freezing would happen at the same time of some resource exhaustion on your device ?



  • @SGaist No there is no resource exhaustion that we are seeing during this freeze scenario.
    Also, we had kept the system with only audio functionality disabled, with this, system was running smoothly for 45+ hours. So Audio is surely playing some spoil sport here.
    We are using timers in C++, lowest interval being 1 sec and also we have timers in QML, there as well lowest being 1 second. QML 1 sec timer is need to updated clock on UI.
    Can it happen that while Audio is playing these timers cause some deadlock kind of thing?



  • @SKWH Try a different machine with a different driver. Perhaps update the system driver for the audio. Make sure you are not fighting a system problem.


Log in to reply