mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 15:15:37 +00:00
Fixed a memory leak related to the navigation sounds.
This commit is contained in:
parent
08e6f1b0dd
commit
b90ab39cb7
|
@ -32,6 +32,7 @@
|
|||
#include "MameNames.h"
|
||||
#include "Platform.h"
|
||||
#include "Settings.h"
|
||||
#include "Sound.h"
|
||||
#include "SystemData.h"
|
||||
#include "SystemScreensaver.h"
|
||||
|
||||
|
@ -614,6 +615,7 @@ int main(int argc, char* argv[])
|
|||
MameNames::deinit();
|
||||
CollectionSystemsManager::deinit();
|
||||
SystemData::deleteSystems();
|
||||
NavigationSounds::getInstance()->deinit();
|
||||
|
||||
// Call this ONLY when linking with FreeImage as a static library.
|
||||
#if defined(FREEIMAGE_LIB)
|
||||
|
|
|
@ -235,7 +235,7 @@ void AudioManager::unregisterSound(std::shared_ptr<Sound>& sound)
|
|||
return;
|
||||
}
|
||||
}
|
||||
LOG(LogError) << "AudioManager - tried to unregister a sound that wasn't registered!";
|
||||
LOG(LogError) << "AudioManager - tried to unregister a sound that wasn't registered";
|
||||
}
|
||||
|
||||
void AudioManager::play()
|
||||
|
|
|
@ -60,7 +60,6 @@ Sound::Sound(
|
|||
|
||||
Sound::~Sound()
|
||||
{
|
||||
deinit();
|
||||
}
|
||||
|
||||
void Sound::loadFile(const std::string& path)
|
||||
|
@ -137,6 +136,7 @@ void Sound::deinit()
|
|||
mSampleLength = 0;
|
||||
mSamplePos = 0;
|
||||
SDL_UnlockAudioDevice(AudioManager::sAudioDevice);
|
||||
sMap.erase(mPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,21 +214,27 @@ NavigationSounds* NavigationSounds::getInstance()
|
|||
|
||||
void NavigationSounds::deinit()
|
||||
{
|
||||
if (sInstance)
|
||||
if (sInstance) {
|
||||
for (auto sound : navigationSounds) {
|
||||
AudioManager::getInstance()->unregisterSound(sound);
|
||||
sound->deinit();
|
||||
}
|
||||
navigationSounds.clear();
|
||||
delete sInstance;
|
||||
}
|
||||
|
||||
sInstance = nullptr;
|
||||
}
|
||||
|
||||
void NavigationSounds::loadThemeNavigationSounds(const std::shared_ptr<ThemeData>& theme)
|
||||
{
|
||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "systembrowse"));
|
||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "quicksysselect"));
|
||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "select"));
|
||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "back"));
|
||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "scroll"));
|
||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "favorite"));
|
||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "launch"));
|
||||
navigationSounds.push_back(std::move(Sound::getFromTheme(theme, "all", "systembrowse")));
|
||||
navigationSounds.push_back(std::move(Sound::getFromTheme(theme, "all", "quicksysselect")));
|
||||
navigationSounds.push_back(std::move(Sound::getFromTheme(theme, "all", "select")));
|
||||
navigationSounds.push_back(std::move(Sound::getFromTheme(theme, "all", "back")));
|
||||
navigationSounds.push_back(std::move(Sound::getFromTheme(theme, "all", "scroll")));
|
||||
navigationSounds.push_back(std::move(Sound::getFromTheme(theme, "all", "favorite")));
|
||||
navigationSounds.push_back(std::move(Sound::getFromTheme(theme, "all", "launch")));
|
||||
}
|
||||
|
||||
void NavigationSounds::playThemeNavigationSound(NavigationSoundsID soundID)
|
||||
|
|
Loading…
Reference in a new issue