QAudioOutput in Qt5 is not producing any sound
-
Hi all,
I'm working under kubuntu 12.10 and developping an application into which i need to generate some sound into a QIODevice, then play it with QAudioOutput.
I've read all the litterature around speaking of how to properly do that, and I think to have done so.
So far I've done :
@
QVector <double> * soundData = SoundGenerator::getSound();soundBuffer->open(QIODevice::ReadWrite); QDataStream writeStream(soundBuffer); foreach(double d, *soundData) { char value = d * (2 << 7); // qDebug() << "Value : " << (short int)value; writeStream << value; } QAudioFormat format; // Set up the format, eg. format.setSampleRate(SoundGenerator::getAudioSampleRate()); format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleType(QAudioFormat::SignedInt); QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); audio = new QAudioOutput(format, this); if (audio->error() != QAudio::NoError) { qDebug() << "Problem playing sound"; } connect(audio, SIGNAL(stateChanged(QAudio::State)), this, SLOT(aboutToFinish(QAudio::State)));
@
I have also a call to
@
audio->start(soundBuffer)
@from another slot
I do not have any error in the initialization of the QAudioOutput
And I have NO SOUND AT ALL (all other applications have sound, and I'm porting a Qt4 app to Qt5, in Qt4 everything is ok with Phonon)
The aboutToFinish slot is called at the beggining with ActiveState as state, and NoError when calling QAudioOutput::error, but it's not called anymore, even if waiting far more than the expected generated sound duration.
The sound generation process is not to be put in question, it has been tested by writing wav files, and it works.
Moreover, I have built the multimedia example from Qt's sources, when it comes to pure audio there is no output (for example in the sprectrum example), on another hand, video plays with the sound perfectly.
Is there any known issue concerning that ? Is that a bug ? Am I doing something wrong ?
Thanks in advance ;)
-
I've recompiled Qt by forcing pulseaudio support to false and Alsa to true
by doing so, I'm able to have the spectrum demo worksI still have issues concerning my code, but apparently it's related to the way I generate data to feed the QIODevice which I provides to QAudioOutput
It seems that there is some issues with Qt5 and pulseaudio right now (with the prebuilt release)
On my configuration it seems that the prebuilt Qt is not able to play sound under Ubuntu 12.10 out of the box (KDE/Qt4, pulseaudio and Qt5 caveheats ?)
I've opened an issue in jira : https://bugreports.qt-project.org/browse/QTBUG-30345?focusedCommentId=198994#comment-198994