QAudioInput -- error underrun? HOW?
-
OSX 10.6.8, Qt 4.7, USB soundcard
Hi. I've implemented the example that shows how to use QAudioInput with a QIODevice, here:
http://doc.qt.nokia.com/4.7-snapshot/multimedia-audioinput.html
I start the thing this way:
@
mAudioInput->start(mInAudioInfo);
@...according to the brief (very!) description on the low level multimedia page, here:
http://labs.qt.nokia.com/2010/05/10/low-level-audio-processing-with-qtmultimedia/
...this should result in me not having to do anything further for data to come in from the input device. What I am doing in the...
@
qint64 AudioInfo::writeData(const char *data, qint64 len)
@...function is storing the incoming data to a buffer, processing it, and elsewhere, writing it back out as sound.
What is WEIRD is that the...
@
mAudioInput
@...keeps stopping with an underrun. Now, all it hands me in the writeData function is a pointer and a length, which I am supposed to return back to it (and I do), so how in blue blazes is it able to get into an underrun condition? If I never looked at the data or wrote it over itself (in my buffers of course), how would it know? It can't. It doesn't even know where they are. So what the heck is going on?
Right now, as a horrible and not usable workaround, every time I go to read the captured data, I check state(), and if it has gone to idle (which it almost always has), I...
@
mAudioInput->start(mInAudioInfo);
@...which restarts it, and I get (jittery, awful) audio for a while, and then... eventually the program crashes deep in the QAudio code.
It's like I am completely missing something I'm supposed to do after it passes me a buffer, but I can't even find a hint of such a thing.
Can anyone help me here?
-
Oh, boy. I reduced the sample rate -- by a lot -- from 96 khz down to 24 khz, and the underrun errors went away...
o This is a USB device with an embedded sound "card": designed to run at 96 khz in stereo.
o Running a Windows VM and going after the card under the VM, through USB, and the VM's abstraction layer... results in 100% operation of the device at 96 khz in stereo, no problems at all. Even if I stick the card out on a hub. So the problem here certainly isn't the card or the USB system. And this machine is fast.
o It would appear, at least, that either QAudioInput or the way I'm using it is not up to the task of dealing with audio very well.
I'm hoping someone comes along and says "oh, you forgot to set the priority" or something along those lines. Help?
-
I'm having the same issues with Qt5 (alpha). And it happens randomly. Sometimes I can record for 2 hours without any problem and other times (with exactly the same settings 16bit samples at 44100Hz) I get the underrun error.
-
And if I get an underrun error, it sometimes just stops recording. Very annoying if your program is so unstable due to this problem.
-
That sounds serious. Please report this at http://bugreports.qt-project.org/ -- that way there's a chance it can be fixed before Qt 5 is released
-