QAudioInput randomly stops
This problem is annoying me for the past couple of weeks. I use QAudioInput to record sound (16bit samples at 44100Hz). The input uses a QBuffer to store the recorded data. There is not anything funny about the implementation:
@connect(mBuffer, SIGNAL(bytesWritten(qint64)), this, SLOT(test(qint64)));
mAudioInput = new QAudioInput(mDevice, format, this); // 16bit at 44100Hz
mAudioInput->start(mBuffer); // mBuffer is a QBuffer@
The test slot simply prints out the number of bytes that have be written. This works fine about 80% of the time, but the other 20% of the time, QAudioInput randomly stops "recording". What I mean by this is that at some random point the bytesWritten is not emitted anymore. I though something about the signal might not be working, so I created a QTimer that checks every second the size of the buffer. The timer confirmed that at some stage QAudioInput stops feeding data to the buffer. I also checked the status, which is still QAudio::ActiveState when the problem happens and the error is QAudio::NoError, so from the viewpoint of QAudioInput everything is still working fine.
This problem is totally random, sometimes I can record for an hour without any problems, other times this happens after 30 seconds. I'm not sure, but I think this might have something to do with underlying system audio system, since nothing breaks in QAudioInput, but the data input just stops.
Does anyone have an idea of what might be going wrong?
I'm using Ubuntu 12.04 64bit and tested it with -Qt 5 alpha- and Qt 5 beta 2.
EDIT: When this problem happens and I call stop() and start() on QAudioInput again (sometimes I have to call it multiple times), the recording goes on again.
EDIT2: I might have been wrong, I wasn't yet able to replicate the problem with Qt 5 alpha, so it might be a problem specific to beta (2). I'll run a couple more tests and if it's not alpha, I'll file a bug report.