summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPoommetee Ketson <poommetee@protonmail.com>2017-10-02 23:37:55 +0700
committerGitHub <noreply@github.com>2017-10-02 23:37:55 +0700
commit3f4e973a60e20051bf4a51a93048d84d2c83a0c9 (patch)
treeab216bf42a21b9f1bc51dec677c8760bd77d8549
parentfcc209590977f486243860c48957a518bdd37564 (diff)
parent12d40fa03f95cccfb6af994b03576f78af314891 (diff)
Merge pull request #11716 from marcelofg55/coreaudio_driver
Merged iphone and osx audio drivers into drivers/coreaudio
-rw-r--r--drivers/SCsub1
-rw-r--r--drivers/coreaudio/SCsub8
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.cpp (renamed from platform/osx/audio_driver_osx.cpp)56
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.h (renamed from platform/osx/audio_driver_osx.h)20
-rw-r--r--platform/iphone/SCsub1
-rw-r--r--platform/iphone/app_delegate.mm6
-rw-r--r--platform/iphone/audio_driver_iphone.cpp187
-rw-r--r--platform/iphone/audio_driver_iphone.h66
-rw-r--r--platform/iphone/detect.py2
-rw-r--r--platform/iphone/os_iphone.cpp6
-rw-r--r--platform/iphone/os_iphone.h5
-rw-r--r--platform/osx/SCsub1
-rw-r--r--platform/osx/detect.py2
-rw-r--r--platform/osx/os_osx.h6
-rw-r--r--platform/osx/os_osx.mm2
15 files changed, 68 insertions, 301 deletions
diff --git a/drivers/SCsub b/drivers/SCsub
index 195f7ec438..34d6254578 100644
--- a/drivers/SCsub
+++ b/drivers/SCsub
@@ -13,6 +13,7 @@ SConscript('windows/SCsub')
# Sounds drivers
SConscript('alsa/SCsub')
+SConscript('coreaudio/SCsub')
SConscript('pulseaudio/SCsub')
if (env["platform"] == "windows"):
SConscript("rtaudio/SCsub")
diff --git a/drivers/coreaudio/SCsub b/drivers/coreaudio/SCsub
new file mode 100644
index 0000000000..233593b0f9
--- /dev/null
+++ b/drivers/coreaudio/SCsub
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+Import('env')
+
+# Driver source files
+env.add_source_files(env.drivers_sources, "*.cpp")
+
+Export('env')
diff --git a/platform/osx/audio_driver_osx.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp
index 3b3ba60507..c531d6af9d 100644
--- a/platform/osx/audio_driver_osx.cpp
+++ b/drivers/coreaudio/audio_driver_coreaudio.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* audio_driver_osx.cpp */
+/* audio_driver_coreaudio.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,27 +27,33 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifdef OSX_ENABLED
+#ifdef COREAUDIO_ENABLED
-#include "audio_driver_osx.h"
+#include "audio_driver_coreaudio.h"
#include "core/project_settings.h"
#include "os/os.h"
#define kOutputBus 0
+#ifdef OSX_ENABLED
static OSStatus outputDeviceAddressCB(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *__nullable inClientData) {
- AudioDriverOSX *driver = (AudioDriverOSX *)inClientData;
+ AudioDriverCoreAudio *driver = (AudioDriverCoreAudio *)inClientData;
driver->reopen();
return noErr;
}
+#endif
-Error AudioDriverOSX::initDevice() {
+Error AudioDriverCoreAudio::initDevice() {
AudioComponentDescription desc;
zeromem(&desc, sizeof(desc));
desc.componentType = kAudioUnitType_Output;
+#ifdef OSX_ENABLED
desc.componentSubType = kAudioUnitSubType_HALOutput;
+#else
+ desc.componentSubType = kAudioUnitSubType_RemoteIO;
+#endif
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
AudioComponent comp = AudioComponentFindNext(NULL, &desc);
@@ -96,8 +102,10 @@ Error AudioDriverOSX::initDevice() {
// Sample rate is independent of channels (ref: https://stackoverflow.com/questions/11048825/audio-sample-frequency-rely-on-channels)
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
+#ifdef OSX_ENABLED
result = AudioUnitSetProperty(audio_unit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, kOutputBus, &buffer_frames, sizeof(UInt32));
ERR_FAIL_COND_V(result != noErr, FAILED);
+#endif
buffer_size = buffer_frames * channels;
samples_in.resize(buffer_size);
@@ -109,7 +117,7 @@ Error AudioDriverOSX::initDevice() {
AURenderCallbackStruct callback;
zeromem(&callback, sizeof(AURenderCallbackStruct));
- callback.inputProc = &AudioDriverOSX::output_callback;
+ callback.inputProc = &AudioDriverCoreAudio::output_callback;
callback.inputProcRefCon = this;
result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, kOutputBus, &callback, sizeof(callback));
ERR_FAIL_COND_V(result != noErr, FAILED);
@@ -120,7 +128,7 @@ Error AudioDriverOSX::initDevice() {
return OK;
}
-Error AudioDriverOSX::finishDevice() {
+Error AudioDriverCoreAudio::finishDevice() {
OSStatus result;
if (active) {
@@ -136,24 +144,26 @@ Error AudioDriverOSX::finishDevice() {
return OK;
}
-Error AudioDriverOSX::init() {
+Error AudioDriverCoreAudio::init() {
OSStatus result;
mutex = Mutex::create();
active = false;
channels = 2;
+#ifdef OSX_ENABLED
outputDeviceAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
outputDeviceAddress.mScope = kAudioObjectPropertyScopeGlobal;
outputDeviceAddress.mElement = kAudioObjectPropertyElementMaster;
result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this);
ERR_FAIL_COND_V(result != noErr, FAILED);
+#endif
return initDevice();
};
-Error AudioDriverOSX::reopen() {
+Error AudioDriverCoreAudio::reopen() {
bool restart = false;
lock();
@@ -185,13 +195,13 @@ Error AudioDriverOSX::reopen() {
return OK;
}
-OSStatus AudioDriverOSX::output_callback(void *inRefCon,
+OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioData) {
- AudioDriverOSX *ad = (AudioDriverOSX *)inRefCon;
+ AudioDriverCoreAudio *ad = (AudioDriverCoreAudio *)inRefCon;
if (!ad->active || !ad->try_lock()) {
for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) {
@@ -227,7 +237,7 @@ OSStatus AudioDriverOSX::output_callback(void *inRefCon,
return 0;
};
-void AudioDriverOSX::start() {
+void AudioDriverCoreAudio::start() {
if (!active) {
OSStatus result = AudioOutputUnitStart(audio_unit);
if (result != noErr) {
@@ -238,37 +248,41 @@ void AudioDriverOSX::start() {
}
};
-int AudioDriverOSX::get_mix_rate() const {
+int AudioDriverCoreAudio::get_mix_rate() const {
return mix_rate;
};
-AudioDriver::SpeakerMode AudioDriverOSX::get_speaker_mode() const {
+AudioDriver::SpeakerMode AudioDriverCoreAudio::get_speaker_mode() const {
return get_speaker_mode_by_total_channels(channels);
};
-void AudioDriverOSX::lock() {
+void AudioDriverCoreAudio::lock() {
if (mutex)
mutex->lock();
};
-void AudioDriverOSX::unlock() {
+void AudioDriverCoreAudio::unlock() {
if (mutex)
mutex->unlock();
};
-bool AudioDriverOSX::try_lock() {
+bool AudioDriverCoreAudio::try_lock() {
if (mutex)
return mutex->try_lock() == OK;
return true;
}
-void AudioDriverOSX::finish() {
+void AudioDriverCoreAudio::finish() {
+ OSStatus result;
+
finishDevice();
- OSStatus result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this);
+#ifdef OSX_ENABLED
+ result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this);
if (result != noErr) {
ERR_PRINT("AudioObjectRemovePropertyListener failed");
}
+#endif
AURenderCallbackStruct callback;
zeromem(&callback, sizeof(AURenderCallbackStruct));
@@ -283,7 +297,7 @@ void AudioDriverOSX::finish() {
}
};
-AudioDriverOSX::AudioDriverOSX() {
+AudioDriverCoreAudio::AudioDriverCoreAudio() {
active = false;
mutex = NULL;
@@ -296,6 +310,6 @@ AudioDriverOSX::AudioDriverOSX() {
samples_in.clear();
};
-AudioDriverOSX::~AudioDriverOSX(){};
+AudioDriverCoreAudio::~AudioDriverCoreAudio(){};
#endif
diff --git a/platform/osx/audio_driver_osx.h b/drivers/coreaudio/audio_driver_coreaudio.h
index a7e68c8141..33b3ba93ec 100644
--- a/platform/osx/audio_driver_osx.h
+++ b/drivers/coreaudio/audio_driver_coreaudio.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* audio_driver_osx.h */
+/* audio_driver_coreaudio.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,20 +27,24 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifdef OSX_ENABLED
+#ifdef COREAUDIO_ENABLED
-#ifndef AUDIO_DRIVER_OSX_H
-#define AUDIO_DRIVER_OSX_H
+#ifndef AUDIO_DRIVER_COREAUDIO_H
+#define AUDIO_DRIVER_COREAUDIO_H
#include "servers/audio_server.h"
#include <AudioUnit/AudioUnit.h>
+#ifdef OSX_ENABLED
#include <CoreAudio/AudioHardware.h>
+#endif
-class AudioDriverOSX : public AudioDriver {
+class AudioDriverCoreAudio : public AudioDriver {
AudioComponentInstance audio_unit;
+#ifdef OSX_ENABLED
AudioObjectPropertyAddress outputDeviceAddress;
+#endif
bool active;
Mutex *mutex;
@@ -62,7 +66,7 @@ class AudioDriverOSX : public AudioDriver {
public:
const char *get_name() const {
- return "AudioUnit";
+ return "CoreAudio";
};
virtual Error init();
@@ -76,8 +80,8 @@ public:
bool try_lock();
Error reopen();
- AudioDriverOSX();
- ~AudioDriverOSX();
+ AudioDriverCoreAudio();
+ ~AudioDriverCoreAudio();
};
#endif
diff --git a/platform/iphone/SCsub b/platform/iphone/SCsub
index 998d0a3f0d..61798c5f87 100644
--- a/platform/iphone/SCsub
+++ b/platform/iphone/SCsub
@@ -5,7 +5,6 @@ Import('env')
iphone_lib = [
'os_iphone.cpp',
- 'audio_driver_iphone.cpp',
'sem_iphone.cpp',
'gl_view.mm',
'main.m',
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index c7b65b476b..da6ceacdac 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -29,8 +29,8 @@
/*************************************************************************/
#import "app_delegate.h"
-#include "audio_driver_iphone.h"
#include "core/project_settings.h"
+#include "drivers/coreaudio/audio_driver_coreaudio.h"
#import "gl_view.h"
#include "main/main.h"
#include "os_iphone.h"
@@ -736,8 +736,8 @@ static int frame_count = 0;
};
// Fixed audio can not resume if it is interrupted cause by an incoming phone call
- if (AudioDriverIphone::get_singleton() != NULL)
- AudioDriverIphone::get_singleton()->start();
+ if (AudioDriverCoreAudio::get_singleton() != NULL)
+ AudioDriverCoreAudio::get_singleton()->start();
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
diff --git a/platform/iphone/audio_driver_iphone.cpp b/platform/iphone/audio_driver_iphone.cpp
deleted file mode 100644
index dbc5bdb654..0000000000
--- a/platform/iphone/audio_driver_iphone.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/*************************************************************************/
-/* audio_driver_iphone.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "audio_driver_iphone.h"
-
-Error AudioDriverIphone::init() {
-
- active = false;
- channels = 2;
-
- AudioStreamBasicDescription strdesc;
- strdesc.mFormatID = kAudioFormatLinearPCM;
- strdesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
- strdesc.mChannelsPerFrame = channels;
- strdesc.mSampleRate = 44100;
- strdesc.mFramesPerPacket = 1;
- strdesc.mBitsPerChannel = 16;
- strdesc.mBytesPerFrame =
- strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8;
- strdesc.mBytesPerPacket =
- strdesc.mBytesPerFrame * strdesc.mFramesPerPacket;
-
- AURenderCallbackStruct callback;
- AudioComponentDescription desc;
- const AudioUnitElement output_bus = 0;
- const AudioUnitElement bus = output_bus;
- const AudioUnitScope scope = kAudioUnitScope_Input;
-
- zeromem(&desc, sizeof(desc));
- desc.componentType = kAudioUnitType_Output;
- desc.componentSubType = kAudioUnitSubType_RemoteIO; /* !!! FIXME: ? */
- AudioComponent comp = AudioComponentFindNext(NULL, &desc);
- desc.componentManufacturer = kAudioUnitManufacturer_Apple;
-
- OSStatus result = AudioComponentInstanceNew(comp, &audio_unit);
- ERR_FAIL_COND_V(result != noErr, FAILED);
- ERR_FAIL_COND_V(comp == NULL, FAILED);
-
- result = AudioUnitSetProperty(audio_unit,
- kAudioUnitProperty_StreamFormat,
- scope, bus, &strdesc, sizeof(strdesc));
- ERR_FAIL_COND_V(result != noErr, FAILED);
-
- zeromem(&callback, sizeof(AURenderCallbackStruct));
- callback.inputProc = &AudioDriverIphone::output_callback;
- callback.inputProcRefCon = this;
- result = AudioUnitSetProperty(audio_unit,
- kAudioUnitProperty_SetRenderCallback,
- scope, bus, &callback, sizeof(callback));
- ERR_FAIL_COND_V(result != noErr, FAILED);
-
- result = AudioUnitInitialize(audio_unit);
- ERR_FAIL_COND_V(result != noErr, FAILED);
-
- result = AudioOutputUnitStart(audio_unit);
- ERR_FAIL_COND_V(result != noErr, FAILED);
-
- const int samples = 1024;
- samples_in = memnew_arr(int32_t, samples); // whatever
- buffer_frames = samples / channels;
-
- return FAILED;
-};
-
-OSStatus AudioDriverIphone::output_callback(void *inRefCon,
- AudioUnitRenderActionFlags *ioActionFlags,
- const AudioTimeStamp *inTimeStamp,
- UInt32 inBusNumber, UInt32 inNumberFrames,
- AudioBufferList *ioData) {
-
- AudioBuffer *abuf;
- AudioDriverIphone *ad = (AudioDriverIphone *)inRefCon;
-
- bool mix = true;
-
- if (!ad->active)
- mix = false;
- else if (ad->mutex) {
- mix = ad->mutex->try_lock() == OK;
- };
-
- if (!mix) {
- for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) {
- abuf = &ioData->mBuffers[i];
- zeromem(abuf->mData, abuf->mDataByteSize);
- };
- return 0;
- };
-
- int frames_left;
-
- for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) {
-
- abuf = &ioData->mBuffers[i];
- frames_left = inNumberFrames;
- int16_t *out = (int16_t *)abuf->mData;
-
- while (frames_left) {
-
- int frames = MIN(frames_left, ad->buffer_frames);
- //ad->lock();
- ad->audio_server_process(frames, ad->samples_in);
- //ad->unlock();
-
- for (int i = 0; i < frames * ad->channels; i++) {
-
- out[i] = ad->samples_in[i] >> 16;
- }
-
- frames_left -= frames;
- out += frames * ad->channels;
- };
- };
-
- if (ad->mutex)
- ad->mutex->unlock();
-
- return 0;
-};
-
-void AudioDriverIphone::start() {
- active = true;
- // Resume audio
- // iOS audio-thread stoped if it is interrupted cause by an incoming phone call
- // Use AudioOutputUnitStart to re-create audio-thread
- OSStatus result = AudioOutputUnitStart(audio_unit);
- ERR_FAIL_COND(result != noErr);
-};
-
-int AudioDriverIphone::get_mix_rate() const {
- return 44100;
-};
-
-AudioDriver::SpeakerMode AudioDriverIphone::get_speaker_mode() const {
- return SPEAKER_MODE_STEREO;
-};
-
-void AudioDriverIphone::lock() {
-
- if (active && mutex)
- mutex->lock();
-};
-
-void AudioDriverIphone::unlock() {
- if (active && mutex)
- mutex->unlock();
-};
-
-void AudioDriverIphone::finish() {
-
- memdelete_arr(samples_in);
-};
-
-AudioDriverIphone::AudioDriverIphone() {
-
- mutex = Mutex::create(); //NULL;
-};
-
-AudioDriverIphone::~AudioDriverIphone(){
-
-};
diff --git a/platform/iphone/audio_driver_iphone.h b/platform/iphone/audio_driver_iphone.h
deleted file mode 100644
index 930ed168f7..0000000000
--- a/platform/iphone/audio_driver_iphone.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*************************************************************************/
-/* audio_driver_iphone.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "servers/audio_server.h"
-
-#include <AudioUnit/AudioUnit.h>
-
-class AudioDriverIphone : public AudioDriver {
-
- AudioComponentInstance audio_unit;
- bool active;
- Mutex *mutex;
-
- int channels;
- int32_t *samples_in;
- int buffer_frames;
-
- static OSStatus output_callback(void *inRefCon,
- AudioUnitRenderActionFlags *ioActionFlags,
- const AudioTimeStamp *inTimeStamp,
- UInt32 inBusNumber, UInt32 inNumberFrames,
- AudioBufferList *ioData);
-
-public:
- const char *get_name() const {
- return "IPhone";
- };
-
- virtual Error init();
- virtual void start();
- virtual int get_mix_rate() const;
- virtual SpeakerMode get_speaker_mode() const;
- virtual void lock();
- virtual void unlock();
- virtual void finish();
-
- AudioDriverIphone();
- ~AudioDriverIphone();
-};
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index dd4db0b1cd..00d8a59f74 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -148,7 +148,7 @@ def configure(env):
env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate'
env.Append(CPPPATH=['#platform/iphone'])
- env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DMPC_FIXED_POINT'])
+ env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DMPC_FIXED_POINT', '-DCOREAUDIO_ENABLED'])
# TODO: Move that to opus module's config
if 'module_opus_enabled' in env and env['module_opus_enabled']:
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index 0e3eeed114..086cbe5010 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -35,7 +35,6 @@
#include "servers/visual/visual_server_raster.h"
//#include "servers/visual/visual_server_wrap_mt.h"
-#include "audio_driver_iphone.h"
#include "main/main.h"
#include "core/io/file_access_pack.h"
@@ -124,9 +123,8 @@ void OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_
// reset this to what it should be, it will have been set to 0 after visual_server->init() is called
RasterizerStorageGLES3::system_fbo = gl_view_base_fb;
- audio_driver = memnew(AudioDriverIphone);
- audio_driver->set_singleton();
- audio_driver->init();
+ AudioDriverManager::add_driver(&audio_driver);
+ AudioDriverManager::initialize(p_audio_driver);
// init physics servers
physics_server = memnew(PhysicsServerSW);
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index 475dceebf2..3ebd5a74db 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -32,6 +32,7 @@
#ifndef OS_IPHONE_H
#define OS_IPHONE_H
+#include "drivers/coreaudio/audio_driver_coreaudio.h"
#include "drivers/unix/os_unix.h"
#include "os/input.h"
@@ -46,8 +47,6 @@
#include "servers/visual/rasterizer.h"
#include "servers/visual_server.h"
-class AudioDriverIphone;
-
class OSIPhone : public OS_Unix {
public:
@@ -70,7 +69,7 @@ private:
PhysicsServer *physics_server;
Physics2DServer *physics_2d_server;
- AudioDriverIphone *audio_driver;
+ AudioDriverCoreAudio audio_driver;
#ifdef GAME_CENTER_ENABLED
GameCenter *game_center;
diff --git a/platform/osx/SCsub b/platform/osx/SCsub
index 27bffbe80e..be3950bc6d 100644
--- a/platform/osx/SCsub
+++ b/platform/osx/SCsub
@@ -10,7 +10,6 @@ files = [
'crash_handler_osx.mm',
'os_osx.mm',
'godot_main_osx.mm',
- 'audio_driver_osx.cpp',
'sem_osx.cpp',
'dir_access_osx.mm',
'joypad_osx.cpp',
diff --git a/platform/osx/detect.py b/platform/osx/detect.py
index 51da000712..f66c3f00da 100644
--- a/platform/osx/detect.py
+++ b/platform/osx/detect.py
@@ -103,7 +103,7 @@ def configure(env):
## Flags
env.Append(CPPPATH=['#platform/osx'])
- env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DAPPLE_STYLE_KEYS'])
+ env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DAPPLE_STYLE_KEYS', '-DCOREAUDIO_ENABLED'])
env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback'])
env.Append(LIBS=['pthread'])
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 6c81da04f5..1f76b7f990 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -31,13 +31,11 @@
#define OS_OSX_H
#include "crash_handler_osx.h"
-#include "drivers/alsa/audio_driver_alsa.h"
-#include "drivers/rtaudio/audio_driver_rtaudio.h"
+#include "drivers/coreaudio/audio_driver_coreaudio.h"
#include "drivers/unix/os_unix.h"
#include "joypad_osx.h"
#include "main/input_default.h"
#include "os/input.h"
-#include "platform/osx/audio_driver_osx.h"
#include "power_osx.h"
#include "servers/audio_server.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
@@ -69,7 +67,7 @@ public:
IP_Unix *ip_unix;
- AudioDriverOSX audio_driver_osx;
+ AudioDriverCoreAudio audio_driver;
InputDefault *input;
JoypadOSX *joypad_osx;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 9a26adc155..16bef349dc 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1071,7 +1071,7 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
bool use_gl2 = p_video_driver != 1;
- AudioDriverManager::add_driver(&audio_driver_osx);
+ AudioDriverManager::add_driver(&audio_driver);
// only opengl support here...
RasterizerGLES3::register_config();