Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Audio buffer underrun when mouse is moving ?
Forum Updated to NodeBB v4.3 + New Features

Audio buffer underrun when mouse is moving ?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 3 Posters 1.2k Views 2 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.
  • H Offline
    H Offline
    Hiloshi
    wrote on last edited by Hiloshi
    #1

    Dear Sirs,

    I met a problem. I use QAudioOutput to play PCM data to QIODevice every 10ms for 1764 bytes(44.1k/16bits).

    This problem is if I don't move my cursor, audio play is very smooth. However, once I move cursor, ALSA show buffer underrun message till I stop moving cursor. The same issue can reproduce on WIN7 64bits and RPi3.

    There is nothing on UI, only one button to play audio.

    I use QElapsedTimer to check 10ms time slot, the timing is correct within in 10ms. CPU usage under 10%.

    I have no idea how to find the root cause, please help provide some directions.

    Appreciate~

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

      Hi,

      Moving the mouse around on your application implies that the event loop will be processing events. Since you are basically sending audio at 100Hz, you should move that part to another thread that won't be influenced by what happens in the GUI thread.

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

      H 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        Moving the mouse around on your application implies that the event loop will be processing events. Since you are basically sending audio at 100Hz, you should move that part to another thread that won't be influenced by what happens in the GUI thread.

        H Offline
        H Offline
        Hiloshi
        wrote on last edited by
        #3

        Dear @SGaist,

        Your suggestion is valuable, I will follow it.

        thanks.

        mrjjM 1 Reply Last reply
        0
        • H Hiloshi

          Dear @SGaist,

          Your suggestion is valuable, I will follow it.

          thanks.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Hiloshi

          Hi
          please see
          https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/

          use such worker approach and it should be smooth at all times.

          H 1 Reply Last reply
          1
          • mrjjM mrjj

            @Hiloshi

            Hi
            please see
            https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/

            use such worker approach and it should be smooth at all times.

            H Offline
            H Offline
            Hiloshi
            wrote on last edited by
            #5

            Dear @mrjj

            Thank you very much, it is a very good lesson.

            Thanks,

            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