Skip to content

Commit

Permalink
Clean up more space/tab mismatches in AudioCommon, Common, and VideoC…
Browse files Browse the repository at this point in the history
…ommon.

Not planning to touch Core since it's the most actively changed part of the project.
  • Loading branch information
lioncash committed Mar 20, 2013
1 parent 0e3d8e2 commit edd9d0e
Show file tree
Hide file tree
Showing 91 changed files with 2,192 additions and 2,210 deletions.
6 changes: 3 additions & 3 deletions Source/Core/AudioCommon/Src/AOSoundStream.cpp
Expand Up @@ -34,7 +34,7 @@ void AOSound::SoundLoop()
format.channels = 2;
format.rate = m_mixer->GetSampleRate();
format.byte_format = AO_FMT_LITTLE;

device = ao_open_live(default_driver, &format, NULL /* no options */);
if (!device)
{
Expand All @@ -49,7 +49,7 @@ void AOSound::SoundLoop()
while (!threadData)
{
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);

{
std::lock_guard<std::mutex> lk(soundCriticalSection);
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
Expand All @@ -62,7 +62,7 @@ void AOSound::SoundLoop()
bool AOSound::Start()
{
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));

thread = std::thread(std::mem_fun(&AOSound::SoundLoop), this);
return true;
}
Expand Down
12 changes: 6 additions & 6 deletions Source/Core/AudioCommon/Src/AOSoundStream.h
Expand Up @@ -45,21 +45,21 @@ class AOSound : public SoundStream
AOSound(CMixer *mixer) : SoundStream(mixer) {}

virtual ~AOSound();

virtual bool Start();

virtual void SoundLoop();

virtual void Stop();

static bool isValid() {
return true;
}

virtual bool usesMixer() const {
return true;
}

virtual void Update();

#else
Expand Down
32 changes: 16 additions & 16 deletions Source/Core/AudioCommon/Src/AlsaSoundStream.cpp
Expand Up @@ -88,7 +88,7 @@ bool AlsaSound::AlsaInit()
snd_pcm_hw_params_t *hwparams;
snd_pcm_uframes_t buffer_size,buffer_size_max;
unsigned int periods;

err = snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, 0);
if (err < 0)
{
Expand All @@ -97,7 +97,7 @@ bool AlsaSound::AlsaInit()
}

snd_pcm_hw_params_alloca(&hwparams);

err = snd_pcm_hw_params_any(handle, hwparams);
if (err < 0)
{
Expand All @@ -111,8 +111,8 @@ bool AlsaSound::AlsaInit()
ERROR_LOG(AUDIO, "Access type not available: %s\n", snd_strerror(err));
return false;
}
err = snd_pcm_hw_params_set_format(handle, hwparams, SND_PCM_FORMAT_S16_LE);

err = snd_pcm_hw_params_set_format(handle, hwparams, SND_PCM_FORMAT_S16_LE);
if (err < 0)
{
ERROR_LOG(AUDIO, "Sample format not available: %s\n", snd_strerror(err));
Expand All @@ -126,14 +126,14 @@ bool AlsaSound::AlsaInit()
ERROR_LOG(AUDIO, "Rate not available: %s\n", snd_strerror(err));
return false;
}
err = snd_pcm_hw_params_set_channels(handle, hwparams, 2);

err = snd_pcm_hw_params_set_channels(handle, hwparams, 2);
if (err < 0)
{
ERROR_LOG(AUDIO, "Channels count not available: %s\n", snd_strerror(err));
return false;
}

periods = BUFFER_SIZE_MAX / FRAME_COUNT_MIN;
err = snd_pcm_hw_params_set_periods_max(handle, hwparams, &periods, &dir);
if (err < 0)
Expand All @@ -153,10 +153,10 @@ bool AlsaSound::AlsaInit()
err = snd_pcm_hw_params(handle, hwparams);
if (err < 0)
{
ERROR_LOG(AUDIO, "Unable to install hw params: %s\n", snd_strerror(err));
ERROR_LOG(AUDIO, "Unable to install hw params: %s\n", snd_strerror(err));
return false;
}

err = snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size);
if (err < 0)
{
Expand All @@ -176,32 +176,32 @@ bool AlsaSound::AlsaInit()
frames_to_deliver = buffer_size / periods;
//limit the minimum size. pulseaudio advertises a minimum of 32 samples.
if (frames_to_deliver < FRAME_COUNT_MIN)
frames_to_deliver = FRAME_COUNT_MIN;
frames_to_deliver = FRAME_COUNT_MIN;
//it is probably a bad idea to try to send more than one buffer of data
if ((unsigned int)frames_to_deliver > buffer_size)
frames_to_deliver = buffer_size;
frames_to_deliver = buffer_size;
NOTICE_LOG(AUDIO, "ALSA gave us a %ld sample \"hardware\" buffer with %d periods. Will send %d samples per fragments.\n", buffer_size, periods, frames_to_deliver);

snd_pcm_sw_params_alloca(&swparams);

err = snd_pcm_sw_params_current(handle, swparams);
if (err < 0)
{
ERROR_LOG(AUDIO, "cannot init sw params: %s\n", snd_strerror(err));
ERROR_LOG(AUDIO, "cannot init sw params: %s\n", snd_strerror(err));
return false;
}

err = snd_pcm_sw_params_set_start_threshold(handle, swparams, 0U);
if (err < 0)
{
ERROR_LOG(AUDIO, "cannot set start thresh: %s\n", snd_strerror(err));
ERROR_LOG(AUDIO, "cannot set start thresh: %s\n", snd_strerror(err));
return false;
}

err = snd_pcm_sw_params(handle, swparams);
if (err < 0)
{
ERROR_LOG(AUDIO, "cannot set sw params: %s\n", snd_strerror(err));
ERROR_LOG(AUDIO, "cannot set sw params: %s\n", snd_strerror(err));
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions Source/Core/AudioCommon/Src/CoreAudioSoundStream.h
Expand Up @@ -30,19 +30,19 @@ class CoreAudioSound : public SoundStream
public:
CoreAudioSound(CMixer *mixer);
virtual ~CoreAudioSound();

virtual bool Start();
virtual void SetVolume(int volume);
virtual void SoundLoop();
virtual void Stop();

static bool isValid() {
return true;
}
virtual bool usesMixer() const {
return true;
}

virtual void Update();

private:
Expand Down
52 changes: 26 additions & 26 deletions Source/Core/AudioCommon/Src/DPL2Decoder.cpp
Expand Up @@ -130,15 +130,15 @@ returns 0 if OK, -1 if fail
*/
float* design_fir(unsigned int *n, float* fc, float opt)
{
unsigned int o = *n & 1; // Indicator for odd filter length
unsigned int end = ((*n + 1) >> 1) - o; // Loop end
unsigned int i; // Loop index
unsigned int o = *n & 1; // Indicator for odd filter length
unsigned int end = ((*n + 1) >> 1) - o; // Loop end
unsigned int i; // Loop index

float k1 = 2 * float(M_PI); // 2*pi*fc1
float k2 = 0.5f * (float)(1 - o);// Constant used if the filter has even length
float g = 0.0f; // Gain
float t1; // Temporary variables
float fc1; // Cutoff frequencies
float k1 = 2 * float(M_PI); // 2*pi*fc1
float k2 = 0.5f * (float)(1 - o); // Constant used if the filter has even length
float g = 0.0f; // Gain
float t1; // Temporary variables
float fc1; // Cutoff frequencies

// Sanity check
if(*n==0) return NULL;
Expand Down Expand Up @@ -241,18 +241,18 @@ void matrix_decode(const float *in, const int k, const int il,
float *_rr, float *_cf)
{
static const float M9_03DB = 0.3535533906f;
static const float MATAGCTRIG = 8.0f; /* (Fuzzy) AGC trigger */
static const float MATAGCDECAY = 1.0f; /* AGC baseline decay rate (1/samp.) */
static const float MATAGCTRIG = 8.0f; /* (Fuzzy) AGC trigger */
static const float MATAGCDECAY = 1.0f; /* AGC baseline decay rate (1/samp.) */
static const float MATCOMPGAIN = 0.37f; /* Cross talk compensation gain, 0.50 - 0.55 is full cancellation. */

const int kr = (k + olddelay) % _dlbuflen;
float l_gain = (_l_fwr + _r_fwr) / (1 + _l_fwr + _l_fwr);
float r_gain = (_l_fwr + _r_fwr) / (1 + _r_fwr + _r_fwr);
/* The 2nd axis has strong gain fluctuations, and therefore require
limits. The factor corresponds to the 1 / amplification of (Lt
- Rt) when (Lt, Rt) is strongly correlated. (e.g. during
dialogues). It should be bigger than -12 dB to prevent
distortion. */
// The 2nd axis has strong gain fluctuations, and therefore require
// limits. The factor corresponds to the 1 / amplification of (Lt
// - Rt) when (Lt, Rt) is strongly correlated. (e.g. during
// dialogues). It should be bigger than -12 dB to prevent
// distortion.
float lmr_lim_fwr = _lmr_fwr > M9_03DB * _lpr_fwr ? _lmr_fwr : M9_03DB * _lpr_fwr;
float lpr_gain = (_lpr_fwr + lmr_lim_fwr) / (1 + _lpr_fwr + _lpr_fwr);
float lmr_gain = (_lpr_fwr + lmr_lim_fwr) / (1 + lmr_lim_fwr + lmr_lim_fwr);
Expand All @@ -275,9 +275,9 @@ void matrix_decode(const float *in, const int k, const int il,
if (decode_rear)
{
_lr[kr] = _rr[kr] = (l_agc - r_agc) * (float)M_SQRT1_2;
/* Stereo rear channel is steered with the same AGC steering as
the decoding matrix. Note this requires a fast updating AGC
at the order of 20 ms (which is the case here). */
// Stereo rear channel is steered with the same AGC steering as
// the decoding matrix. Note this requires a fast updating AGC
// at the order of 20 ms (which is the case here).
_lr[kr] *= (_l_fwr + _l_fwr) / (1 + _l_fwr + _r_fwr);
_rr[kr] *= (_r_fwr + _r_fwr) / (1 + _l_fwr + _r_fwr);
}
Expand All @@ -298,16 +298,16 @@ void matrix_decode(const float *in, const int k, const int il,
_rf[k] = (lpr_agc - lmr_agc) * (float)M_SQRT1_2;

/*** CENTER FRONT CANCELLATION ***/
/* A heuristic approach exploits that Lt + Rt gain contains the
information about Lt, Rt correlation. This effectively reshapes
the front and rear "cones" to concentrate Lt + Rt to C and
introduce Lt - Rt in L, R. */
// A heuristic approach exploits that Lt + Rt gain contains the
// information about Lt, Rt correlation. This effectively reshapes
// the front and rear "cones" to concentrate Lt + Rt to C and
// introduce Lt - Rt in L, R.
/* 0.67677 is the empirical lower bound for lpr_gain. */
c_gain = 8 * (*_adapt_lpr_gain - 0.67677f);
c_gain = c_gain > 0 ? c_gain : 0;
/* c_gain should not be too high, not even reaching full
cancellation (~ 0.50 - 0.55 at current AGC implementation), or
the center will sound too narrow. */
// c_gain should not be too high, not even reaching full
// cancellation (~ 0.50 - 0.55 at current AGC implementation), or
// the center will sound too narrow. */
c_gain = MATCOMPGAIN / (1 + c_gain * c_gain);
c_agc_cfk = c_gain * _cf[k];
_lf[k] -= c_agc_cfk;
Expand All @@ -317,7 +317,7 @@ void matrix_decode(const float *in, const int k, const int il,

void dpl2decode(float *samples, int numsamples, float *out)
{
static const unsigned int FWRDURATION = 240; /* FWR average duration (samples) */
static const unsigned int FWRDURATION = 240; // FWR average duration (samples)
static const int cfg_delay = 0;
static const unsigned int fmt_freq = 48000;
static const unsigned int fmt_nchannels = 2; // input channels
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/AudioCommon/Src/DSoundStream.cpp
Expand Up @@ -122,7 +122,7 @@ void DSound::SoundLoop()
bool DSound::Start()
{
if (FAILED(DirectSoundCreate8(0, &ds, 0)))
return false;
return false;
if (hWnd)
{
HRESULT hr = ds->SetCooperativeLevel((HWND)hWnd, DSSCL_PRIORITY);
Expand Down
52 changes: 26 additions & 26 deletions Source/Core/AudioCommon/Src/DSoundStream.h
Expand Up @@ -31,33 +31,33 @@
class DSound : public SoundStream
{
#ifdef _WIN32
std::thread thread;
Common::Event soundSyncEvent;
void *hWnd;

IDirectSound8* ds;
IDirectSoundBuffer* dsBuffer;
int bufferSize; //i bytes
std::thread thread;
Common::Event soundSyncEvent;
void *hWnd;

IDirectSound8* ds;
IDirectSoundBuffer* dsBuffer;

int bufferSize; //i bytes
int m_volume;
// playback position
int currentPos;
int lastPos;
short realtimeBuffer[BUFSIZE / sizeof(short)];
inline int FIX128(int x)

// playback position
int currentPos;
int lastPos;
short realtimeBuffer[BUFSIZE / sizeof(short)];

inline int FIX128(int x)
{
return x & (~127);
}
}

inline int ModBufferSize(int x)
inline int ModBufferSize(int x)
{
return (x + bufferSize) % bufferSize;
}
}

bool CreateBuffer();
bool WriteDataToBuffer(DWORD dwOffset, char* soundData, DWORD dwSoundBytes);
bool CreateBuffer();
bool WriteDataToBuffer(DWORD dwOffset, char* soundData, DWORD dwSoundBytes);

public:
DSound(CMixer *mixer, void *_hWnd = NULL)
Expand All @@ -70,16 +70,16 @@ class DSound : public SoundStream
, hWnd(_hWnd)
{}

virtual ~DSound() {}
virtual ~DSound() {}

virtual bool Start();
virtual void SoundLoop();
virtual void SoundLoop();
virtual void SetVolume(int volume);
virtual void Stop();
virtual void Stop();
virtual void Clear(bool mute);
static bool isValid() { return true; }
virtual bool usesMixer() const { return true; }
virtual void Update();
static bool isValid() { return true; }
virtual bool usesMixer() const { return true; }
virtual void Update();

#else
public:
Expand Down
11 changes: 4 additions & 7 deletions Source/Core/AudioCommon/Src/Mixer.cpp
Expand Up @@ -67,7 +67,7 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples)
{
static const __m128i sr_mask =
_mm_set_epi32(0x0C0D0E0FL, 0x08090A0BL,
0x04050607L, 0x00010203L);
0x04050607L, 0x00010203L);

for (unsigned int i = 0; i < numLeft * 2; i += 8)
{
Expand Down Expand Up @@ -99,12 +99,11 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples)
if ((m_indexR2 & INDEX_MASK) == (m_indexW & INDEX_MASK)) //..if it exists
m_indexR2 = m_indexR;


s16 l1 = Common::swap16(m_buffer[m_indexR & INDEX_MASK]); //current
s16 l2 = Common::swap16(m_buffer[m_indexR2 & INDEX_MASK]); //next
int sampleL = ((l1 << 16) + (l2 - l1) * (u16)frac) >> 16;
samples[i+1] = sampleL;
int sampleL = ((l1 << 16) + (l2 - l1) * (u16)frac) >> 16;
samples[i+1] = sampleL;

s16 r1 = Common::swap16(m_buffer[(m_indexR + 1) & INDEX_MASK]); //current
s16 r2 = Common::swap16(m_buffer[(m_indexR2 + 1) & INDEX_MASK]); //next
int sampleR = ((r1 << 16) + (r2 - r1) * (u16)frac) >> 16;
Expand All @@ -116,8 +115,6 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples)
}
}



} else {
numLeft = 0;
}
Expand Down

0 comments on commit edd9d0e

Please sign in to comment.