Using Qt 5.5.1 on a Windows 7 desktop and a laptop.

I have tried the following program with mp3, wav, flac files. I can only hear the buzzing sound, nothing else. Please guide.

The reproducable example:

Qt Code:
  1. #include <QCoreApplication>
  2. #include <QAudioOutput>
  3. #include <QFile>
  4. #include <QDebug>
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. QCoreApplication a(argc, argv);
  9.  
  10. QAudioOutput* audioOutpu;
  11.  
  12. QFile sourceFile;
  13. sourceFile.setFileName("c.wav");
  14. bool p = sourceFile.open(QIODevice::ReadOnly);
  15. if (p == false)
  16. qDebug() << "no file";
  17. else
  18. qDebug() << "yes file";
  19.  
  20.  
  21. QAudioDeviceInfo d1;
  22. QList<QAudioDeviceInfo> l1 = d1.availableDevices(QAudio::AudioOutput);
  23.  
  24. qDebug() << "======================================================";
  25. qDebug() << l1.first().supportedCodecs();
  26. qDebug() << l1.first().supportedChannelCounts();
  27. qDebug() << l1.first().supportedSampleTypes();
  28. qDebug() << l1.first().supportedSampleRates();
  29. qDebug() << l1.first().supportedSampleSizes();
  30.  
  31. QAudioFormat desiredFormat1;
  32. desiredFormat1.setChannelCount(2);
  33. desiredFormat1.setByteOrder(QAudioFormat::LittleEndian);
  34. desiredFormat1.setCodec("audio/pcm");
  35. desiredFormat1.setSampleType(QAudioFormat::SignedInt);
  36. desiredFormat1.setSampleRate(44100);
  37. desiredFormat1.setSampleSize(16);
  38.  
  39. QAudioDeviceInfo info1(QAudioDeviceInfo::defaultOutputDevice());
  40. if (!info1.isFormatSupported(desiredFormat1))
  41. {
  42. qWarning() << "Default format not supported, trying to use the nearest.";
  43. desiredFormat1 = info1.preferredFormat();
  44. }
  45.  
  46. audioOutpu = new QAudioOutput(desiredFormat1);
  47. audioOutpu->setVolume(1.0);
  48.  
  49. audioOutpu->start(&sourceFile);
  50. qDebug() << "bbbbbbbbbb";
  51. QEventLoop loop;
  52. QObject::connect(audioOutpu, SIGNAL(stateChanged(QAudio::State)), &loop, SLOT(quit()));
  53. do {
  54. loop.exec();
  55. } while(audioOutpu->state() == QAudio::ActiveState);
  56.  
  57. return a.exec();
  58. }
To copy to clipboard, switch view to plain text mode 

Output:
Screenshot from 2016-08-16 13:10:31.png