Merge 7c12e2b5eb
into 53b54406bd
This commit is contained in:
commit
eeba1f8b0a
|
@ -166,7 +166,8 @@ void UpdateSoundStream(Core::System& system)
|
|||
|
||||
if (sound_stream)
|
||||
{
|
||||
int volume = Config::Get(Config::MAIN_AUDIO_MUTED) ? 0 : Config::Get(Config::MAIN_AUDIO_VOLUME);
|
||||
const int volume =
|
||||
Config::Get(Config::MAIN_AUDIO_MUTED) ? 0 : Config::Get(Config::MAIN_AUDIO_VOLUME);
|
||||
sound_stream->SetVolume(volume);
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +193,7 @@ void SetSoundStreamRunning(Core::System& system, bool running)
|
|||
|
||||
void SendAIBuffer(Core::System& system, const short* samples, unsigned int num_samples)
|
||||
{
|
||||
SoundStream* sound_stream = system.GetSoundStream();
|
||||
const SoundStream* sound_stream = system.GetSoundStream();
|
||||
|
||||
if (!sound_stream)
|
||||
return;
|
||||
|
@ -212,9 +213,9 @@ void SendAIBuffer(Core::System& system, const short* samples, unsigned int num_s
|
|||
|
||||
void StartAudioDump(Core::System& system)
|
||||
{
|
||||
SoundStream* sound_stream = system.GetSoundStream();
|
||||
const SoundStream* sound_stream = system.GetSoundStream();
|
||||
|
||||
std::time_t 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();
|
||||
|
||||
|
@ -232,7 +233,7 @@ void StartAudioDump(Core::System& system)
|
|||
|
||||
void StopAudioDump(Core::System& system)
|
||||
{
|
||||
SoundStream* sound_stream = system.GetSoundStream();
|
||||
const SoundStream* sound_stream = system.GetSoundStream();
|
||||
|
||||
if (!sound_stream)
|
||||
return;
|
||||
|
@ -265,7 +266,7 @@ void DecreaseVolume(Core::System& system, unsigned short offset)
|
|||
|
||||
void ToggleMuteVolume(Core::System& system)
|
||||
{
|
||||
bool isMuted = Config::Get(Config::MAIN_AUDIO_MUTED);
|
||||
const bool isMuted = Config::Get(Config::MAIN_AUDIO_MUTED);
|
||||
Config::SetBaseOrCurrent(Config::MAIN_AUDIO_MUTED, !isMuted);
|
||||
UpdateSoundStream(system);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ constexpr u32 BUFFER_SAMPLES = 512;
|
|||
long CubebStream::DataCallback(cubeb_stream* stream, void* user_data, const void* /*input_buffer*/,
|
||||
void* output_buffer, long num_frames)
|
||||
{
|
||||
auto* self = static_cast<CubebStream*>(user_data);
|
||||
const auto* self = static_cast<CubebStream*>(user_data);
|
||||
|
||||
if (self->m_stereo)
|
||||
self->m_mixer->Mix(static_cast<short*>(output_buffer), num_frames);
|
||||
|
@ -44,7 +44,7 @@ CubebStream::CubebStream()
|
|||
Common::Event sync_event;
|
||||
m_work_queue.Push([this, &sync_event] {
|
||||
Common::ScopeGuard sync_event_guard([&sync_event] { sync_event.Set(); });
|
||||
auto 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_should_couninit = result == S_OK || result == S_FALSE;
|
||||
});
|
||||
|
|
|
@ -182,7 +182,8 @@ std::size_t Mixer::MixSurround(float* samples, std::size_t num_samples)
|
|||
|
||||
memset(samples, 0, num_samples * SURROUND_CHANNELS * sizeof(float));
|
||||
|
||||
std::size_t needed_frames = m_surround_decoder.QueryFramesNeededForSurroundOutput(num_samples);
|
||||
const std::size_t needed_frames =
|
||||
m_surround_decoder.QueryFramesNeededForSurroundOutput(num_samples);
|
||||
|
||||
constexpr std::size_t max_samples = 0x8000;
|
||||
ASSERT_MSG(AUDIO, needed_frames <= max_samples,
|
||||
|
@ -190,7 +191,7 @@ std::size_t Mixer::MixSurround(float* samples, std::size_t num_samples)
|
|||
needed_frames, max_samples);
|
||||
|
||||
std::array<s16, max_samples> buffer;
|
||||
std::size_t 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)
|
||||
{
|
||||
ERROR_LOG_FMT(AUDIO,
|
||||
|
@ -229,7 +230,7 @@ void Mixer::PushSamples(const s16* samples, std::size_t num_samples)
|
|||
if (m_log_dsp_audio)
|
||||
{
|
||||
const s32 sample_rate_divisor = m_dma_mixer.GetInputSampleRateDivisor();
|
||||
auto volume = m_dma_mixer.GetVolume();
|
||||
const auto volume = m_dma_mixer.GetVolume();
|
||||
m_wave_writer_dsp.AddStereoSamplesBE(samples, static_cast<u32>(num_samples),
|
||||
sample_rate_divisor, volume.first, volume.second);
|
||||
}
|
||||
|
@ -241,7 +242,7 @@ void Mixer::PushStreamingSamples(const s16* samples, std::size_t num_samples)
|
|||
if (m_log_dtk_audio)
|
||||
{
|
||||
const s32 sample_rate_divisor = m_streaming_mixer.GetInputSampleRateDivisor();
|
||||
auto volume = m_streaming_mixer.GetVolume();
|
||||
const auto volume = m_streaming_mixer.GetVolume();
|
||||
m_wave_writer_dtk.AddStereoSamplesBE(samples, static_cast<u32>(num_samples),
|
||||
sample_rate_divisor, volume.first, volume.second);
|
||||
}
|
||||
|
@ -286,7 +287,8 @@ void Mixer::PushSkylanderPortalSamples(const u8* samples, std::size_t num_sample
|
|||
{
|
||||
for (std::size_t i = 0; i < num_samples; ++i)
|
||||
{
|
||||
s16 sample = static_cast<u16>(samples[i * 2 + 1]) << 8 | static_cast<u16>(samples[i * 2]);
|
||||
const s16 sample =
|
||||
static_cast<u16>(samples[i * 2 + 1]) << 8 | static_cast<u16>(samples[i * 2]);
|
||||
samples_stereo[i * 2] = sample;
|
||||
samples_stereo[i * 2 + 1] = sample;
|
||||
}
|
||||
|
@ -335,7 +337,8 @@ void Mixer::StartLogDTKAudio(const std::string& filename)
|
|||
{
|
||||
if (!m_log_dtk_audio)
|
||||
{
|
||||
bool success = m_wave_writer_dtk.Start(filename, m_streaming_mixer.GetInputSampleRateDivisor());
|
||||
const bool success =
|
||||
m_wave_writer_dtk.Start(filename, m_streaming_mixer.GetInputSampleRateDivisor());
|
||||
if (success)
|
||||
{
|
||||
m_log_dtk_audio = true;
|
||||
|
@ -372,7 +375,7 @@ void Mixer::StartLogDSPAudio(const std::string& filename)
|
|||
{
|
||||
if (!m_log_dsp_audio)
|
||||
{
|
||||
bool 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)
|
||||
{
|
||||
m_log_dsp_audio = true;
|
||||
|
@ -497,7 +500,7 @@ void Mixer::MixerFifo::Enqueue()
|
|||
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)
|
||||
std::size_t 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))
|
||||
{
|
||||
WARN_LOG_FMT(AUDIO,
|
||||
|
|
|
@ -76,7 +76,7 @@ static bool InitLibrary()
|
|||
|
||||
if (!InitFunctions())
|
||||
{
|
||||
::FreeLibrary(s_openal_dll);
|
||||
FreeLibrary(s_openal_dll);
|
||||
s_openal_dll = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ bool OpenALStream::SetRunning(bool running)
|
|||
|
||||
static ALenum CheckALError(const char* desc)
|
||||
{
|
||||
ALenum err = palGetError();
|
||||
const ALenum err = palGetError();
|
||||
|
||||
if (err != AL_NO_ERROR)
|
||||
{
|
||||
|
@ -211,16 +211,16 @@ void OpenALStream::SoundLoop()
|
|||
{
|
||||
Common::SetCurrentThreadName("Audio thread - openal");
|
||||
|
||||
bool float32_capable = palIsExtensionPresent("AL_EXT_float32") != 0;
|
||||
bool surround_capable = palIsExtensionPresent("AL_EXT_MCFORMATS") || IsCreativeXFi();
|
||||
const bool float32_capable = palIsExtensionPresent("AL_EXT_float32") != 0;
|
||||
const bool surround_capable = palIsExtensionPresent("AL_EXT_MCFORMATS") || IsCreativeXFi();
|
||||
bool use_surround = Config::ShouldUseDPL2Decoder() && surround_capable;
|
||||
|
||||
// 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,
|
||||
// we just check if one is being used.
|
||||
bool fixed32_capable = IsCreativeXFi();
|
||||
const bool fixed32_capable = IsCreativeXFi();
|
||||
|
||||
u32 frequency = m_mixer->GetSampleRate();
|
||||
const u32 frequency = m_mixer->GetSampleRate();
|
||||
|
||||
u32 frames_per_buffer;
|
||||
// Can't have zero samples per buffer
|
||||
|
@ -288,12 +288,12 @@ void OpenALStream::SoundLoop()
|
|||
num_buffers_queued -= num_buffers_processed;
|
||||
}
|
||||
|
||||
unsigned int min_frames = frames_per_buffer;
|
||||
const unsigned int min_frames = frames_per_buffer;
|
||||
|
||||
if (use_surround)
|
||||
{
|
||||
std::array<float, OAL_MAX_FRAMES * SURROUND_CHANNELS> dpl2;
|
||||
u32 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)
|
||||
continue;
|
||||
|
@ -351,7 +351,8 @@ void OpenALStream::SoundLoop()
|
|||
}
|
||||
else
|
||||
{
|
||||
u32 rendered_frames = static_cast<u32>(m_mixer->Mix(m_realtime_buffer.data(), min_frames));
|
||||
const u32 rendered_frames =
|
||||
static_cast<u32>(m_mixer->Mix(m_realtime_buffer.data(), min_frames));
|
||||
|
||||
if (!rendered_frames)
|
||||
continue;
|
||||
|
|
|
@ -32,7 +32,7 @@ size_t SurroundDecoder::QueryFramesNeededForSurroundOutput(const size_t output_f
|
|||
if (m_decoded_fifo.size() < output_frames * SURROUND_CHANNELS)
|
||||
{
|
||||
// Output stereo frames needed to have at least the desired number of surround frames
|
||||
size_t 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -159,8 +159,9 @@ ComPtr<IMMDevice> WASAPIStream::GetDeviceByName(std::string_view name)
|
|||
bool WASAPIStream::Init()
|
||||
{
|
||||
ASSERT(m_enumerator == nullptr);
|
||||
HRESULT result = CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(m_enumerator.GetAddressOf()));
|
||||
const HRESULT result =
|
||||
CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(m_enumerator.GetAddressOf()));
|
||||
|
||||
if (!HandleWinAPI("Failed to create MMDeviceEnumerator", result))
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue