Skip to content

Commit 8223b6f

Browse files
No longer crash the Qt interface if it could not initialize audio.
1 parent dee65d0 commit 8223b6f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

qtBuildSystem/Mu/mainwindow.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ MainWindow::MainWindow(QWidget* parent) :
4747
stateManager = new StateManager(this);
4848
emuDebugger = new DebugViewer(this);
4949
refreshDisplay = new QTimer(this);
50+
5051
audioDevice = new QAudioOutput(format, this);
5152
audioOut = audioDevice->start();
5253

@@ -226,7 +227,10 @@ void MainWindow::updateDisplay(){
226227
ui->display->repaint();
227228

228229
//audio
229-
audioOut->write((const char*)emu.getAudioSamples(), AUDIO_SAMPLES_PER_FRAME * 2/*channels*/ * sizeof(int16_t));
230+
if (audioOut != NULL) {
231+
audioOut->write((const char*)emu.getAudioSamples(),
232+
AUDIO_SAMPLES_PER_FRAME * 2/*channels*/ * sizeof(int16_t));
233+
}
230234

231235
//power LED
232236
ui->powerButtonLed->setStyleSheet(emu.getPowerButtonLed() ? "background: lime" : "");

0 commit comments

Comments
 (0)