Mixer: Directly initialize class members

This commit is contained in:
Lioncash 2016-01-14 01:19:25 -05:00
parent 531a3ed09a
commit fc6a2f490f
2 changed files with 22 additions and 34 deletions

View File

@ -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");
}

View File

@ -4,11 +4,11 @@
#pragma once
#include <array>
#include <atomic>
#include <cstring>
#include <mutex>
#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<u32> m_indexW;
std::atomic<u32> m_indexR;
std::array<short, MAX_SAMPLES * 2> m_buffer{};
std::atomic<u32> m_indexW{0};
std::atomic<u32> m_indexR{0};
// Volume ranges from 0-256
std::atomic<s32> m_LVolume;
std::atomic<s32> m_RVolume;
float m_numLeftI;
u32 m_frac;
std::atomic<s32> m_LVolume{256};
std::atomic<s32> 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<float> m_speed; // Current rate of the emulation (1.0 = 100% speed)
// Current rate of emulation (1.0 = 100% speed)
std::atomic<float> m_speed{0.0f};
};