[Qt-interest] High CPU Usage With QAudioOutput

Gabriel M. Beddingfield gabrbedd at gmail.com
Wed Apr 6 16:40:11 CEST 2011



On Wed, 6 Apr 2011, Barnes, Clifton A. wrote:

> aplay prints the following when running 'aplay file.wav':
>    Signed 16 bit Little Endian, Rate 16000 Hz, Mono
>
> I'm using the following to set the format:
>
> QAudioFormat format; // Class variable
>
> format.setFrequency(16000);
> format.setChannels(1);
> format.setSampleSize(16);
> format.setCodec("audio/pcm");

This is line incorrect, since you're actually sending 
audio/x-wav

> format.setByteOrder(QAudioFormat::LittleEndian);
> format.setSampleType(QAudioFormat::SignedInt);
>
> I then pass that format object to the QAudioOutput constructor.

Just curious... did you first check if the format is 
supported?  Also, is it going to PulseAudio instead of your 
sound card?  My guess is that something is triggering 
resampling.

Also, if you're really just wanting phonon-like media 
playback... you should check out QMediaPlayer.  QAudioOutput 
is really for low-level stuff (like if you're writing a 
synthesizer or sampler something).

-gabriel




More information about the Qt-interest-old mailing list