QAudioOutput underrun issue on Realtime Play from Microphone with QAudioInput
-
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 0and after audiOutput->start() i get:
buffersize 19200 period size 3840Here 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? -
Hi,
What version of Qt are you using ?
On what Linux distribution ?
On what type of machine ?
What audio hardware are you using ? -
@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?
-
Is it the Qt version provided with your distribution ?
-
-
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.
-
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.