Remove CoreAudio audio backend
Cubeb handles everything the CoreAudio backend can, plus supports DPL2.
This commit is contained in:
parent
898bbffaa7
commit
21fa010bb6
|
@ -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<AlsaSound>();
|
||||
else if (backend == BACKEND_COREAUDIO && CoreAudioSound::isValid())
|
||||
g_sound_stream = std::make_unique<CoreAudioSound>();
|
||||
else if (backend == BACKEND_PULSEAUDIO && PulseAudio::isValid())
|
||||
g_sound_stream = std::make_unique<PulseAudio>();
|
||||
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<std::string> 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()
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
<ClInclude Include="AlsaSoundStream.h" />
|
||||
<ClInclude Include="AudioCommon.h" />
|
||||
<ClInclude Include="AudioStretcher.h" />
|
||||
<ClInclude Include="CoreAudioSoundStream.h" />
|
||||
<ClInclude Include="CubebStream.h" />
|
||||
<ClInclude Include="CubebUtils.h" />
|
||||
<ClInclude Include="DPL2Decoder.h" />
|
||||
|
|
|
@ -53,9 +53,6 @@
|
|||
<ClInclude Include="OpenSLESStream.h">
|
||||
<Filter>SoundStreams</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CoreAudioSoundStream.h">
|
||||
<Filter>SoundStreams</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="AlsaSoundStream.h">
|
||||
<Filter>SoundStreams</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,123 +0,0 @@
|
|||
// Copyright 2009 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <AudioUnit/AudioUnit.h>
|
||||
|
||||
#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()
|
||||
{
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
// Copyright 2008 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <AudioUnit/AudioUnit.h>
|
||||
#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
|
||||
};
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue