[Interest] QAudioOutput and ALSA crashs with I/O Possible.

Hugo Drumond Jacob hugo at jacob.eng.br
Tue Apr 8 16:36:34 CEST 2014


Hi folks!

I'm using QtMultimedia (Qt 4.8.3) framework to play some sound on my
application but I'm experiencing some problems when using ALSA interface.

The scenario is something like this:

     QFile inputFile;           // class member.
     QAudioOutput *audioOutput; // class member.
     ...
     void startPlaying()
     {
         inputFile.setFileName("/tmp/test.raw");
         inputFile.open(QIODevice::ReadOnly);

         QAudioFormat format;
         // Set up the format, eg.
         format.setFrequency(8000);
         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)) {
             qWarning()<<"raw audio format not supported by backend, cannot
play audio.";
             return;
         }

         audioOutput = new QAudioOutput(format, this);

 connect(audioOutput,SIGNAL(stateChanged(QAudio::State)),SLOT(finishedPlaying(QAudio::State)));
         audioOutput->start(&inputFile);
     }

     void finishedPlaying(QAudio::State state)
     {
         if (state == QAudio::IdleState) {
             audioOutput->stop();
             inputFile.close();
         }
     }

The problem:
When the application runs with QtMultimedia using pulseaudio to sink the
audio stream, everything occurs like expected. Actually, the problem is
when pulseaudio isn't present. The application crash with a message (from
ALSA!?) "I/O Possible".
Browsing the internet I found [1], that suggests to block SIGIO with
sigprocmask. Ok, this works, but, isn't too 'hardcore'?

Any suggests? Thanks!

Hugo Drumond Jacob

[1]
https://www.mail-archive.com/alsa-user@lists.sourceforge.net/msg21681.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140408/cf5f94a8/attachment.html>


More information about the Interest mailing list