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. Can't understand the reasons behind complaints; "QAudioInput: failed to set input volume" and "Got a buffer underflow!"?
Forum Update on Monday, May 27th 2025

Can't understand the reasons behind complaints; "QAudioInput: failed to set input volume" and "Got a buffer underflow!"?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qaudioinputqaudiooutputqtcpsocket
11 Posts 2 Posters 5.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.
  • F Offline
    F Offline
    faisal.tum
    wrote on 7 Jan 2016, 13:59 last edited by faisal.tum 1 Jul 2016, 14:00
    #2

    Is it the right branch to post this question,? In which branch should I post this so that I have higher probability of getting an answer? Is the way I have formulated the question is a hindrance to getting any answer at all?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 7 Jan 2016, 23:15 last edited by
      #3

      Hi and welcome to devnet,

      Please allow 24 to 48 hours before bumping your own thread. This forum is community driven and not all people lives in the same timezone as you.

      That said, both problems comes from Pulse. Is it working properly ?

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

      F 1 Reply Last reply 19 Jan 2016, 18:51
      0
      • S SGaist
        7 Jan 2016, 23:15

        Hi and welcome to devnet,

        Please allow 24 to 48 hours before bumping your own thread. This forum is community driven and not all people lives in the same timezone as you.

        That said, both problems comes from Pulse. Is it working properly ?

        F Offline
        F Offline
        faisal.tum
        wrote on 19 Jan 2016, 18:51 last edited by faisal.tum
        #4

        @SGaist

        Hi,
        thanks for the reply. Well I'm not sure if pulse is working correctly all the time. It seems unpredictable sometimes. Although I can't see these complaints in windows, but they are persistent in linux.

        Anyway, I have changed my application as I don't need any more server client connection. Currently all I'm doing is a simple redirecting of QAudioInput to QAudioOutput. The main methods for that are as below:

        void MainWindow::on_startButton_clicked()
        {
            QAudioDeviceInfo inputDevinfo = ui->inputDevice->itemData(ui->inputDevice->currentIndex()).value<QAudioDeviceInfo>();
            QAudioFormat audioFormat;
            audioFormat.setChannelCount(2);
            audioFormat.setCodec("audio/pcm");
            audioFormat.setSampleRate(44100);
            audioFormat.setSampleSize(16);
            audioFormat.setByteOrder(QAudioFormat::LittleEndian);
            audioFormat.setSampleType(QAudioFormat::SignedInt);
        
            if (!inputDevinfo.isFormatSupported(audioFormat))
            {
                //Default format not supported - trying to use nearest
                audioFormat = inputDevinfo.nearestFormat(audioFormat);
            }
            m_audioInput = new QAudioInput(inputDevinfo, audioFormat, this);
        
            QAudioDeviceInfo outputDevinfo = ui->outputDevice->itemData(ui->outputDevice->currentIndex()).value<QAudioDeviceInfo>();
            if (!outputDevinfo.isFormatSupported(audioFormat))
            {
                //Default format not supported - trying to use nearest
                audioFormat = outputDevinfo.nearestFormat(audioFormat);
            }
            m_audioOutput = new QAudioOutput(outputDevinfo, audioFormat, this);
            m_audioOutput->start(m_audioInput->start());
        }
        
        void MainWindow::on_stopButton_clicked()
        {
            m_audioOutput->stop();
            m_audioInput->stop();
            m_audioOutput->~QAudioOutput();
            m_audioInput->~QAudioInput();
        }
        
        

        Despite such simple approach of redirecting, where all the memory is supposedly dealt natively by Qt, there are at times complaints like "QAudioInput: failed to set input volume" and "Got a buffer underflow!". The application seems to work smoothly, but not quite dependable enough as the behaviour differs with different input and output devices. I have no idea what could be the problem. Is it the problem with my code or is there a bug in Qt's Audio module? The issues seem persistent in linux, in Windows I haven't faced many issues.

        I didn't want to flood my response with codes, so if you want to fully test the code you can get it from the following Dropbox link.
        https://www.dropbox.com/s/qwckg9midiqgp4q/duplexaudio.zip?dl=0

        Well, just checked this code in my windows system. I cannot hear any sound there at all. So, in linux it complains "QAudioInput: failed to set input volume" and "Got a buffer underflow!" and in windows, no sound at all, but no complaints. Do you have any idea why such is the case?

        Thanks.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 19 Jan 2016, 20:51 last edited by
          #5

          Calling a destructor like that is not the right way to delete an object. Either use the delete operator or, since they are QObject derived classes, deleteLater.

          Did you found a pattern when these messages can be seen ?

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

          F 1 Reply Last reply 19 Jan 2016, 21:54
          0
          • S SGaist
            19 Jan 2016, 20:51

            Calling a destructor like that is not the right way to delete an object. Either use the delete operator or, since they are QObject derived classes, deleteLater.

            Did you found a pattern when these messages can be seen ?

            F Offline
            F Offline
            faisal.tum
            wrote on 19 Jan 2016, 21:54 last edited by faisal.tum
            #6

            @SGaist

            Thank you for an important rectification of my code.

            As for the pattern, well, the code runs in Linux, it complains "QAudioInput: failed to set input volume" exactly when QAudioInput object is started by calling the start() function, while "Got a buffer underflow!" is rather an unpredictable complaint, I couldn't find a definitive stage when it would make that complaint.

            As I have told you in the previous response, this approach of redirecting QAudioInput object to QAudioOutput object produces mere quietness in Windows, but the approach shown in this link:
            http://www.codeproject.com/Articles/421287/Cross-Platform-Microphone-Audio-Processing-Utility
            works perfectly in Windows, yet produces rampant "Got a buffer underflow!" complaints and eventual crash in Linux. The project from that link itself, when run in Linux leads to an eventual crash along with the aforementioned complaints, while running smoothly in Windows.

            Why is such different behaviour for two different operating systems?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 19 Jan 2016, 22:04 last edited by
              #7

              Because both platform have rather radically different multimedia frameworks. Windows has DirectX and the Windows Media Foundation and linux has e.g. Pulse, GStreamer.

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

              F 1 Reply Last reply 19 Jan 2016, 22:19
              0
              • S SGaist
                19 Jan 2016, 22:04

                Because both platform have rather radically different multimedia frameworks. Windows has DirectX and the Windows Media Foundation and linux has e.g. Pulse, GStreamer.

                F Offline
                F Offline
                faisal.tum
                wrote on 19 Jan 2016, 22:19 last edited by faisal.tum
                #8

                @SGaist

                So, this sort of difference should be expected then? Should I be worried that the code that actually manages to do the job is different for two different OS or this is normal in this case?

                I'm sorry, I'm rather new and inexperienced, so I've these questions.

                Thanks!

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 19 Jan 2016, 22:32 last edited by
                  #9

                  Yes, it is to be expected, every OS is different so there will be differences. Qt abstracts them away for you quite nicely however there will some points where what the OS supports will show some differences. e.g. QMediaPlayer will play video on all OSes however Windows might require some additional Codecs to be installed where Linux would already read them because the default installed packages has supports for them already.

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

                  F 1 Reply Last reply 19 Jan 2016, 22:36
                  0
                  • S SGaist
                    19 Jan 2016, 22:32

                    Yes, it is to be expected, every OS is different so there will be differences. Qt abstracts them away for you quite nicely however there will some points where what the OS supports will show some differences. e.g. QMediaPlayer will play video on all OSes however Windows might require some additional Codecs to be installed where Linux would already read them because the default installed packages has supports for them already.

                    F Offline
                    F Offline
                    faisal.tum
                    wrote on 19 Jan 2016, 22:36 last edited by
                    #10

                    @SGaist

                    Thanks!

                    So, is there any way I can get rid of the complaint "QAudioInput: failed to set input volume" in the Linux version?

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 19 Jan 2016, 23:13 last edited by
                      #11

                      I'd say probably, but right now I don't know what might be interfering here to trigger that message.

                      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

                      • Login

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