Fix for audio not reinitializing on restart.

This commit is contained in:
Aloshi 2013-05-20 10:57:04 -05:00
parent d89a1020a2
commit f3229f111c
4 changed files with 17 additions and 3 deletions

View file

@ -50,6 +50,15 @@ void AudioManager::mixAudio(void *unused, Uint8 *stream, int len)
}
AudioManager::AudioManager()
{
}
AudioManager::~AudioManager()
{
deinit();
}
void AudioManager::init()
{
//Set up format and callback. Play 16-bit stereo audio at 44.1Khz
sAudioFormat.freq = 44100;
@ -65,7 +74,7 @@ AudioManager::AudioManager()
}
}
AudioManager::~AudioManager()
void AudioManager::deinit()
{
SDL_PauseAudio(1);
SDL_CloseAudio();
@ -97,4 +106,4 @@ void AudioManager::play()
{
//unpause audio, the mixer will figure out if samples need to be played...
SDL_PauseAudio(0);
}
}

View file

@ -26,6 +26,9 @@ public:
static void play();
virtual ~AudioManager();
static void init();
static void deinit();
};
#endif

View file

@ -53,6 +53,7 @@ void Window::init()
{
mInputManager->init();
Renderer::init(0, 0);
AudioManager::init();
for(unsigned int i = 0; i < mGuiStack.size(); i++)
{
@ -68,6 +69,7 @@ void Window::deinit()
}
mInputManager->deinit();
AudioManager::deinit();
Renderer::deinit();
}

View file

@ -7,7 +7,6 @@
#include "SystemData.h"
#include <boost/filesystem.hpp>
#include "components/GuiDetectDevice.h"
#include "AudioManager.h"
#include "platform.h"
#include "Log.h"
#include "Window.h"
@ -121,6 +120,7 @@ int main(int argc, char* argv[])
Window window; //don't call Window.init() because we manually pass the resolution to Renderer::init
window.getInputManager()->init();
AudioManager::init();
//try loading the system config file
if(!fs::exists(SystemData::getConfigPath())) //if it doesn't exist, create the example and quit