PDA

View Full Version : QAudioOutput buffer underrun



BartBlackMagic
5th September 2010, 15:55
Hi, I was planning to write a small VOIP program using QUdpSockets, but this always ended in buffer underrun problems. I looked with Wireshark whether the receiving end was getting packets and it was.
To better understand the problem, I made the following ridiculous code that gets data from the QAudioInput component via the QIODevice "device" and gives this device to QAudioOutput that I expected to play the audio from the microphone. But it doesn't, the QAudioOutput still gives "buffer underrun" messages.

Anyone has an idea what i'm doing wrong?



AudioController::AudioController()
{
// Set up the format, eg.
format.setFrequency(10100);
format.setChannels(1);
format.setSampleSize(8);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::UnSignedInt);

QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (!info.isFormatSupported(format)) {
qDebug("raw audio format not supported by backend, cannot play audio.");
return;
}

input = new QAudioInput(format, this);
output = new QAudioOutput(format, this);

connect(input,SIGNAL(stateChanged(QAudio::State)), SLOT(inputPlaying(QAudio::State)));
device = input->start();

connect(output,SIGNAL(stateChanged(QAudio::State)) ,SLOT(outputPlaying(QAudio::State)));
output->start(device);

}

BartBlackMagic
16th September 2010, 18:44
I still haven't figured out what to do to solve this buffer underrun problem. Is there nobody who has experience in this field?
Thx