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?

Qt Code:
  1. AudioController::AudioController()
  2. {
  3. // Set up the format, eg.
  4. format.setFrequency(10100);
  5. format.setChannels(1);
  6. format.setSampleSize(8);
  7. format.setCodec("audio/pcm");
  8. format.setByteOrder(QAudioFormat::LittleEndian);
  9. format.setSampleType(QAudioFormat::UnSignedInt);
  10.  
  11. QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
  12. if (!info.isFormatSupported(format)) {
  13. qDebug("raw audio format not supported by backend, cannot play audio.");
  14. return;
  15. }
  16.  
  17. input = new QAudioInput(format, this);
  18. output = new QAudioOutput(format, this);
  19.  
  20. connect(input,SIGNAL(stateChanged(QAudio::State)),SLOT(inputPlaying(QAudio::State)));
  21. device = input->start();
  22.  
  23. connect(output,SIGNAL(stateChanged(QAudio::State)),SLOT(outputPlaying(QAudio::State)));
  24. output->start(device);
  25.  
  26. }
To copy to clipboard, switch view to plain text mode