Another stab at correct SDL audio handling

Fully de-initialize SDL audio in AudioManager::deinit().
This commit is contained in:
Bim Overbohm 2013-06-20 16:14:10 +02:00
parent 8436c16426
commit 47ddffb6c3
2 changed files with 10 additions and 2 deletions

View file

@ -1,5 +1,6 @@
#include "AudioManager.h"
#include <SDL.h>
#include "Log.h"
#include "VolumeControl.h"
@ -70,6 +71,12 @@ std::shared_ptr<AudioManager> & AudioManager::getInstance()
void AudioManager::init()
{
if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0)
{
LOG(LogError) << "Error initializing SDL audio!\n" << SDL_GetError();
return;
}
//stop playing all Sounds
for(unsigned int i = 0; i < sSoundVector.size(); i++)
{
@ -97,8 +104,9 @@ void AudioManager::deinit()
{
//stop all playback
stop();
//completely tear down SDL audio. else SDL hogs audio resources and emulators might fail to start...
SDL_CloseAudio();
SDL_QuitSubSystem(SDL_INIT_AUDIO);
}
void AudioManager::registerSound(std::shared_ptr<Sound> & sound)

View file

@ -34,7 +34,7 @@ namespace Renderer
{
LOG(LogInfo) << "Creating surface...";
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0)
if(SDL_Init(SDL_INIT_VIDEO) != 0)
{
LOG(LogError) << "Error initializing SDL!\n " << SDL_GetError();
return false;