I'm trying to implement a double buffer for a real-time audio application, and QAudioInput
requires it to be a subclass of QIODevice
. I'm finding the documentation for this method pretty confusing.
First of all, the method signature in the documentation doesn't match the header for QT 5.9.2, which has virtual qint64 writeData(const char *data, qint64 len) = 0;
.
The documentation has this signature though: qint64 QIODevice::writeData(const char *data, qint64 maxSize)
The maxSize
parameter confuses me because it implies that I can just buffer some of the data, which the documentation also implies with:
Writes up to
maxSize
bytes from data to the device. Returns the number of bytes written, or-1
if an error occurred.
However, immediately afterword the documentation says this, which seems contradictory to me:
When reimplementing this function it is important that this function writes all the data available before returning. This is required in order for
QDataStream
to be able to operate on the class.QDataStream
assumes all the information was written and therefore does not retry writing if there was a problem.
So is my QIODevice
implementation responsible for buffering all the data in a single call or not?
writeData
. – bezet