Skip to content

Commit

Permalink
Post merge fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Filoppi committed May 14, 2021
1 parent 78d7281 commit a49f4f0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 48 deletions.
53 changes: 15 additions & 38 deletions Source/Core/AudioCommon/AudioCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,49 +60,33 @@ static std::unique_ptr<SoundStream> CreateSoundStreamForBackend(std::string_view

void InitSoundStream()
{
std::lock_guard<std::mutex> guard(g_sound_stream_mutex);

std::string backend = SConfig::GetInstance().sBackend;
g_sound_stream = CreateSoundStreamForBackend(backend);
g_selected_sound_stream_failed = false;

if (!g_sound_stream)
{
WARN_LOG_FMT(AUDIO, "Unknown backend {}, using {} instead.", backend, GetDefaultSoundBackend());
WARN_LOG_FMT(AUDIO, "Unknown backend {}, using {} instead (default)", backend,
GetDefaultSoundBackend());
backend = GetDefaultSoundBackend();
g_sound_stream = CreateSoundStreamForBackend(GetDefaultSoundBackend());
g_sound_stream = CreateSoundStreamForBackend(backend);
}

if (!g_sound_stream || !g_sound_stream->Init())
{
WARN_LOG_FMT(AUDIO, "Could not initialize backend {}, using {} instead.", backend,
BACKEND_NULLSOUND);
WARN_LOG_FMT(AUDIO, "Could not initialize backend {}, using {} instead", backend,
NullSound::GetName());
g_sound_stream = std::make_unique<NullSound>();
g_sound_stream->Init();
g_sound_stream->Init(); // NullSound can't fail
g_selected_sound_stream_failed = true;
}
}

// This needs to be called after AudioInterface::Init where input sample rates are set
void PostInitSoundStream()
{
// This needs to be called after AudioInterface::Init where input sample rates are set
UpdateSoundStream();
std::lock_guard<std::mutex> guard(g_sound_stream_mutex);

std::string backend = SConfig::GetInstance().sBackend;
g_sound_stream = CreateSoundStreamForBackend(backend);
g_selected_sound_stream_failed = false;

if (!g_sound_stream)
{
WARN_LOG_FMT(AUDIO, "Unknown backend {}, using {} instead (default)", backend,
GetDefaultSoundBackend());
backend = GetDefaultSoundBackend();
g_sound_stream = CreateSoundStreamForBackend(backend);
}

if (!g_sound_stream || !g_sound_stream->Init())
{
WARN_LOG_FMT(AUDIO, "Could not initialize backend {}, using {} instead", backend,
NullSound::GetName());
g_sound_stream = std::make_unique<NullSound>();
g_sound_stream->Init(); // NullSound can't fail
g_selected_sound_stream_failed = true;
}
}

UpdateSoundStreamSettings(true);
// This can fail, but we don't really care as it just won't produce any sounds,
// also the user might be able to fix it up by changing their device settings
Expand All @@ -111,13 +95,6 @@ void PostInitSoundStream()
// and true again, so basically the backend is "restarted" with every emulation state change
SetSoundStreamRunning(true, true);

//To review: are these still needed after merge with master?
// 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()->SetStreamingInputSampleRate(AudioInterface::GetAISSampleRate());

if (SConfig::GetInstance().m_DumpAudio && !s_audio_dump_started)
StartAudioDump();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/AudioCommon/Mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Mixer::Mixer(u32 sample_rate)

Mixer::~Mixer()
{
INFO_LOG_FMT(AUDIO_INTERFACE, "Mixer is initialized");
INFO_LOG_FMT(AUDIO_INTERFACE, "Mixer is uninitialized");
}

void Mixer::SetPaused(bool paused)
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ bool IsSettingSaveable(const Config::Location& config_location)
&Config::MAIN_ALLOW_SD_WRITES.GetLocation(),
&Config::MAIN_DPL2_DECODER.GetLocation(),
&Config::MAIN_DPL2_QUALITY.GetLocation(),
&Config::MAIN_DPL2_BASS_REDIRECTION.location,
&Config::MAIN_AUDIO_MIXER_MIN_LATENCY.location,
&Config::MAIN_AUDIO_MIXER_MAX_LATENCY.location,
&Config::MAIN_DPL2_BASS_REDIRECTION.GetLocation(),
&Config::MAIN_AUDIO_MIXER_MIN_LATENCY.GetLocation(),
&Config::MAIN_AUDIO_MIXER_MAX_LATENCY.GetLocation(),
&Config::MAIN_RAM_OVERRIDE_ENABLE.GetLocation(),
&Config::MAIN_MEM1_SIZE.GetLocation(),
&Config::MAIN_MEM2_SIZE.GetLocation(),
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Core/HW/AudioInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,8 @@ void Init()

event_type_ai = CoreTiming::RegisterEvent("AICallback", Update);

//To review: this is now duplicate?
g_sound_stream->GetMixer()->SetDMAInputSampleRate(GetAIDSampleRate());
g_sound_stream->GetMixer()->SetStreamInputSampleRate(GetAISSampleRate());
g_sound_stream->GetMixer()->SetStreamingInputSampleRate(GetAISSampleRate());
}

void Shutdown()
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/HW/WiimoteEmu/Speaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void stopdamnwav()
}
#endif

void SpeakerLogic::SpeakerData(const u8* data, int length)
void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan)
{
if (reg_data.sample_rate == 0 || length == 0)
return;
Expand Down Expand Up @@ -174,7 +174,7 @@ void SpeakerLogic::SpeakerData(const u8* data, int length)
// We should play the samples from the wiimote at the native volume they came with,
// because you can lower their volume from the wii settings, and because they are
// already extremely low quality, so any additional quality loss isn't welcome.
float speaker_pan = std::clamp(float(m_speaker_pan_setting.GetValue()) / 100, -1.f, 1.f);
speaker_pan = std::clamp(speaker_pan, -1.f, 1.f);
const u32 l_volume = std::min(u32(std::min(1.f - speaker_pan, 1.f) * volume), 255u);
const u32 r_volume = std::min(u32(std::min(1.f + speaker_pan, 1.f) * volume), 255u);

Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ void Wiimote::Reset()
m_i2c_bus.AddSlave(&m_speaker_logic);
m_i2c_bus.AddSlave(&m_camera_logic);

//To review: is this needed now?
m_speaker_logic.m_index = m_index;

// Reset extension connections to NONE:
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static Common::Event g_compressAndDumpStateSyncEvent;
static std::thread g_save_thread;

// Don't forget to increase this after doing changes on the savestate system
constexpr u32 STATE_VERSION = 131; // Last changed in PR ????
constexpr u32 STATE_VERSION = 130; // Last changed in PR 9545

// Maps savestate versions to Dolphin versions.
// Versions after 42 don't need to be added to this list,
Expand Down

0 comments on commit a49f4f0

Please sign in to comment.