From fc6a2f490ffe9bfcf68d56549b4887e6ff5aa515 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 14 Jan 2016 01:19:25 -0500 Subject: [PATCH] Mixer: Directly initialize class members --- Source/Core/AudioCommon/Mixer.cpp | 14 +++-------- Source/Core/AudioCommon/Mixer.h | 42 +++++++++++++------------------ 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/Source/Core/AudioCommon/Mixer.cpp b/Source/Core/AudioCommon/Mixer.cpp index eff1dbe584..505a3b2551 100644 --- a/Source/Core/AudioCommon/Mixer.cpp +++ b/Source/Core/AudioCommon/Mixer.cpp @@ -6,11 +6,11 @@ #include "AudioCommon/AudioCommon.h" #include "AudioCommon/Mixer.h" -#include "Common/CPUDetect.h" +#include "Common/CommonFuncs.h" +#include "Common/CommonTypes.h" #include "Common/MathUtil.h" +#include "Common/Logging/Log.h" #include "Core/ConfigManager.h" -#include "Core/Core.h" -#include "Core/HW/AudioInterface.h" // UGLINESS #include "Core/PowerPC/PowerPC.h" @@ -20,13 +20,7 @@ #endif CMixer::CMixer(unsigned int BackendSampleRate) - : m_dma_mixer(this, 32000) - , m_streaming_mixer(this, 48000) - , m_wiimote_speaker_mixer(this, 3000) - , m_sampleRate(BackendSampleRate) - , m_log_dtk_audio(false) - , m_log_dsp_audio(false) - , m_speed(0) + : m_sampleRate(BackendSampleRate) { INFO_LOG(AUDIO_INTERFACE, "Mixer is initialized"); } diff --git a/Source/Core/AudioCommon/Mixer.h b/Source/Core/AudioCommon/Mixer.h index 75e47d9aef..be3d9f33c9 100644 --- a/Source/Core/AudioCommon/Mixer.h +++ b/Source/Core/AudioCommon/Mixer.h @@ -4,11 +4,11 @@ #pragma once +#include #include -#include -#include #include "AudioCommon/WaveFile.h" +#include "Common/CommonTypes.h" // 16 bit Stereo #define MAX_SAMPLES (1024 * 4) // 128 ms @@ -51,44 +51,38 @@ private: class MixerFifo final { public: - MixerFifo(CMixer *mixer, unsigned sample_rate) + MixerFifo(CMixer* mixer, unsigned sample_rate) : m_mixer(mixer) , m_input_sample_rate(sample_rate) - , m_indexW(0) - , m_indexR(0) - , m_LVolume(256) - , m_RVolume(256) - , m_numLeftI(0.0f) - , m_frac(0) { - memset(m_buffer, 0, sizeof(m_buffer)); } void PushSamples(const short* samples, unsigned int num_samples); unsigned int Mix(short* samples, unsigned int numSamples, bool consider_framelimit = true); void SetInputSampleRate(unsigned int rate); void SetVolume(unsigned int lvolume, unsigned int rvolume); private: - CMixer *m_mixer; + CMixer* m_mixer; unsigned m_input_sample_rate; - short m_buffer[MAX_SAMPLES * 2]; - std::atomic m_indexW; - std::atomic m_indexR; + std::array m_buffer{}; + std::atomic m_indexW{0}; + std::atomic m_indexR{0}; // Volume ranges from 0-256 - std::atomic m_LVolume; - std::atomic m_RVolume; - float m_numLeftI; - u32 m_frac; + std::atomic m_LVolume{256}; + std::atomic m_RVolume{256}; + float m_numLeftI = 0.0f; + u32 m_frac = 0; }; - MixerFifo m_dma_mixer; - MixerFifo m_streaming_mixer; - MixerFifo m_wiimote_speaker_mixer; + MixerFifo m_dma_mixer{this, 32000}; + MixerFifo m_streaming_mixer{this, 48000}; + MixerFifo m_wiimote_speaker_mixer{this, 3000}; unsigned int m_sampleRate; WaveFileWriter m_wave_writer_dtk; WaveFileWriter m_wave_writer_dsp; - bool m_log_dtk_audio; - bool m_log_dsp_audio; + bool m_log_dtk_audio = false; + bool m_log_dsp_audio = false; - std::atomic m_speed; // Current rate of the emulation (1.0 = 100% speed) + // Current rate of emulation (1.0 = 100% speed) + std::atomic m_speed{0.0f}; };