mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +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 "AudioManager.h"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "VolumeControl.h"
|
#include "VolumeControl.h"
|
||||||
|
|
||||||
|
@ -70,6 +71,12 @@ std::shared_ptr<AudioManager> & AudioManager::getInstance()
|
||||||
|
|
||||||
void AudioManager::init()
|
void AudioManager::init()
|
||||||
{
|
{
|
||||||
|
if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0)
|
||||||
|
{
|
||||||
|
LOG(LogError) << "Error initializing SDL audio!\n" << SDL_GetError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//stop playing all Sounds
|
//stop playing all Sounds
|
||||||
for(unsigned int i = 0; i < sSoundVector.size(); i++)
|
for(unsigned int i = 0; i < sSoundVector.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -97,8 +104,9 @@ void AudioManager::deinit()
|
||||||
{
|
{
|
||||||
//stop all playback
|
//stop all playback
|
||||||
stop();
|
stop();
|
||||||
|
//completely tear down SDL audio. else SDL hogs audio resources and emulators might fail to start...
|
||||||
SDL_CloseAudio();
|
SDL_CloseAudio();
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioManager::registerSound(std::shared_ptr<Sound> & sound)
|
void AudioManager::registerSound(std::shared_ptr<Sound> & sound)
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace Renderer
|
||||||
{
|
{
|
||||||
LOG(LogInfo) << "Creating surface...";
|
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();
|
LOG(LogError) << "Error initializing SDL!\n " << SDL_GetError();
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue