mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 14:45:41 +12:00
Audio: Properly close audio device on emulator destruction
This commit is contained in:
parent
452510b932
commit
37ee5c5477
3 changed files with 21 additions and 7 deletions
|
@ -21,10 +21,12 @@ class MiniAudioDevice {
|
|||
bool running = false;
|
||||
|
||||
std::vector<std::string> audioDevices;
|
||||
|
||||
public:
|
||||
MiniAudioDevice();
|
||||
// If safe is on, we create a null audio device
|
||||
void init(Samples& samples, bool safe = false);
|
||||
void close();
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
|
|
@ -130,7 +130,7 @@ void MiniAudioDevice::start() {
|
|||
|
||||
void MiniAudioDevice::stop() {
|
||||
if (!initialized) {
|
||||
Helpers::warn("MiniAudio device not initialized, can't start");
|
||||
Helpers::warn("MiniAudio device not initialized, can't stop");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -142,3 +142,14 @@ void MiniAudioDevice::stop() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MiniAudioDevice::close() {
|
||||
stop();
|
||||
|
||||
if (initialized) {
|
||||
initialized = false;
|
||||
|
||||
ma_device_uninit(&device);
|
||||
ma_context_uninit(&context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ Emulator::Emulator()
|
|||
Emulator::~Emulator() {
|
||||
config.save();
|
||||
lua.close();
|
||||
audioDevice.close();
|
||||
|
||||
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
||||
discordRpc.stop();
|
||||
|
@ -249,7 +250,7 @@ bool Emulator::loadROM(const std::filesystem::path& path) {
|
|||
success = loadELF(path);
|
||||
else if (extension == ".3ds" || extension == ".cci")
|
||||
success = loadNCSD(path, ROMType::NCSD);
|
||||
else if (extension == ".cxi" || extension == ".app" || extension == ".ncch")
|
||||
else if (extension == ".cxi" || extension == ".app")
|
||||
success = loadNCSD(path, ROMType::CXI);
|
||||
else if (extension == ".3dsx")
|
||||
success = load3DSX(path);
|
||||
|
|
Loading…
Add table
Reference in a new issue