From 21fa010bb66f56ed9b83e840d25c10c313b99e05 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sun, 25 Jun 2017 23:56:11 -0700 Subject: [PATCH] Remove CoreAudio audio backend Cubeb handles everything the CoreAudio backend can, plus supports DPL2. --- Source/Core/AudioCommon/AudioCommon.cpp | 10 +- Source/Core/AudioCommon/AudioCommon.vcxproj | 3 +- .../AudioCommon/AudioCommon.vcxproj.filters | 3 - Source/Core/AudioCommon/CMakeLists.txt | 3 - .../Core/AudioCommon/CoreAudioSoundStream.cpp | 123 ------------------ .../Core/AudioCommon/CoreAudioSoundStream.h | 32 ----- Source/Core/Core/ConfigManager.h | 1 - 7 files changed, 3 insertions(+), 172 deletions(-) delete mode 100644 Source/Core/AudioCommon/CoreAudioSoundStream.cpp delete mode 100644 Source/Core/AudioCommon/CoreAudioSoundStream.h diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp index 606854159c..18aa75d1ae 100644 --- a/Source/Core/AudioCommon/AudioCommon.cpp +++ b/Source/Core/AudioCommon/AudioCommon.cpp @@ -4,7 +4,6 @@ #include "AudioCommon/AudioCommon.h" #include "AudioCommon/AlsaSoundStream.h" -#include "AudioCommon/CoreAudioSoundStream.h" #include "AudioCommon/CubebStream.h" #include "AudioCommon/Mixer.h" #include "AudioCommon/NullSoundStream.h" @@ -46,8 +45,6 @@ void InitSoundStream() } else if (backend == BACKEND_ALSA && AlsaSound::isValid()) g_sound_stream = std::make_unique(); - else if (backend == BACKEND_COREAUDIO && CoreAudioSound::isValid()) - g_sound_stream = std::make_unique(); else if (backend == BACKEND_PULSEAUDIO && PulseAudio::isValid()) g_sound_stream = std::make_unique(); else if (backend == BACKEND_OPENSLES && OpenSLESStream::isValid()) @@ -101,7 +98,7 @@ std::string GetDefaultSoundBackend() if (AlsaSound::isValid()) backend = BACKEND_ALSA; #elif defined __APPLE__ - backend = BACKEND_COREAUDIO; + backend = BACKEND_CUBEB; #elif defined _WIN32 backend = BACKEND_XAUDIO2; #endif @@ -118,8 +115,6 @@ std::vector GetSoundBackends() backends.push_back(BACKEND_XAUDIO2); if (AlsaSound::isValid()) backends.push_back(BACKEND_ALSA); - if (CoreAudioSound::isValid()) - backends.push_back(BACKEND_COREAUDIO); if (PulseAudio::isValid()) backends.push_back(BACKEND_PULSEAUDIO); if (OpenALStream::isValid()) @@ -152,8 +147,7 @@ bool SupportsVolumeChanges(const std::string& backend) // FIXME: this one should ask the backend whether it supports it. // but getting the backend from string etc. is probably // too much just to enable/disable a stupid slider... - return backend == BACKEND_COREAUDIO || backend == BACKEND_CUBEB || backend == BACKEND_OPENAL || - backend == BACKEND_XAUDIO2; + return backend == BACKEND_CUBEB || backend == BACKEND_OPENAL || backend == BACKEND_XAUDIO2; } void UpdateSoundStream() diff --git a/Source/Core/AudioCommon/AudioCommon.vcxproj b/Source/Core/AudioCommon/AudioCommon.vcxproj index 1429782557..5040cb6c6c 100644 --- a/Source/Core/AudioCommon/AudioCommon.vcxproj +++ b/Source/Core/AudioCommon/AudioCommon.vcxproj @@ -54,7 +54,6 @@ - @@ -82,4 +81,4 @@ - \ No newline at end of file + diff --git a/Source/Core/AudioCommon/AudioCommon.vcxproj.filters b/Source/Core/AudioCommon/AudioCommon.vcxproj.filters index 9d7975c53f..48c93879be 100644 --- a/Source/Core/AudioCommon/AudioCommon.vcxproj.filters +++ b/Source/Core/AudioCommon/AudioCommon.vcxproj.filters @@ -53,9 +53,6 @@ SoundStreams - - SoundStreams - SoundStreams diff --git a/Source/Core/AudioCommon/CMakeLists.txt b/Source/Core/AudioCommon/CMakeLists.txt index e39296d6cb..8213df5fe8 100644 --- a/Source/Core/AudioCommon/CMakeLists.txt +++ b/Source/Core/AudioCommon/CMakeLists.txt @@ -67,9 +67,6 @@ if(WIN32) else() message(FATAL_ERROR "OpenAL NOT found in Externals") endif() - -elseif(APPLE) - target_sources(audiocommon PRIVATE CoreAudioSoundStream.cpp) endif() target_link_libraries(audiocommon PRIVATE cubeb SoundTouch) diff --git a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp b/Source/Core/AudioCommon/CoreAudioSoundStream.cpp deleted file mode 100644 index 54ba660129..0000000000 --- a/Source/Core/AudioCommon/CoreAudioSoundStream.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2009 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#include - -#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) -{ - 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; -} - -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; -} - -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"); -} - -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 = AudioComponentInstanceDispose(audioUnit); - if (err != noErr) - ERROR_LOG(AUDIO, "error closing audio component"); -} - -void CoreAudioSound::Update() -{ -} diff --git a/Source/Core/AudioCommon/CoreAudioSoundStream.h b/Source/Core/AudioCommon/CoreAudioSoundStream.h deleted file mode 100644 index 8e4f35a8e9..0000000000 --- a/Source/Core/AudioCommon/CoreAudioSoundStream.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2008 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#pragma once - -#ifdef __APPLE__ -#include -#endif - -#include "AudioCommon/SoundStream.h" - -class CoreAudioSound final : public SoundStream -{ -#ifdef __APPLE__ -public: - bool Start() override; - void SetVolume(int volume) override; - void SoundLoop() override; - void Stop() override; - void Update() override; - - static bool isValid() { return true; } -private: - AudioUnit audioUnit; - int m_volume; - - static OSStatus callback(void* inRefCon, AudioUnitRenderActionFlags* ioActionFlags, - const AudioTimeStamp* inTimeStamp, UInt32 inBusNumber, - UInt32 inNumberFrames, AudioBufferList* ioData); -#endif -}; diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index e40b6bf320..521c3c4b98 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -35,7 +35,6 @@ class TMDReader; // DSP Backend Types #define BACKEND_NULLSOUND _trans("No audio output") #define BACKEND_ALSA "ALSA" -#define BACKEND_COREAUDIO "CoreAudio" #define BACKEND_CUBEB "Cubeb" #define BACKEND_OPENAL "OpenAL" #define BACKEND_PULSEAUDIO "Pulse"