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 a62c4e0
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Externals/FreeSurround/source/FreeSurroundDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void DPL2FSDecoder::Init(channel_setup chsetup, unsigned int blsize,
memcpy(&outbuf[i], &outbuf[prev_size - C], sizeof(float) * C);
}
}
for (unsigned int k = 0; k < std::min(C, unsigned int(signal.size())); k++)
for (unsigned int k = 0; k < std::min(C, static_cast<unsigned int>(signal.size())); k++)
signal[k].resize(N);
signal.resize(C, std::vector<cplx>(N));

Expand Down
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
3 changes: 2 additions & 1 deletion Source/Core/AudioCommon/Mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Mixer::Mixer(u32 sample_rate)

Mixer::~Mixer()
{
INFO_LOG_FMT(AUDIO_INTERFACE, "Mixer is initialized");
INFO_LOG_FMT(AUDIO_INTERFACE, "Mixer is uninitialized");
Core::RemoveOnStateChangedCallback(&m_on_state_changed_handle);
}

void Mixer::SetPaused(bool paused)
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/AudioCommon/Mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class Mixer final
{
public:
MixerFifo(Mixer* mixer, unsigned sample_rate, bool big_endians, bool constantly_pushed = true)
: m_mixer(mixer), m_input_sample_rate(sample_rate),
m_big_endians(big_endians), m_constantly_pushed(constantly_pushed)
: m_mixer(mixer), m_input_sample_rate(sample_rate), m_constantly_pushed(constantly_pushed),
m_big_endians(big_endians)
{
}
void DoState(PointerWrap& p);
Expand Down Expand Up @@ -191,7 +191,7 @@ class Mixer final

u32 m_sample_rate; // Only changed by main or emulation thread when the backend is not running
bool m_stretching = false;
bool m_update_surround_latency = false;
bool m_update_surround_latency = false; //To delete?
AudioCommon::AudioStretcher m_stretcher;
AudioCommon::SurroundDecoder m_surround_decoder;

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
3 changes: 3 additions & 0 deletions Source/Core/DolphinLib.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="AudioCommon\AudioCommon.h" />
<ClInclude Include="AudioCommon\AudioSpeedCounter.h" />
<ClInclude Include="AudioCommon\AudioStretcher.h" />
<ClInclude Include="AudioCommon\CubebStream.h" />
<ClInclude Include="AudioCommon\CubebUtils.h" />
Expand Down Expand Up @@ -667,12 +668,14 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="AudioCommon\AudioCommon.cpp" />
<ClCompile Include="AudioCommon\AudioSpeedCounter.cpp" />
<ClCompile Include="AudioCommon\AudioStretcher.cpp" />
<ClCompile Include="AudioCommon\CubebStream.cpp" />
<ClCompile Include="AudioCommon\CubebUtils.cpp" />
<ClCompile Include="AudioCommon\Mixer.cpp" />
<ClCompile Include="AudioCommon\NullSoundStream.cpp" />
<ClCompile Include="AudioCommon\OpenALStream.cpp" />
<ClCompile Include="AudioCommon\SoundStream.cpp" />
<ClCompile Include="AudioCommon\SurroundDecoder.cpp" />
<ClCompile Include="AudioCommon\WASAPIStream.cpp" />
<ClCompile Include="AudioCommon\WaveFile.cpp" />
Expand Down

0 comments on commit a62c4e0

Please sign in to comment.