[Qt-interest] Delay in audio output using qtmultimedia in Mac
Jeremy Lainé
jeremy.laine at bolloretelecom.eu
Wed Sep 28 18:14:45 CEST 2011
On 09/28/2011 06:56 AM, Arun Kumar wrote:
> Hi,
> I am developing one audio processing application using Qt, It works on both
> windows(Windows Xp) and in Mac, It will read Audio data from input device(microphone)
> and output to output device(speaker). It works perfectly in Windows bu in Mac machine it
> produce sound after a 2 to 3 sec later, I checked this in audio input example the i
> found its problem of QAudioInput , I checked the Audio format and sampling rate etc that
> all are supported formats and tried by changing the buffer size too but no effect, how i
> can fix this any suggstion or example will very helpful to me
While developping a VoIP application, I found the "buffer size" to be a bit tricky, but in
the end what works for me (I am using 8 kHz sampling rate, 16bit data):
- Mac: 2048 * channelCount (128ms @ 8 kHz)
- Linux/Windows : 2560 * channelCount (160ms @ 8kHz)
I use the same buffer sizes for audio input and output. You might consider logging what
::bufferSize() returns after ::start() to check the requested buffer size is actually
being accepted on a per-OS basis.
On a side note, I have noticed that calling QAudioInput::start() and QAudioOutput::start()
can block for a variable time (especially when first called, there must be some one-time
setup going on). This is quite annoying in timing-sensitive applications.
In my application, maintaining low latency is important so I have tweaked my QIODevice
subclass that feeds the audio output to drop samples as needed to avoid my playback buffer
exceeding a certain length.. but it's a bit of work to get it right on all platforms. On
the whole I find that QtMultimedia(Kit) does not fully deliver on its promise of ready to
use cross-platform low-level audio processing.. but I am sticking with it for now as I
appreciate the convenience of a Qt-based solution.
--
Jeremy LAINE
Bolloré telecom | 26, rue de Berri | F-75008 Paris
More information about the Qt-interest-old
mailing list