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. QAudioOutput underrun issue on Realtime Play from Microphone with QAudioInput
Forum Updated to NodeBB v4.3 + New Features

QAudioOutput underrun issue on Realtime Play from Microphone with QAudioInput

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.3k 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.
  • michaelLM Offline
    michaelLM Offline
    michaelL
    wrote on last edited by aha_1980
    #1

    Hi,

    sometimes i am getting "underrun occured" from ALSA lib and that means the audioouput is not getting the values on time to play. Alsa then repeats the old buffer values on the speaker.

    How can i avoid underruns on QAudioOuput?

    I tryied to change the buffersize:

    audioOutput->setBufferSize(144000);
    qDebug()<<"buffersize "<<audioOutput->bufferSize()<<" period size"<<audioOutput->periodSize();
    

    I get:
    buffersize 144000 period size 0

    and after audiOutput->start() i get:
    buffersize 19200 period size 3840

    Here is what i am doing:

    audioOutput->setBufferSize(144000);
    qDebug()<<"buffersize "<<audioOutput->bufferSize()<<" period size"<<audioOutput->periodSize();
    m_audioInput = audioInput->start();
     m_audioOutput = audioOutput->start();
     qDebug()<<"buffersize "<<audioOutput->bufferSize()<<" period size"<<audioOutput->periodSize();
     connect(m_audioInput, SIGNAL(readyRead()), SLOT(readBufferSlot()));
    

    Once audio data gets recorded i write to the QIODevice m_audioOutput the values from QIODevice m_audioInput .
    So i think i have a timing issue simetimes and the audio interval for both is 1000ms before and after start(). Why cant i increase the buffer size? And how can i avoid underrun?

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

      Hi,

      What version of Qt are you using ?
      On what Linux distribution ?
      On what type of machine ?
      What audio hardware are you using ?

      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
      • michaelLM Offline
        michaelLM Offline
        michaelL
        wrote on last edited by
        #3

        @SGaist said in QAudioOutput underrung issue on Realtime Play from Microfone with QAudioInput:

        dio hardware are you using ?

        @SGaist i am using:
        QT Version 5.9.1
        Linux Distribuition: Debian Jessie 8
        Machine: ARM iMx6Q
        Audio: Two Soundcards, one USB and one connected to ARM via I2S and I2C(NXP iMx6 Eval).

        The USB Audio Soundcard, "Microfone" works fine also with other computers. The second one, for speakers, also works fine.

        So i found this on QAudioOutput class:

        int QAudioOutput::periodSize() const
        

        Returns the period size in bytes. This is the amount of data required each period to prevent buffer underrun, and to ensure uninterrupted playback.
        Note: It is recommended to provide at least enough data for a full period with each write operation.

        I cannot set peridoSize but i can only read. QaudioInput must be synchronize with QAudioOutput so that QAudioOutput doesnt get underrun. As far as i know, underruns means that for example QAudioOutput doenst get engought data at a certain time to play and it will throw a message and repeat the last buffer of data to the speakers.

        Any idea?

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

          Is it the Qt version provided with your distribution ?

          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
          • michaelLM Offline
            michaelLM Offline
            michaelL
            wrote on last edited by
            #5

            @SGaist said in QAudioOutput underrun issue on Realtime Play from Microphone with QAudioInput:

            the Qt version provided with your distribution ?
            @SGaist Yes this QT version is provided. How do i increase the buffer in QAudioOutput and the periodSize()?

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

              Did you check which backend you are using ?

              In case it's ALSA, you have to ensure that QAudioOutput is in stopped state before calling setBufferSize.

              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
              • michaelLM Offline
                michaelLM Offline
                michaelL
                wrote on last edited by
                #7

                @SGaist said in QAudioOutput underrun issue on Realtime Play from Microphone with QAudioInput:

                setBufferSize

                @SGaist Yes it is ALSA and it is in idle/stop state.
                So do you mean that the solution would be changing the Buffersize right?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SherifOmran
                  wrote on last edited by SherifOmran
                  #8

                  how did you solve the underrun issue, i have it also in embedded and not on PC ? i have the same issue and when i increase the buffer size, it does not help on embedded.

                  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