Remove explicit calls to AudioManager::init() and fix deinit() behaviour

Ensure that deinit() removes the current sInstance so that the next call
to AudioManager::getInstance() will re-initialize audio correctly.

Remove explicit calls to AudioManager::init() and instead rely on
Sound::play() to initialize audio when needed.
This commit is contained in:
Conn O'Griofa 2017-09-14 02:26:33 +01:00
parent dca648c160
commit c08c24e615
4 changed files with 4 additions and 7 deletions

View file

@ -199,7 +199,6 @@ void FileData::launchGame(Window* window)
window->init();
VolumeControl::getInstance()->init();
AudioManager::getInstance()->init();
window->normalizeNextUpdate();
//update number of times the game has been launched
@ -274,4 +273,4 @@ FileData::SortType getSortTypeFromString(std::string desc) {
}
// if not found default to name, ascending
return FileSorts::SortTypes.at(0);
}
}

View file

@ -106,6 +106,7 @@ void AudioManager::deinit()
//completely tear down SDL audio. else SDL hogs audio resources and emulators might fail to start...
SDL_CloseAudio();
SDL_QuitSubSystem(SDL_INIT_AUDIO);
sInstance = NULL;
}
void AudioManager::registerSound(std::shared_ptr<Sound> & sound)

View file

@ -114,6 +114,8 @@ void Sound::play()
if(!Settings::getInstance()->getBool("EnableSounds"))
return;
AudioManager::getInstance();
SDL_LockAudio();
if (playing)
{

View file

@ -191,11 +191,6 @@ void VideoPlayerComponent::stopVideo()
int status;
kill(mPlayerPid, SIGKILL);
waitpid(mPlayerPid, &status, WNOHANG);
// Restart AudioManager
if (boost::starts_with(Settings::getInstance()->getString("OMXAudioDev").c_str(), "alsa"))
{
AudioManager::getInstance()->init();
}
mPlayerPid = -1;
}
}