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 ?

Audio buffer underrun when mouse is moving ?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 3 Posters 1.2k Views
  • 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 12 Sept 2017, 09:21 last edited by Hiloshi 9 Dec 2017, 09:22
    #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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 12 Sept 2017, 09:47 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 13 Sept 2017, 15:45
      2
      • S SGaist
        12 Sept 2017, 09:47

        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 13 Sept 2017, 15:45 last edited by
        #3

        Dear @SGaist,

        Your suggestion is valuable, I will follow it.

        thanks.

        M 1 Reply Last reply 13 Sept 2017, 15:51
        0
        • H Hiloshi
          13 Sept 2017, 15:45

          Dear @SGaist,

          Your suggestion is valuable, I will follow it.

          thanks.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 13 Sept 2017, 15:51 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 14 Sept 2017, 08:28
          1
          • M mrjj
            13 Sept 2017, 15:51

            @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 14 Sept 2017, 08:28 last edited by
            #5

            Dear @mrjj

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

            Thanks,

            1 Reply Last reply
            0

            1/5

            12 Sept 2017, 09:21

            • Login

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