mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
Another stab at correct SDL audio handling
Fully de-initialize SDL audio in AudioManager::deinit().
This commit is contained in:
parent
8436c16426
commit
47ddffb6c3
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue