Merge pull request #14505 from Dentomologist/audiocommon_use_left_const_for_nonpointer_variables

AudioCommon: Use left const for non-pointer variables
This commit is contained in:
Jordan Woyak authored and GitHub committed 2026-03-24 00:25:53 -05:00
commit 2b6667a98d
6 files changed
+22 -22

No files matched your search

+3 -3
View File
@@ -167,7 +167,7 @@ void UpdateSoundStream(Core::System& system)
if (sound_stream) if (sound_stream)
{ {
int const volume = const int volume =
Config::Get(Config::MAIN_AUDIO_MUTED) ? 0 : Config::Get(Config::MAIN_AUDIO_VOLUME); Config::Get(Config::MAIN_AUDIO_MUTED) ? 0 : Config::Get(Config::MAIN_AUDIO_VOLUME);
sound_stream->SetVolume(volume); sound_stream->SetVolume(volume);
} }
@@ -216,7 +216,7 @@ void StartAudioDump(Core::System& system)
{ {
const SoundStream* const sound_stream = system.GetSoundStream(); const SoundStream* const sound_stream = system.GetSoundStream();
std::time_t const start_time = std::time(nullptr); const std::time_t start_time = std::time(nullptr);
std::string path_prefix = File::GetUserPath(D_DUMPAUDIO_IDX) + SConfig::GetInstance().GetGameID(); std::string path_prefix = File::GetUserPath(D_DUMPAUDIO_IDX) + SConfig::GetInstance().GetGameID();
@@ -270,7 +270,7 @@ void DecreaseVolume(Core::System& system, unsigned short offset)
void ToggleMuteVolume(Core::System& system) void ToggleMuteVolume(Core::System& system)
{ {
bool const isMuted = Config::Get(Config::MAIN_AUDIO_MUTED); const bool isMuted = Config::Get(Config::MAIN_AUDIO_MUTED);
Config::SetBaseOrCurrent(Config::MAIN_AUDIO_MUTED, !isMuted); Config::SetBaseOrCurrent(Config::MAIN_AUDIO_MUTED, !isMuted);
UpdateSoundStream(system); UpdateSoundStream(system);
} }
+1 -1
View File
@@ -39,7 +39,7 @@ CubebStream::CubebStream()
: m_work_queue("Cubeb Worker") : m_work_queue("Cubeb Worker")
{ {
m_work_queue.PushBlocking([this] { m_work_queue.PushBlocking([this] {
auto const result = CoInitializeEx(nullptr, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE); const auto result = CoInitializeEx(nullptr, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE);
m_coinit_success = result == S_OK; m_coinit_success = result == S_OK;
m_should_couninit = result == S_OK || result == S_FALSE; m_should_couninit = result == S_OK || result == S_FALSE;
}); });
+8 -8
View File
@@ -184,7 +184,7 @@ std::size_t Mixer::MixSurround(float* samples, std::size_t num_samples)
memset(samples, 0, num_samples * SURROUND_CHANNELS * sizeof(float)); memset(samples, 0, num_samples * SURROUND_CHANNELS * sizeof(float));
std::size_t const needed_frames = const std::size_t needed_frames =
m_surround_decoder.QueryFramesNeededForSurroundOutput(num_samples); m_surround_decoder.QueryFramesNeededForSurroundOutput(num_samples);
constexpr std::size_t max_samples = 0x8000; constexpr std::size_t max_samples = 0x8000;
@@ -193,7 +193,7 @@ std::size_t Mixer::MixSurround(float* samples, std::size_t num_samples)
needed_frames, max_samples); needed_frames, max_samples);
std::array<s16, max_samples> buffer; std::array<s16, max_samples> buffer;
std::size_t const available_frames = Mix(buffer.data(), static_cast<std::size_t>(needed_frames)); const std::size_t available_frames = Mix(buffer.data(), static_cast<std::size_t>(needed_frames));
if (available_frames != needed_frames) if (available_frames != needed_frames)
{ {
ERROR_LOG_FMT(AUDIO, ERROR_LOG_FMT(AUDIO,
@@ -252,7 +252,7 @@ void Mixer::PushStreamingSamples(const s16* samples, std::size_t num_samples)
if (m_log_dtk_audio) if (m_log_dtk_audio)
{ {
const s32 sample_rate_divisor = m_streaming_mixer.GetInputSampleRateDivisor(); const s32 sample_rate_divisor = m_streaming_mixer.GetInputSampleRateDivisor();
auto const volume = m_streaming_mixer.GetVolume(); const auto volume = m_streaming_mixer.GetVolume();
m_wave_writer_dtk.AddStereoSamplesBE(samples, static_cast<u32>(num_samples), m_wave_writer_dtk.AddStereoSamplesBE(samples, static_cast<u32>(num_samples),
sample_rate_divisor, volume.first, volume.second); sample_rate_divisor, volume.first, volume.second);
} }
@@ -303,7 +303,7 @@ void Mixer::PushSkylanderPortalSamples(const u8* samples, std::size_t num_sample
{ {
for (std::size_t i = 0; i < num_samples; ++i) for (std::size_t i = 0; i < num_samples; ++i)
{ {
s16 const sample = const s16 sample =
static_cast<u16>(samples[i * 2 + 1]) << 8 | static_cast<u16>(samples[i * 2]); static_cast<u16>(samples[i * 2 + 1]) << 8 | static_cast<u16>(samples[i * 2]);
samples_stereo[i * 2] = sample; samples_stereo[i * 2] = sample;
samples_stereo[i * 2 + 1] = sample; samples_stereo[i * 2 + 1] = sample;
@@ -356,7 +356,7 @@ void Mixer::StartLogDTKAudio(const std::string& filename)
{ {
if (!m_log_dtk_audio) if (!m_log_dtk_audio)
{ {
bool const success = const bool success =
m_wave_writer_dtk.Start(filename, m_streaming_mixer.GetInputSampleRateDivisor()); m_wave_writer_dtk.Start(filename, m_streaming_mixer.GetInputSampleRateDivisor());
if (success) if (success)
{ {
@@ -394,7 +394,7 @@ void Mixer::StartLogDSPAudio(const std::string& filename)
{ {
if (!m_log_dsp_audio) if (!m_log_dsp_audio)
{ {
bool const success = m_wave_writer_dsp.Start(filename, m_dma_mixer.GetInputSampleRateDivisor()); const bool success = m_wave_writer_dsp.Start(filename, m_dma_mixer.GetInputSampleRateDivisor());
if (success) if (success)
{ {
m_log_dsp_audio = true; m_log_dsp_audio = true;
@@ -517,10 +517,10 @@ void Mixer::MixerFifo::Enqueue()
0.0002984010f, 0.0002102045f, 0.0001443499f, 0.0000961509f, 0.0000616906f, 0.0000377350f, 0.0002984010f, 0.0002102045f, 0.0001443499f, 0.0000961509f, 0.0000616906f, 0.0000377350f,
0.0000216492f, 0.0000113187f, 0.0000050749f, 0.0000016272f}; 0.0000216492f, 0.0000113187f, 0.0000050749f, 0.0000016272f};
std::size_t const head = m_queue_head.load(std::memory_order_acquire); const std::size_t head = m_queue_head.load(std::memory_order_acquire);
// Check if we run out of space in the circular queue. (rare) // Check if we run out of space in the circular queue. (rare)
std::size_t const next_head = (head + 1) & GRANULE_QUEUE_MASK; const std::size_t next_head = (head + 1) & GRANULE_QUEUE_MASK;
if (next_head == m_queue_tail.load(std::memory_order_acquire)) if (next_head == m_queue_tail.load(std::memory_order_acquire))
{ {
WARN_LOG_FMT(AUDIO, WARN_LOG_FMT(AUDIO,
+8 -8
View File
@@ -168,7 +168,7 @@ bool OpenALStream::SetRunning(bool running)
static ALenum CheckALError(const char* desc) static ALenum CheckALError(const char* desc)
{ {
ALenum const err = palGetError(); const ALenum err = palGetError();
if (err != AL_NO_ERROR) if (err != AL_NO_ERROR)
{ {
@@ -211,16 +211,16 @@ void OpenALStream::SoundLoop()
{ {
Common::SetCurrentThreadName("Audio thread - openal"); Common::SetCurrentThreadName("Audio thread - openal");
bool const float32_capable = palIsExtensionPresent("AL_EXT_float32") != 0; const bool float32_capable = palIsExtensionPresent("AL_EXT_float32") != 0;
bool const surround_capable = palIsExtensionPresent("AL_EXT_MCFORMATS") || IsCreativeXFi(); const bool surround_capable = palIsExtensionPresent("AL_EXT_MCFORMATS") || IsCreativeXFi();
bool use_surround = Config::ShouldUseDPL2Decoder() && surround_capable; bool use_surround = Config::ShouldUseDPL2Decoder() && surround_capable;
// As there is no extension to check for 32-bit fixed point support // As there is no extension to check for 32-bit fixed point support
// and we know that only a X-Fi with hardware OpenAL supports it, // and we know that only a X-Fi with hardware OpenAL supports it,
// we just check if one is being used. // we just check if one is being used.
bool const fixed32_capable = IsCreativeXFi(); const bool fixed32_capable = IsCreativeXFi();
u32 const frequency = m_mixer->GetSampleRate(); const u32 frequency = m_mixer->GetSampleRate();
u32 frames_per_buffer; u32 frames_per_buffer;
// Can't have zero samples per buffer // Can't have zero samples per buffer
@@ -288,12 +288,12 @@ void OpenALStream::SoundLoop()
num_buffers_queued -= num_buffers_processed; num_buffers_queued -= num_buffers_processed;
} }
unsigned int const min_frames = frames_per_buffer; const unsigned int min_frames = frames_per_buffer;
if (use_surround) if (use_surround)
{ {
std::array<float, OAL_MAX_FRAMES * SURROUND_CHANNELS> dpl2; std::array<float, OAL_MAX_FRAMES * SURROUND_CHANNELS> dpl2;
u32 const rendered_frames = static_cast<u32>(m_mixer->MixSurround(dpl2.data(), min_frames)); const u32 rendered_frames = static_cast<u32>(m_mixer->MixSurround(dpl2.data(), min_frames));
if (rendered_frames < min_frames) if (rendered_frames < min_frames)
continue; continue;
@@ -351,7 +351,7 @@ void OpenALStream::SoundLoop()
} }
else else
{ {
u32 const rendered_frames = const u32 rendered_frames =
static_cast<u32>(m_mixer->Mix(m_realtime_buffer.data(), min_frames)); static_cast<u32>(m_mixer->Mix(m_realtime_buffer.data(), min_frames));
if (!rendered_frames) if (!rendered_frames)
+1 -1
View File
@@ -32,7 +32,7 @@ size_t SurroundDecoder::QueryFramesNeededForSurroundOutput(const size_t output_f
if (m_decoded_fifo.size() < output_frames * SURROUND_CHANNELS) if (m_decoded_fifo.size() < output_frames * SURROUND_CHANNELS)
{ {
// Output stereo frames needed to have at least the desired number of surround frames // Output stereo frames needed to have at least the desired number of surround frames
size_t const frames_needed = output_frames - m_decoded_fifo.size() / SURROUND_CHANNELS; const size_t frames_needed = output_frames - m_decoded_fifo.size() / SURROUND_CHANNELS;
return frames_needed + m_frame_block_size - frames_needed % m_frame_block_size; return frames_needed + m_frame_block_size - frames_needed % m_frame_block_size;
} }
+1 -1
View File
@@ -159,7 +159,7 @@ ComPtr<IMMDevice> WASAPIStream::GetDeviceByName(std::string_view name)
bool WASAPIStream::Init() bool WASAPIStream::Init()
{ {
ASSERT(m_enumerator == nullptr); ASSERT(m_enumerator == nullptr);
HRESULT const result = CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, const HRESULT result = CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr,
CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_enumerator)); CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_enumerator));
if (!HandleWinAPI("Failed to create MMDeviceEnumerator", result)) if (!HandleWinAPI("Failed to create MMDeviceEnumerator", result))