Handle lack of an audio device gracefully without hangs
This commit is contained in:
@@ -36,4 +36,6 @@ class MiniAudioDevice {
|
|||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
bool isInitialized() const { return initialized; }
|
||||||
};
|
};
|
||||||
@@ -428,6 +428,10 @@ RomFS::DumpingResult Emulator::dumpRomFS(const std::filesystem::path& path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Emulator::setAudioEnabled(bool enable) {
|
void Emulator::setAudioEnabled(bool enable) {
|
||||||
|
// Don't enable audio if we didn't manage to find an audio device and initialize it properly, otherwise audio sync will break,
|
||||||
|
// because the emulator will expect the audio device to drain the sample buffer, but there's no audio device running...
|
||||||
|
enable = enable && audioDevice.isInitialized();
|
||||||
|
|
||||||
if (!enable) {
|
if (!enable) {
|
||||||
audioDevice.stop();
|
audioDevice.stop();
|
||||||
} else if (enable && romType != ROMType::None && running) {
|
} else if (enable && romType != ROMType::None && running) {
|
||||||
|
|||||||
Reference in New Issue
Block a user