嵌入式linux系统中使用QAudioRecorder录音调用Record函数后不产生文件
代码 在构造函数中执行:
m_pAudioRecorder =NULL;
m_pAudioRecorder = new QAudioRecorder();
if (m_pAudioRecorder->state() == QMediaRecorder::StoppedState)
{
//获得可用音频输入的列表
QStringList inputs = m_pAudioRecorder->audioInputs();
qDebug()<<"Input Devices Can Used :";
qDebug() << inputs;
qDebug()<<"==========="<<endl;
//获得默认音频输入设备
qDebug()<<"Default Input Devices :";
qDebug() << m_pAudioRecorder->defaultAudioInput();
qDebug()<<"-------------------"<<endl;
//音频编码器设置
QAudioEncoderSettings settings = m_pAudioRecorder->audioSettings();
qDebug()<<"Encoder:"<<endl;
qDebug() << settings.codec();//windows下默认的是audio/pcm
settings.setCodec("audio/pcm");
settings.setSampleRate(1000);
settings.setChannelCount(0);
settings.setQuality(QMultimedia::HighQuality);
settings.setEncodingMode(QMultimedia::ConstantQualityEncoding );
if(m_pAudioRecorder->setOutputLocation(QUrl::fromLocalFile("/workspace/aaa")))
qDebug()<<"-------->>>Start OutPutLocation OK!";
else
qDebug()<<"-------->>>Start OutPutLocation Failed!";
qDebug()<<"QUrl::fromLocalFile:"<<QUrl::fromLocalFile("/workspace/aaa");
//StartRecord在主函数中调用
void AudioRecorder::StartRecord()
{
m_pAudioRecorder->record();
qDebug()<<"-------->>>Start Audio Recorder...";
}
程序运行后并没有在workspace目录下生成 aaa.wav文件,wav后缀是Qt的这个库会默认添加的