I have developed an application to record voice with Qt. it works correctly in a Linux environment but it gives me a run-time error in Android when I start recording.
I have debugged my code and I think it is because of QAudioInput library.
I attached my error image.
QBuffer m_buffer;
m_buffer.open(QBuffer::ReadWrite);
void Recorder::toggleRecord(QString state)
{
if(state == "1")
{
m_buffer.open(QBuffer::ReadWrite);
m_audioInput->start(&m_buffer);
QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
if (!info.isFormatSupported(m_format)) {
qWarning() << "Default format not supported, trying to use the nearest.";
m_format = info.nearestFormat(m_format);
}
}
if(state == "0")
{
m_buffer.close();
m_audioInput->stop();
}
}
You will need run-time access request for this Android version (8).
You can launch it whenever your application starts.