Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt QAudioRecorder停止崩溃应用程序_Qt_Audio Recording - Fatal编程技术网

Qt QAudioRecorder停止崩溃应用程序

Qt QAudioRecorder停止崩溃应用程序,qt,audio-recording,Qt,Audio Recording,我有一个微型录音机。当我按下按钮时,录制开始或停止(取决于状态)。第一次执行start/stop时,但经过一定时间后,应用程序在stop函数时崩溃。我看起来很随意 //myapp.h //myapp.cpp 记录期间出错: |State | Status | -----------------|------------|----------| clic to start > | | |

我有一个微型录音机。当我按下按钮时,录制开始或停止(取决于状态)。第一次执行start/stop时,但经过一定时间后,应用程序在stop函数时崩溃。我看起来很随意

//myapp.h
//myapp.cpp
记录期间出错:

                 |State       | Status   |
-----------------|------------|----------|
clic to start >  |            |          |
                 |Recording   |          |
                 |            | Starting |
clic to stop >   |            |          |

我已经找到了一个防止崩溃的解决方案,但它并不漂亮。如果录音机处于StratingStatus或FinalingStatus状态,我将重新创建录音机

void MyApp::toogleRecord(){

    switch (myAudioRecorder->status()) {
    case QMediaRecorder::LoadedStatus:
        myAudioRecorder->record();
        break;
    case QMediaRecorder::StartingStatus:
        qDebug()<<"ok je suis là en starting";
        createAudioRecorder();
        break;
    case QMediaRecorder::RecordingStatus    :
        myAudioRecorder->stop();
        break;
    case QMediaRecorder::FinalizingStatus:
        qDebug()<<"ok je suis là en finalizing";
        createAudioRecorder();
        break;
    default:
        break;
    }
}
void MyApp::toogleRecord(){
开关(myAudioRecorder->status()){
案例QMediareRecorder::LoadedStatus:
myAudioRecorder->record();
打破
案例QMediareRecorder::启动状态:

qDebug()崩溃时有任何可读错误吗?没有。实际上,它并没有真正崩溃,应用程序在这一行被阻止,似乎没有响应(windows灰色)。我至少要检查回溯-在调试模式下运行应用程序,然后在“崩溃”时运行应用程序您将看到如何调用该行,局部变量值是什么等等。我建议创建一个插槽,并将其连接到信号QMediaRecorder::error(QMediaRecorder::error error),通过该信号可以获得一些有用的信息。当我在没有停止点的情况下启动调试时,我没有关于“崩溃”的消息。
                 |State       | Status   |
-----------------|------------|----------|
clic to start >  |            |          |
                 |Recording   |          |
                 |            | Starting |
                 |            | Recording|
clic to stop >   |            |          |
                 |Stopped     |          |  
                 |            |Finalizing|
                 |            |Loaded    |
                 |State       | Status   |
-----------------|------------|----------|
clic to start >  |            |          |
                 |Recording   |          |
                 |            | Starting |
clic to stop >   |            |          |
void MyApp::toogleRecord(){

    switch (myAudioRecorder->status()) {
    case QMediaRecorder::LoadedStatus:
        myAudioRecorder->record();
        break;
    case QMediaRecorder::StartingStatus:
        qDebug()<<"ok je suis là en starting";
        createAudioRecorder();
        break;
    case QMediaRecorder::RecordingStatus    :
        myAudioRecorder->stop();
        break;
    case QMediaRecorder::FinalizingStatus:
        qDebug()<<"ok je suis là en finalizing";
        createAudioRecorder();
        break;
    default:
        break;
    }
}