36 changes: 36 additions & 0 deletions Source/Core/Core/System.cpp
Expand Up @@ -3,12 +3,18 @@

#include "Core/System.h"

#include <memory>

#include "AudioCommon/SoundStream.h"
#include "Core/Config/MainSettings.h"

namespace Core
{
struct System::Impl
{
std::unique_ptr<SoundStream> m_sound_stream;
bool m_sound_stream_running = false;
bool m_audio_dump_started = false;
};

System::System() : m_impl{std::make_unique<Impl>()}
Expand All @@ -22,4 +28,34 @@ void System::Initialize()
m_separate_cpu_and_gpu_threads = Config::Get(Config::MAIN_CPU_THREAD);
m_mmu_enabled = Config::Get(Config::MAIN_MMU);
}

SoundStream* System::GetSoundStream() const
{
return m_impl->m_sound_stream.get();
}

void System::SetSoundStream(std::unique_ptr<SoundStream> sound_stream)
{
m_impl->m_sound_stream = std::move(sound_stream);
}

bool System::IsSoundStreamRunning() const
{
return m_impl->m_sound_stream_running;
}

void System::SetSoundStreamRunning(bool running)
{
m_impl->m_sound_stream_running = running;
}

bool System::IsAudioDumpStarted() const
{
return m_impl->m_audio_dump_started;
}

void System::SetAudioDumpStarted(bool started)
{
m_impl->m_audio_dump_started = started;
}
} // namespace Core
9 changes: 9 additions & 0 deletions Source/Core/Core/System.h
Expand Up @@ -5,6 +5,8 @@

#include <memory>

class SoundStream;

namespace Core
{
// Central class that encapsulates the running system.
Expand All @@ -31,6 +33,13 @@ class System
bool IsDualCoreMode() const { return m_separate_cpu_and_gpu_threads; }
bool IsMMUMode() const { return m_mmu_enabled; }

SoundStream* GetSoundStream() const;
void SetSoundStream(std::unique_ptr<SoundStream> sound_stream);
bool IsSoundStreamRunning() const;
void SetSoundStreamRunning(bool running);
bool IsAudioDumpStarted() const;
void SetAudioDumpStarted(bool started);

private:
System();

Expand Down
4 changes: 3 additions & 1 deletion Source/Core/DolphinQt/GBAWidget.cpp
Expand Up @@ -26,6 +26,7 @@
#include "Core/HW/SI/SI_Device.h"
#include "Core/Movie.h"
#include "Core/NetPlayProto.h"
#include "Core/System.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/Resources.h"
Expand Down Expand Up @@ -325,7 +326,8 @@ void GBAWidget::UpdateTitle()
void GBAWidget::UpdateVolume()
{
int volume = m_muted ? 0 : m_volume * 256 / 100;
g_sound_stream->GetMixer()->SetGBAVolume(m_core_info.device_number, volume, volume);
auto& system = Core::System::GetInstance();
system.GetSoundStream()->GetMixer()->SetGBAVolume(m_core_info.device_number, volume, volume);
UpdateTitle();
}

Expand Down