From 34692ab826abc8f8faa61bdb2280b742424528f1 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sat, 7 Dec 2013 15:14:29 -0500 Subject: Remove unnecessary Src/ folders --- Source/Core/AudioCommon/CoreAudioSoundStream.cpp | 135 +++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 Source/Core/AudioCommon/CoreAudioSoundStream.cpp (limited to 'Source/Core/AudioCommon/CoreAudioSoundStream.cpp') diff --git a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp new file mode 100644 index 0000000000..967eaa4b0a --- /dev/null +++ b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp @@ -0,0 +1,135 @@ +// Copyright 2013 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include + +#include "CoreAudioSoundStream.h" + +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); + + return noErr; +} + +CoreAudioSound::CoreAudioSound(CMixer *mixer) : SoundStream(mixer) +{ +} + +CoreAudioSound::~CoreAudioSound() +{ +} + +bool CoreAudioSound::Start() +{ + OSStatus err; + AURenderCallbackStruct callback_struct; + AudioStreamBasicDescription format; + ComponentDescription desc; + Component component; + + desc.componentType = kAudioUnitType_Output; + desc.componentSubType = kAudioUnitSubType_DefaultOutput; + desc.componentFlags = 0; + desc.componentFlagsMask = 0; + desc.componentManufacturer = kAudioUnitManufacturer_Apple; + component = FindNextComponent(NULL, &desc); + if (component == NULL) { + ERROR_LOG(AUDIO, "error finding audio component"); + return false; + } + + err = OpenAComponent(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, + kAudioUnitParameterFlag_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, + kAudioUnitParameterFlag_Output, 0, + volume / 100., 0); + if (err != noErr) + ERROR_LOG(AUDIO, "error setting volume"); +} + +void CoreAudioSound::SoundLoop() +{ +} + +void CoreAudioSound::Stop() +{ + OSStatus err; + + 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 = CloseComponent(audioUnit); + if (err != noErr) + ERROR_LOG(AUDIO, "error closing audio component"); +} + +void CoreAudioSound::Update() +{ +} -- cgit v1.2.3 From 2afe2152712981e21d6bda6f029292ed2b1cf91e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 17 Feb 2014 05:18:15 -0500 Subject: Convert all includes to relative paths. --- Source/Core/AudioCommon/CoreAudioSoundStream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/AudioCommon/CoreAudioSoundStream.cpp') diff --git a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp index 967eaa4b0a..a46edbb660 100644 --- a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp +++ b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp @@ -4,7 +4,7 @@ #include -#include "CoreAudioSoundStream.h" +#include "AudioCommon/CoreAudioSoundStream.h" OSStatus CoreAudioSound::callback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, -- cgit v1.2.3 From d802d392811be44d34ae9cd23f616db93e54c50f Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sun, 9 Mar 2014 21:14:26 +0100 Subject: clang-modernize -use-nullptr and s/\bNULL\b/nullptr/g for *.cpp/h/mm files not compiled on my machine --- Source/Core/AudioCommon/CoreAudioSoundStream.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/AudioCommon/CoreAudioSoundStream.cpp') diff --git a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp index a46edbb660..e311adc230 100644 --- a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp +++ b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp @@ -40,8 +40,8 @@ bool CoreAudioSound::Start() desc.componentFlags = 0; desc.componentFlagsMask = 0; desc.componentManufacturer = kAudioUnitManufacturer_Apple; - component = FindNextComponent(NULL, &desc); - if (component == NULL) { + component = FindNextComponent(nullptr, &desc); + if (component == nullptr) { ERROR_LOG(AUDIO, "error finding audio component"); return false; } -- cgit v1.2.3 From f94e764df52eba37bc1b800112d0c3e02f6455d1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 30 Aug 2014 16:29:15 -0400 Subject: AudioCommon: Clean up brace placements --- Source/Core/AudioCommon/CoreAudioSoundStream.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'Source/Core/AudioCommon/CoreAudioSoundStream.cpp') diff --git a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp index e311adc230..cfe6bc6e16 100644 --- a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp +++ b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp @@ -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, -- cgit v1.2.3 From b36b55cfcb7d2cab7c3bb08e72f57a75199e2b70 Mon Sep 17 00:00:00 2001 From: comex Date: Tue, 25 Nov 2014 00:42:21 -0500 Subject: Upgrade AudioUnit API usage. weird that such a simple change doesn't seem to have any obvious documentation on Apple's website or elsewhere... --- Source/Core/AudioCommon/CoreAudioSoundStream.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Source/Core/AudioCommon/CoreAudioSoundStream.cpp') diff --git a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp index cfe6bc6e16..3bfd517708 100644 --- a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp +++ b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp @@ -32,22 +32,22 @@ bool CoreAudioSound::Start() OSStatus err; AURenderCallbackStruct callback_struct; AudioStreamBasicDescription format; - ComponentDescription desc; - Component component; + AudioComponentDescription desc; + AudioComponent component; desc.componentType = kAudioUnitType_Output; desc.componentSubType = kAudioUnitSubType_DefaultOutput; desc.componentFlags = 0; desc.componentFlagsMask = 0; desc.componentManufacturer = kAudioUnitManufacturer_Apple; - component = FindNextComponent(nullptr, &desc); + component = AudioComponentFindNext(nullptr, &desc); if (component == nullptr) { ERROR_LOG(AUDIO, "error finding audio component"); return false; } - err = OpenAComponent(component, &audioUnit); + err = AudioComponentInstanceNew(component, &audioUnit); if (err != noErr) { ERROR_LOG(AUDIO, "error opening audio component"); @@ -131,7 +131,7 @@ void CoreAudioSound::Stop() if (err != noErr) ERROR_LOG(AUDIO, "error uninitializing audiounit"); - err = CloseComponent(audioUnit); + err = AudioComponentInstanceDispose(audioUnit); if (err != noErr) ERROR_LOG(AUDIO, "error closing audio component"); } -- cgit v1.2.3 From 35ee8a136237042efa6987e954c135f91a065cd0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 24 May 2015 04:13:02 -0400 Subject: SoundStream: Internally construct the mixer Instead of creating the mixer externally and then passing it in, it can just be made within the class. --- Source/Core/AudioCommon/CoreAudioSoundStream.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'Source/Core/AudioCommon/CoreAudioSoundStream.cpp') diff --git a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp index 3bfd517708..a8f002258f 100644 --- a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp +++ b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp @@ -19,14 +19,6 @@ OSStatus CoreAudioSound::callback(void *inRefCon, return noErr; } -CoreAudioSound::CoreAudioSound(CMixer *mixer) : SoundStream(mixer) -{ -} - -CoreAudioSound::~CoreAudioSound() -{ -} - bool CoreAudioSound::Start() { OSStatus err; -- cgit v1.2.3 From cefcb0ace9d363b3679b4e93bcc9ec05f1e5f4f8 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Mon, 18 May 2015 01:08:10 +0200 Subject: Update license headers to GPLv2+ --- Source/Core/AudioCommon/CoreAudioSoundStream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/AudioCommon/CoreAudioSoundStream.cpp') diff --git a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp index a8f002258f..637cc1d607 100644 --- a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp +++ b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp @@ -1,5 +1,5 @@ // Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 +// Licensed under GPLv2+ // Refer to the license.txt file included. #include -- cgit v1.2.3 From 30ebb2459eb97ba544547183854775df8460b475 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sun, 24 May 2015 06:55:12 +0200 Subject: Set copyright year to when a file was created --- Source/Core/AudioCommon/CoreAudioSoundStream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/AudioCommon/CoreAudioSoundStream.cpp') diff --git a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp index 637cc1d607..3c1d6039af 100644 --- a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp +++ b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp @@ -1,4 +1,4 @@ -// Copyright 2013 Dolphin Emulator Project +// Copyright 2009 Dolphin Emulator Project // Licensed under GPLv2+ // Refer to the license.txt file included. -- cgit v1.2.3