mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 04:41:39 +00:00
Move engine initialization.
This commit is contained in:
parent
fc31b32517
commit
2ecdf59772
1 changed files with 7 additions and 15 deletions
|
|
@ -32,7 +32,6 @@ struct EmbeddedSoundData
|
|||
};
|
||||
|
||||
static ma_engine g_audioEngine = {};
|
||||
static bool g_audioEngineInitialized = false;
|
||||
static std::array<EmbeddedSoundData, size_t(EmbeddedSound::Count)> g_embeddedSoundData = {};
|
||||
static const std::unordered_map<std::string, EmbeddedSound> g_embeddedSoundMap =
|
||||
{
|
||||
|
|
@ -134,6 +133,13 @@ static void PlayEmbeddedSound(EmbeddedSound s)
|
|||
|
||||
void EmbeddedPlayer::Init()
|
||||
{
|
||||
ma_engine_config engineConfig = ma_engine_config_init();
|
||||
ma_result res = ma_engine_init(&engineConfig, &g_audioEngine);
|
||||
if (res == MA_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "ma_engine_init failed with error code %d.\n", res);
|
||||
}
|
||||
|
||||
s_isActive = true;
|
||||
}
|
||||
|
||||
|
|
@ -147,19 +153,6 @@ void EmbeddedPlayer::Play(const char *name)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!g_audioEngineInitialized)
|
||||
{
|
||||
ma_engine_config engineConfig = ma_engine_config_init();
|
||||
ma_result res = ma_engine_init(&engineConfig, &g_audioEngine);
|
||||
if (res != MA_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "ma_engine_init failed with error code %d.\n", res);
|
||||
}
|
||||
|
||||
// Do not attempt to initialize this again if it fails.
|
||||
g_audioEngineInitialized = true;
|
||||
}
|
||||
|
||||
if (g_audioEngine.pDevice == nullptr)
|
||||
{
|
||||
return;
|
||||
|
|
@ -204,6 +197,5 @@ void EmbeddedPlayer::Shutdown()
|
|||
ma_engine_uninit(&g_audioEngine);
|
||||
}
|
||||
|
||||
g_audioEngineInitialized = false;
|
||||
s_isActive = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue