AudioCommon: Clean up brace placements

This commit is contained in:
Lioncash 2014-08-30 16:29:15 -04:00
parent ba4934b75e
commit f94e764df5
9 changed files with 93 additions and 43 deletions

View File

@ -40,7 +40,8 @@ public:
virtual void Stop() override;
static bool isValid() {
static bool isValid()
{
return true;
}

View File

@ -23,7 +23,8 @@ public:
virtual void SoundLoop() override;
virtual void Stop() override;
static bool isValid() {
static bool isValid()
{
return true;
}

View File

@ -41,13 +41,15 @@ bool CoreAudioSound::Start()
desc.componentFlagsMask = 0;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
component = FindNextComponent(nullptr, &desc);
if (component == nullptr) {
if (component == nullptr)
{
ERROR_LOG(AUDIO, "error finding audio component");
return false;
}
err = OpenAComponent(component, &audioUnit);
if (err != noErr) {
if (err != noErr)
{
ERROR_LOG(AUDIO, "error opening audio component");
return false;
}
@ -58,7 +60,8 @@ bool CoreAudioSound::Start()
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, 0, &format,
sizeof(AudioStreamBasicDescription));
if (err != noErr) {
if (err != noErr)
{
ERROR_LOG(AUDIO, "error setting audio format");
return false;
}
@ -69,12 +72,13 @@ bool CoreAudioSound::Start()
kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input, 0, &callback_struct,
sizeof callback_struct);
if (err != noErr) {
if (err != noErr)
{
ERROR_LOG(AUDIO, "error setting audio callback");
return false;
}
err = AudioUnitSetParameter(audioUnit,
err = AudioUnitSetParameter(audioUnit,
kHALOutputParam_Volume,
kAudioUnitParameterFlag_Output, 0,
m_volume / 100., 0);
@ -82,13 +86,15 @@ bool CoreAudioSound::Start()
ERROR_LOG(AUDIO, "error setting volume");
err = AudioUnitInitialize(audioUnit);
if (err != noErr) {
if (err != noErr)
{
ERROR_LOG(AUDIO, "error initializing audiounit");
return false;
}
err = AudioOutputUnitStart(audioUnit);
if (err != noErr) {
if (err != noErr)
{
ERROR_LOG(AUDIO, "error starting audiounit");
return false;
}
@ -99,7 +105,7 @@ bool CoreAudioSound::Start()
void CoreAudioSound::SetVolume(int volume)
{
OSStatus err;
m_volume = volume;
m_volume = volume;
err = AudioUnitSetParameter(audioUnit,
kHALOutputParam_Volume,

View File

@ -22,7 +22,8 @@ public:
virtual void SoundLoop();
virtual void Stop();
static bool isValid() {
static bool isValid()
{
return true;
}

View File

@ -57,7 +57,8 @@ unsigned int CMixer::MixerFifo::Mix(short* samples, unsigned int numSamples, boo
s32 rvolume = m_RVolume;
// TODO: consider a higher-quality resampling algorithm.
for (; currentSample < numSamples*2 && ((indexW-indexR) & INDEX_MASK) > 2; currentSample+=2) {
for (; currentSample < numSamples*2 && ((indexW-indexR) & INDEX_MASK) > 2; currentSample+=2)
{
u32 indexR2 = indexR + 2; //next sample
s16 l1 = Common::swap16(m_buffer[indexR & INDEX_MASK]); //current

View File

@ -30,7 +30,8 @@ static CMixer *g_mixer;
static short buffer[2][BUFFER_SIZE];
static int curBuffer = 0;
static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) {
static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
{
assert(bq == bqPlayerBufferQueue);
assert(nullptr == context);
@ -49,6 +50,7 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) {
// Render to the fresh buffer
g_mixer->Mix(reinterpret_cast<short *>(buffer[curBuffer]), BUFFER_SIZE_IN_SAMPLES);
}
bool OpenSLESStream::Start()
{
SLresult result;
@ -103,9 +105,11 @@ bool OpenSLESStream::Start()
curBuffer = 0;
result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer[curBuffer], sizeof(buffer[curBuffer]));
if (SL_RESULT_SUCCESS != result) {
if (SL_RESULT_SUCCESS != result)
{
return false;
}
curBuffer ^= 1;
g_mixer = m_mixer;
return true;
@ -113,7 +117,8 @@ bool OpenSLESStream::Start()
void OpenSLESStream::Stop()
{
if (bqPlayerObject != nullptr) {
if (bqPlayerObject != nullptr)
{
(*bqPlayerObject)->Destroy(bqPlayerObject);
bqPlayerObject = nullptr;
bqPlayerPlay = nullptr;
@ -121,11 +126,15 @@ void OpenSLESStream::Stop()
bqPlayerMuteSolo = nullptr;
bqPlayerVolume = nullptr;
}
if (outputMixObject != nullptr) {
if (outputMixObject != nullptr)
{
(*outputMixObject)->Destroy(outputMixObject);
outputMixObject = nullptr;
}
if (engineObject != nullptr) {
if (engineObject != nullptr)
{
(*engineObject)->Destroy(engineObject);
engineObject = nullptr;
engineEngine = nullptr;

View File

@ -19,7 +19,8 @@ PulseAudio::PulseAudio(CMixer *mixer)
: SoundStream(mixer)
, m_thread()
, m_run_thread()
{}
{
}
bool PulseAudio::Start()
{

View File

@ -33,23 +33,32 @@ public:
virtual void Update() {}
virtual void Clear(bool mute) { m_muted = mute; }
bool IsMuted() const { return m_muted; }
virtual void StartLogAudio(const char *filename) {
if (! m_logAudio) {
virtual void StartLogAudio(const char *filename)
{
if (! m_logAudio)
{
m_logAudio = true;
g_wave_writer.Start(filename, m_mixer->GetSampleRate());
g_wave_writer.SetSkipSilence(false);
NOTICE_LOG(DSPHLE, "Starting Audio logging");
} else {
}
else
{
WARN_LOG(DSPHLE, "Audio logging already started");
}
}
virtual void StopLogAudio() {
if (m_logAudio) {
virtual void StopLogAudio()
{
if (m_logAudio)
{
m_logAudio = false;
g_wave_writer.Stop();
NOTICE_LOG(DSPHLE, "Stopping Audio logging");
} else {
}
else
{
WARN_LOG(DSPHLE, "Audio logging already stopped");
}
}

View File

@ -137,8 +137,10 @@ ALDeviceList::ALDeviceList()
*/
ALDeviceList::~ALDeviceList()
{
for (auto& di : vDeviceInfo) {
if (di.pvstrExtensions) {
for (auto& di : vDeviceInfo)
{
if (di.pvstrExtensions)
{
di.pvstrExtensions->clear();
delete di.pvstrExtensions;
}
@ -171,13 +173,13 @@ char * ALDeviceList::GetDeviceName(s32 index)
*/
void ALDeviceList::GetDeviceVersion(s32 index, s32 *major, s32 *minor)
{
if (index < GetNumDevices()) {
if (index < GetNumDevices())
{
if (major)
*major = vDeviceInfo[index].iMajorVersion;
if (minor)
*minor = vDeviceInfo[index].iMinorVersion;
}
return;
}
/*
@ -198,9 +200,12 @@ bool ALDeviceList::IsExtensionSupported(s32 index, char *szExtName)
{
bool bReturn = false;
if (index < GetNumDevices()) {
for (auto& ext : *vDeviceInfo[index].pvstrExtensions) {
if (!strcasecmp(ext.c_str(), szExtName)) {
if (index < GetNumDevices())
{
for (auto& ext : *vDeviceInfo[index].pvstrExtensions)
{
if (!strcasecmp(ext.c_str(), szExtName))
{
bReturn = true;
break;
}
@ -224,9 +229,11 @@ s32 ALDeviceList::GetDefaultDevice()
void ALDeviceList::FilterDevicesMinVer(s32 major, s32 minor)
{
s32 dMajor = 0, dMinor = 0;
for (u32 i = 0; i < vDeviceInfo.size(); i++) {
for (u32 i = 0; i < vDeviceInfo.size(); i++)
{
GetDeviceVersion(i, &dMajor, &dMinor);
if ((dMajor < major) || ((dMajor == major) && (dMinor < minor))) {
if ((dMajor < major) || ((dMajor == major) && (dMinor < minor)))
{
vDeviceInfo[i].bSelected = false;
}
}
@ -238,9 +245,11 @@ void ALDeviceList::FilterDevicesMinVer(s32 major, s32 minor)
void ALDeviceList::FilterDevicesMaxVer(s32 major, s32 minor)
{
s32 dMajor = 0, dMinor = 0;
for (u32 i = 0; i < vDeviceInfo.size(); i++) {
for (u32 i = 0; i < vDeviceInfo.size(); i++)
{
GetDeviceVersion(i, &dMajor, &dMinor);
if ((dMajor > major) || ((dMajor == major) && (dMinor > minor))) {
if ((dMajor > major) || ((dMajor == major) && (dMinor > minor)))
{
vDeviceInfo[i].bSelected = false;
}
}
@ -253,14 +262,18 @@ void ALDeviceList::FilterDevicesExtension(char *szExtName)
{
bool bFound;
for (auto& di : vDeviceInfo) {
for (auto& di : vDeviceInfo)
{
bFound = false;
for (auto& ext : *di.pvstrExtensions) {
if (!strcasecmp(ext.c_str(), szExtName)) {
for (auto& ext : *di.pvstrExtensions)
{
if (!strcasecmp(ext.c_str(), szExtName))
{
bFound = true;
break;
}
}
if (!bFound)
di.bSelected = false;
}
@ -271,9 +284,11 @@ void ALDeviceList::FilterDevicesExtension(char *szExtName)
*/
void ALDeviceList::ResetFilters()
{
for (s32 i = 0; i < GetNumDevices(); i++) {
for (s32 i = 0; i < GetNumDevices(); i++)
{
vDeviceInfo[i].bSelected = true;
}
filterIndex = 0;
}
@ -284,11 +299,14 @@ s32 ALDeviceList::GetFirstFilteredDevice()
{
s32 i;
for (i = 0; i < GetNumDevices(); i++) {
if (vDeviceInfo[i].bSelected == true) {
for (i = 0; i < GetNumDevices(); i++)
{
if (vDeviceInfo[i].bSelected == true)
{
break;
}
}
filterIndex = i + 1;
return i;
}
@ -300,11 +318,14 @@ s32 ALDeviceList::GetNextFilteredDevice()
{
s32 i;
for (i = filterIndex; i < GetNumDevices(); i++) {
if (vDeviceInfo[i].bSelected == true) {
for (i = filterIndex; i < GetNumDevices(); i++)
{
if (vDeviceInfo[i].bSelected == true)
{
break;
}
}
filterIndex = i + 1;
return i;
}