Skip to content

Commit

Permalink
No longer crash the Qt interface if it could not initialize audio.
Browse files Browse the repository at this point in the history
  • Loading branch information
XerTheSquirrel committed Jun 14, 2024
1 parent dee65d0 commit 8223b6f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion qtBuildSystem/Mu/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ MainWindow::MainWindow(QWidget* parent) :
stateManager = new StateManager(this);
emuDebugger = new DebugViewer(this);
refreshDisplay = new QTimer(this);

audioDevice = new QAudioOutput(format, this);
audioOut = audioDevice->start();

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

//audio
audioOut->write((const char*)emu.getAudioSamples(), AUDIO_SAMPLES_PER_FRAME * 2/*channels*/ * sizeof(int16_t));
if (audioOut != NULL) {
audioOut->write((const char*)emu.getAudioSamples(),
AUDIO_SAMPLES_PER_FRAME * 2/*channels*/ * sizeof(int16_t));
}

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

0 comments on commit 8223b6f

Please sign in to comment.