Hello.
I have modified source code of QAudioInput example from QtCreator so the readMore() slot looks like:
void MainWindow::readMore()
{
if(!m_audioInput)
return;
qint64 len = m_audioInput->bytesReady();
if(len > 4096)
len = 4096;
qint64 l = m_input->read(m_buffer.data(), len);
ui
->plainTextEdit
->appendPlainText
(QString("Odczytano l = %1").
arg(l
));
}
void MainWindow::readMore()
{
if(!m_audioInput)
return;
qint64 len = m_audioInput->bytesReady();
if(len > 4096)
len = 4096;
qint64 l = m_input->read(m_buffer.data(), len);
ui->plainTextEdit->appendPlainText(QString("Odczytano l = %1").arg(l));
}
To copy to clipboard, switch view to plain text mode
I thought that 'l' variable will never be greater than 4096 but it always has value of m_audioInput->bytesReady() (even if it is > 4096).
'm_input' is QIODevice and read() method shoud read at most 'len' (4096) bytes of data, so 'l' should not be greater than 4096.
If I am wrong please correct me.
Could someone explain me why is it so behaves.
Bookmarks