Unsolved QByteArray AudioOutput Example
-
Re: https://doc.qt.io/qt-5/qtmultimedia-multimedia-audiooutput-example.html (Linux)
Generator::generateData() declares "qint64 length" but then calls QByteArray::resize(length), which takes an int, which apparently is the maximum size of a QByteArray. I found a 2012 response suggesting sizeof(int) was big enough. My 2017 laptop came with 16Gb, so I can easily allocate a contiguous block larger than 2Gb. That's not the issue, should not the example use a qint32 instead of a qint64? For example, a debug run with a breakpoint after the length calc returns length=88200. Methinks, perhaps qint64 is overkill?P.S. The Q_UNUSED macros should not be terminated with a semi-colon in writedata().
BTW, I can easily send the example into underrun. I'm still studying the code as I convert it to use a Designer Dialog form. Don't understand where the underruns are coming from, yet. Click push/pull going back and forth between alsa and pulse does it.ALSA lib pcm.c:8432:(snd_pcm_recover) underrun occurred
-
@Psnarf
Don't understand your question. Assuming you are now compiling 64-bit (right? and that's perhaps unlike in 2012), thensizeof(qint64) == sizeof(int)
. It will only resize to the value specified, even if the variable could hold a huge number. If the length is only 88K that's what it will resize to, regardless of the type of the variable.