Reformat all the things. Have fun with merge conflicts.

This commit is contained in:
Pierre Bourdon
2016-06-24 10:43:46 +02:00
parent 2115e8a4a6
commit 3570c7f03a
1116 changed files with 187405 additions and 180344 deletions

View File

@ -7,105 +7,94 @@
#include "AudioCommon/CoreAudioSoundStream.h"
#include "Common/Logging/Log.h"
OSStatus CoreAudioSound::callback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber,
UInt32 inNumberFrames, AudioBufferList *ioData)
OSStatus CoreAudioSound::callback(void* inRefCon, AudioUnitRenderActionFlags* ioActionFlags,
const AudioTimeStamp* inTimeStamp, UInt32 inBusNumber,
UInt32 inNumberFrames, AudioBufferList* ioData)
{
for (UInt32 i = 0; i < ioData->mNumberBuffers; i++)
((CoreAudioSound *)inRefCon)->m_mixer->
Mix((short *)ioData->mBuffers[i].mData,
ioData->mBuffers[i].mDataByteSize / 4);
for (UInt32 i = 0; i < ioData->mNumberBuffers; i++)
((CoreAudioSound*)inRefCon)
->m_mixer->Mix((short*)ioData->mBuffers[i].mData, ioData->mBuffers[i].mDataByteSize / 4);
return noErr;
return noErr;
}
bool CoreAudioSound::Start()
{
OSStatus err;
AURenderCallbackStruct callback_struct;
AudioStreamBasicDescription format;
AudioComponentDescription desc;
AudioComponent component;
OSStatus err;
AURenderCallbackStruct callback_struct;
AudioStreamBasicDescription format;
AudioComponentDescription desc;
AudioComponent component;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_DefaultOutput;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
component = AudioComponentFindNext(nullptr, &desc);
if (component == nullptr)
{
ERROR_LOG(AUDIO, "error finding audio component");
return false;
}
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_DefaultOutput;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
component = AudioComponentFindNext(nullptr, &desc);
if (component == nullptr)
{
ERROR_LOG(AUDIO, "error finding audio component");
return false;
}
err = AudioComponentInstanceNew(component, &audioUnit);
if (err != noErr)
{
ERROR_LOG(AUDIO, "error opening audio component");
return false;
}
err = AudioComponentInstanceNew(component, &audioUnit);
if (err != noErr)
{
ERROR_LOG(AUDIO, "error opening audio component");
return false;
}
FillOutASBDForLPCM(format, m_mixer->GetSampleRate(),
2, 16, 16, false, false, false);
err = AudioUnitSetProperty(audioUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, 0, &format,
sizeof(AudioStreamBasicDescription));
if (err != noErr)
{
ERROR_LOG(AUDIO, "error setting audio format");
return false;
}
FillOutASBDForLPCM(format, m_mixer->GetSampleRate(), 2, 16, 16, false, false, false);
err = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0,
&format, sizeof(AudioStreamBasicDescription));
if (err != noErr)
{
ERROR_LOG(AUDIO, "error setting audio format");
return false;
}
callback_struct.inputProc = callback;
callback_struct.inputProcRefCon = this;
err = AudioUnitSetProperty(audioUnit,
kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input, 0, &callback_struct,
sizeof callback_struct);
if (err != noErr)
{
ERROR_LOG(AUDIO, "error setting audio callback");
return false;
}
callback_struct.inputProc = callback;
callback_struct.inputProcRefCon = this;
err = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input,
0, &callback_struct, sizeof callback_struct);
if (err != noErr)
{
ERROR_LOG(AUDIO, "error setting audio callback");
return false;
}
err = AudioUnitSetParameter(audioUnit,
kHALOutputParam_Volume,
kAudioUnitScope_Output, 0,
m_volume / 100., 0);
if (err != noErr)
ERROR_LOG(AUDIO, "error setting volume");
err = AudioUnitSetParameter(audioUnit, kHALOutputParam_Volume, kAudioUnitScope_Output, 0,
m_volume / 100., 0);
if (err != noErr)
ERROR_LOG(AUDIO, "error setting volume");
err = AudioUnitInitialize(audioUnit);
if (err != noErr)
{
ERROR_LOG(AUDIO, "error initializing audiounit");
return false;
}
err = AudioUnitInitialize(audioUnit);
if (err != noErr)
{
ERROR_LOG(AUDIO, "error initializing audiounit");
return false;
}
err = AudioOutputUnitStart(audioUnit);
if (err != noErr)
{
ERROR_LOG(AUDIO, "error starting audiounit");
return false;
}
err = AudioOutputUnitStart(audioUnit);
if (err != noErr)
{
ERROR_LOG(AUDIO, "error starting audiounit");
return false;
}
return true;
return true;
}
void CoreAudioSound::SetVolume(int volume)
{
OSStatus err;
m_volume = volume;
OSStatus err;
m_volume = volume;
err = AudioUnitSetParameter(audioUnit,
kHALOutputParam_Volume,
kAudioUnitScope_Output, 0,
volume / 100., 0);
if (err != noErr)
ERROR_LOG(AUDIO, "error setting volume");
err = AudioUnitSetParameter(audioUnit, kHALOutputParam_Volume, kAudioUnitScope_Output, 0,
volume / 100., 0);
if (err != noErr)
ERROR_LOG(AUDIO, "error setting volume");
}
void CoreAudioSound::SoundLoop()
@ -114,19 +103,19 @@ void CoreAudioSound::SoundLoop()
void CoreAudioSound::Stop()
{
OSStatus err;
OSStatus err;
err = AudioOutputUnitStop(audioUnit);
if (err != noErr)
ERROR_LOG(AUDIO, "error stopping audiounit");
err = AudioOutputUnitStop(audioUnit);
if (err != noErr)
ERROR_LOG(AUDIO, "error stopping audiounit");
err = AudioUnitUninitialize(audioUnit);
if (err != noErr)
ERROR_LOG(AUDIO, "error uninitializing audiounit");
err = AudioUnitUninitialize(audioUnit);
if (err != noErr)
ERROR_LOG(AUDIO, "error uninitializing audiounit");
err = AudioComponentInstanceDispose(audioUnit);
if (err != noErr)
ERROR_LOG(AUDIO, "error closing audio component");
err = AudioComponentInstanceDispose(audioUnit);
if (err != noErr)
ERROR_LOG(AUDIO, "error closing audio component");
}
void CoreAudioSound::Update()