summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2021-03-24 14:18:15 +0100
committerGitHub <noreply@github.com>2021-03-24 14:18:15 +0100
commitfa04e5a7d3df4007ce3aad9bbfeb0bd1cf2d15f1 (patch)
treef75e8d69bc875a716ed1c09f8e4719cbba9c98cd /Source
parent75f8ce10f90e1318d56a8fd2ca30fd87dba37895 (diff)
parent66e39de1ab984b311dd1e928d5af679b45fd80b3 (diff)
Merge pull request #9603 from Bonta0/audio-init
AudioCommon: Split Initialization
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/AudioCommon/AudioCommon.cpp11
-rw-r--r--Source/Core/AudioCommon/AudioCommon.h1
-rw-r--r--Source/Core/Core/Core.cpp6
-rw-r--r--Source/Core/Core/HW/AudioInterface.cpp3
4 files changed, 12 insertions, 9 deletions
diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp
index 3d7705bba1..e6a9e679ff 100644
--- a/Source/Core/AudioCommon/AudioCommon.cpp
+++ b/Source/Core/AudioCommon/AudioCommon.cpp
@@ -15,7 +15,6 @@
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Core/ConfigManager.h"
-#include "Core/HW/AudioInterface.h"
// This shouldn't be a global, at least not here.
std::unique_ptr<SoundStream> g_sound_stream;
@@ -66,13 +65,11 @@ void InitSoundStream()
g_sound_stream = std::make_unique<NullSound>();
g_sound_stream->Init();
}
+}
- // Ideally these two calls would be done in AudioInterface::Init so that we don't
- // need to have a dependency on AudioInterface here, but this has to be done
- // after creating g_sound_stream (above) and before starting audio dumping (below)
- g_sound_stream->GetMixer()->SetDMAInputSampleRate(AudioInterface::GetAIDSampleRate());
- g_sound_stream->GetMixer()->SetStreamInputSampleRate(AudioInterface::GetAISSampleRate());
-
+void PostInitSoundStream()
+{
+ // This needs to be called after AudioInterface::Init where input sample rates are set
UpdateSoundStream();
SetSoundStreamRunning(true);
diff --git a/Source/Core/AudioCommon/AudioCommon.h b/Source/Core/AudioCommon/AudioCommon.h
index a294057590..e30c0acfbe 100644
--- a/Source/Core/AudioCommon/AudioCommon.h
+++ b/Source/Core/AudioCommon/AudioCommon.h
@@ -19,6 +19,7 @@ extern std::unique_ptr<SoundStream> g_sound_stream;
namespace AudioCommon
{
void InitSoundStream();
+void PostInitSoundStream();
void ShutdownSoundStream();
std::string GetDefaultSoundBackend();
std::vector<std::string> GetSoundBackends();
diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp
index 99e7624b55..3e269c7b73 100644
--- a/Source/Core/Core/Core.cpp
+++ b/Source/Core/Core/Core.cpp
@@ -516,6 +516,9 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
Movie::Init(*boot);
Common::ScopeGuard movie_guard{&Movie::Shutdown};
+ AudioCommon::InitSoundStream();
+ Common::ScopeGuard audio_guard{&AudioCommon::ShutdownSoundStream};
+
HW::Init();
Common::ScopeGuard hw_guard{[] {
@@ -566,8 +569,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
// it's now ok to initialize any custom textures
HiresTexture::Update();
- AudioCommon::InitSoundStream();
- Common::ScopeGuard audio_guard{&AudioCommon::ShutdownSoundStream};
+ AudioCommon::PostInitSoundStream();
// The hardware is initialized.
s_hardware_initialized = true;
diff --git a/Source/Core/Core/HW/AudioInterface.cpp b/Source/Core/Core/HW/AudioInterface.cpp
index 4ccf581e9c..82f1418368 100644
--- a/Source/Core/Core/HW/AudioInterface.cpp
+++ b/Source/Core/Core/HW/AudioInterface.cpp
@@ -153,6 +153,9 @@ void Init()
s_aid_sample_rate = Get32KHzSampleRate();
event_type_ai = CoreTiming::RegisterEvent("AICallback", Update);
+
+ g_sound_stream->GetMixer()->SetDMAInputSampleRate(GetAIDSampleRate());
+ g_sound_stream->GetMixer()->SetStreamInputSampleRate(GetAISSampleRate());
}
void Shutdown()