diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2016-06-24 10:43:46 +0200 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2016-06-24 10:43:46 +0200 |
| commit | 3570c7f03a2aa90aa634f96c0af1969af610f14d (patch) | |
| tree | 4252e03c0e853ba7cffe022937698c854ad0eaa9 /Source/Core/AudioCommon/CoreAudioSoundStream.cpp | |
| parent | 2115e8a4a6814e32107b5205ff5c95bbd3c6e99c (diff) | |
Reformat all the things. Have fun with merge conflicts.
Diffstat (limited to 'Source/Core/AudioCommon/CoreAudioSoundStream.cpp')
| -rw-r--r-- | Source/Core/AudioCommon/CoreAudioSoundStream.cpp | 187 |
1 files changed, 88 insertions, 99 deletions
diff --git a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp index 38f11fb766..54ba660129 100644 --- a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp +++ b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp @@ -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; - - 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; - } - - 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; - } - - 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 = AudioOutputUnitStart(audioUnit); - if (err != noErr) - { - ERROR_LOG(AUDIO, "error starting audiounit"); - return false; - } - - return true; + 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; + } + + 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; + } + + 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 = 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; + } + + return true; } void CoreAudioSound::SetVolume(int 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"); + 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"); } 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() |
