1
0
mirror of https://github.com/blawar/ooot.git synced 2024-06-25 22:09:34 +00:00

Added AudioMgr_Shutdown.

This commit is contained in:
DaMarkov 2022-03-01 23:59:49 +01:00
parent 0c3f220837
commit 4e64d4574a
3 changed files with 20 additions and 4 deletions

View File

@ -8,4 +8,4 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr);
void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr);
void AudioMgr_ThreadEntry(void* arg0);
void AudioMgr_Unlock(AudioMgr* audioMgr);
void func_800C3C80(AudioMgr* audioMgr);
void AudioMgr_Shutdown();

View File

@ -91,6 +91,7 @@ void audio_int()
}
static AudioTask* g_currentAudioTask = nullptr;
static bool g_aziInit = false;
void audio_thread()
{
@ -100,7 +101,7 @@ void audio_thread()
const auto interval = std::chrono::microseconds(1000 * 1000 / 60);
auto targetTime = std::chrono::high_resolution_clock::now() + interval;
while(true)
while(g_aziInit)
{
if(std::chrono::high_resolution_clock::now() > targetTime)
{
@ -123,8 +124,6 @@ void audio_thread()
std::unique_ptr<std::thread> t1;
static bool g_aziInit = false;
void azi_init()
{
if(g_aziInit)
@ -166,3 +165,17 @@ void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedCon
t1 = std::make_unique<std::thread>(audio_thread);
}
void AudioMgr_Shutdown()
{
Sleep(500);//Wait until the audio buffer finishes playing
CloseDLL();//Shut down Azi
Sleep(1000);//Keep the audio thread open a bit longer
g_aziInit = false;//Thread closes now
if (t1->joinable())
t1->join();
}

View File

@ -11,6 +11,7 @@
#include "z64audio.h"
#include "controller/controllers.h"
#include "def/audio_rsp.h"
#include "def/audioMgr.h"
static std::unique_ptr<platform::window::Base> gWindow;
@ -150,6 +151,8 @@ void main_func(void)
Graph_ThreadEntry(0);
AudioMgr_Shutdown();
gfx_shutdown();
}