Drop RtAudio driver on Windows

We've been defaulting to WASAPI since 3.0 and it's superior to RtAudio
in all aspects.

Obsoletes and closes #25503.

Also enable WINMIDI on MinGW, this had been missed initially.

Fix os_windows.cpp and crash_handler_windows.cpp which had weird
dependencies on RtAudio.h's includes (ugh).
This commit is contained in:
Rémi Verschelde 2019-02-20 13:00:19 +01:00
parent f41439c84b
commit 51c9ffaec0
14 changed files with 6 additions and 11738 deletions

View file

@ -18,7 +18,6 @@ doc_classes/* @godotengine/documentation
/drivers/coreaudio/ @marcelofg55
/drivers/coremidi/ @marcelofg55
/drivers/pulseaudio/ @marcelofg55
/drivers/rtaudio/ @marcelofg55
/drivers/wasapi/ @marcelofg55
/drivers/winmidi/ @marcelofg55
/drivers/xaudio2/ @marcelofg55

View file

@ -362,11 +362,6 @@ Comment: Recast
Copyright: 2009, Mikko Mononen
License: Zlib
Files: ./thirdparty/rtaudio/
Comment: RtAudio
Copyright: 2001-2016, Gary P. Scavone
License: Expat
Files: ./thirdparty/squish/
Comment: libSquish
Copyright: 2006, Simon Brown

1
drivers/SCsub vendored
View file

@ -13,7 +13,6 @@ SConscript('alsa/SCsub')
SConscript('coreaudio/SCsub')
SConscript('pulseaudio/SCsub')
if (env["platform"] == "windows"):
SConscript("rtaudio/SCsub")
SConscript("wasapi/SCsub")
if env['xaudio2']:
SConscript("xaudio2/SCsub")

View file

@ -1,23 +0,0 @@
#!/usr/bin/env python
Import('env')
# Not cloning the env, the includes need to be accessible for platform/
# Thirdparty source files
thirdparty_dir = "#thirdparty/rtaudio/"
thirdparty_sources = [
"RtAudio.cpp",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env.Append(CPPPATH=[thirdparty_dir])
env_thirdparty = env.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.drivers_sources, thirdparty_sources)
# Driver source files
env.add_source_files(env.drivers_sources, "*.cpp")
Export('env')

View file

@ -1,205 +0,0 @@
/*************************************************************************/
/* audio_driver_rtaudio.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 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_rtaudio.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#ifdef RTAUDIO_ENABLED
const char *AudioDriverRtAudio::get_name() const {
#ifdef OSX_ENABLED
return "RtAudio-OSX";
#elif defined(UNIX_ENABLED)
return "RtAudio-ALSA";
#elif defined(WINDOWS_ENABLED)
return "RtAudio-DirectSound";
#else
return "RtAudio-None";
#endif
}
int AudioDriverRtAudio::callback(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, double streamTime, RtAudioStreamStatus status, void *userData) {
if (status) {
if (status & RTAUDIO_INPUT_OVERFLOW) {
WARN_PRINT("RtAudio input overflow!");
}
if (status & RTAUDIO_OUTPUT_UNDERFLOW) {
WARN_PRINT("RtAudio output underflow!");
}
}
int32_t *buffer = (int32_t *)outputBuffer;
AudioDriverRtAudio *self = (AudioDriverRtAudio *)userData;
if (self->mutex->try_lock() != OK) {
// what should i do..
for (unsigned int i = 0; i < nBufferFrames; i++)
buffer[i] = 0;
return 0;
}
self->audio_server_process(nBufferFrames, buffer);
self->mutex->unlock();
return 0;
}
Error AudioDriverRtAudio::init() {
active = false;
mutex = Mutex::create(true);
dac = memnew(RtAudio);
ERR_EXPLAIN("Cannot initialize RtAudio audio driver: No devices present.")
ERR_FAIL_COND_V(dac->getDeviceCount() < 1, ERR_UNAVAILABLE);
// FIXME: Adapt to the OutputFormat -> SpeakerMode change
/*
String channels = GLOBAL_DEF_RST("audio/output","stereo");
if (channels=="5.1")
output_format=OUTPUT_5_1;
else if (channels=="quad")
output_format=OUTPUT_QUAD;
else if (channels=="mono")
output_format=OUTPUT_MONO;
else
output_format=OUTPUT_STEREO;
*/
RtAudio::StreamParameters parameters;
parameters.deviceId = dac->getDefaultOutputDevice();
RtAudio::StreamOptions options;
// set the desired numberOfBuffers
options.numberOfBuffers = 4;
parameters.firstChannel = 0;
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
int latency = GLOBAL_DEF("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
unsigned int buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
print_verbose("Audio buffer frames: " + itos(buffer_frames) + " calculated latency: " + itos(buffer_frames * 1000 / mix_rate) + "ms");
short int tries = 4;
while (tries > 0) {
switch (speaker_mode) {
case SPEAKER_MODE_STEREO: parameters.nChannels = 2; break;
case SPEAKER_SURROUND_31: parameters.nChannels = 4; break;
case SPEAKER_SURROUND_51: parameters.nChannels = 6; break;
case SPEAKER_SURROUND_71: parameters.nChannels = 8; break;
};
try {
dac->openStream(&parameters, NULL, RTAUDIO_SINT32, mix_rate, &buffer_frames, &callback, this, &options);
active = true;
break;
} catch (RtAudioError) {
// try with less channels
ERR_PRINT("Unable to open audio, retrying with fewer channels...");
switch (speaker_mode) {
case SPEAKER_MODE_STEREO: break; // Required to silence unhandled enum value warning.
case SPEAKER_SURROUND_31: speaker_mode = SPEAKER_MODE_STEREO; break;
case SPEAKER_SURROUND_51: speaker_mode = SPEAKER_SURROUND_31; break;
case SPEAKER_SURROUND_71: speaker_mode = SPEAKER_SURROUND_51; break;
}
tries--;
}
}
return active ? OK : ERR_UNAVAILABLE;
}
int AudioDriverRtAudio::get_mix_rate() const {
return mix_rate;
}
AudioDriver::SpeakerMode AudioDriverRtAudio::get_speaker_mode() const {
return speaker_mode;
}
void AudioDriverRtAudio::start() {
if (active)
dac->startStream();
}
void AudioDriverRtAudio::lock() {
if (mutex)
mutex->lock();
}
void AudioDriverRtAudio::unlock() {
if (mutex)
mutex->unlock();
}
void AudioDriverRtAudio::finish() {
lock();
if (active && dac->isStreamOpen()) {
dac->closeStream();
active = false;
}
unlock();
if (mutex) {
memdelete(mutex);
mutex = NULL;
}
if (dac) {
memdelete(dac);
dac = NULL;
}
}
AudioDriverRtAudio::AudioDriverRtAudio() :
speaker_mode(SPEAKER_MODE_STEREO),
mutex(NULL),
dac(NULL),
mix_rate(DEFAULT_MIX_RATE),
active(false) {
}
#endif

View file

@ -1,65 +0,0 @@
/*************************************************************************/
/* audio_driver_rtaudio.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 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. */
/*************************************************************************/
#ifndef AUDIO_DRIVER_RTAUDIO_H
#define AUDIO_DRIVER_RTAUDIO_H
#ifdef RTAUDIO_ENABLED
#include "servers/audio_server.h"
#include <RtAudio.h>
class AudioDriverRtAudio : public AudioDriver {
static int callback(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *userData);
SpeakerMode speaker_mode;
Mutex *mutex;
RtAudio *dac;
int mix_rate;
bool active;
public:
virtual const char *get_name() const;
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();
AudioDriverRtAudio();
};
#endif // AUDIO_DRIVER_RTAUDIO_H
#endif

View file

@ -32,7 +32,6 @@
#define OS_SERVER_H
#include "drivers/dummy/texture_loader_dummy.h"
#include "drivers/rtaudio/audio_driver_rtaudio.h"
#include "drivers/unix/os_unix.h"
#include "main/input_default.h"
#ifdef __APPLE__

View file

@ -30,9 +30,9 @@
#include "crash_handler_windows.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "main/main.h"
#include "os_windows.h"
#ifdef CRASH_HANDLER_EXCEPTION
@ -41,6 +41,7 @@
#include <psapi.h>
#include <algorithm>
#include <iterator>
#include <vector>
#pragma comment(lib, "psapi.lib")
#pragma comment(lib, "dbghelp.lib")

View file

@ -205,8 +205,8 @@ def configure_msvc(env, manual_msvc_config):
print("Missing environment variable: WindowsSdkDir")
env.AppendUnique(CPPDEFINES = ['WINDOWS_ENABLED', 'OPENGL_ENABLED',
'RTAUDIO_ENABLED', 'WASAPI_ENABLED',
'WINMIDI_ENABLED', 'TYPED_METHOD_BIND',
'WASAPI_ENABLED', 'WINMIDI_ENABLED',
'TYPED_METHOD_BIND',
'WIN32', 'MSVC',
'WINVER=%s' % env["target_win_version"],
'_WIN32_WINNT=%s' % env["target_win_version"]])
@ -326,8 +326,8 @@ def configure_mingw(env):
env.Append(CCFLAGS=['-DWINDOWS_ENABLED', '-mwindows'])
env.Append(CCFLAGS=['-DOPENGL_ENABLED'])
env.Append(CCFLAGS=['-DRTAUDIO_ENABLED'])
env.Append(CCFLAGS=['-DWASAPI_ENABLED'])
env.Append(CCFLAGS=['-DWINMIDI_ENABLED'])
env.Append(CCFLAGS=['-DWINVER=%s' % env['target_win_version'], '-D_WIN32_WINNT=%s' % env['target_win_version']])
env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid', 'ksuser', 'imm32', 'bcrypt','avrt'])

View file

@ -52,6 +52,7 @@
#include "windows_terminal_logger.h"
#include <avrt.h>
#include <direct.h>
#include <process.h>
#include <regstr.h>
#include <shlobj.h>
@ -3021,9 +3022,6 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) {
#ifdef WASAPI_ENABLED
AudioDriverManager::add_driver(&driver_wasapi);
#endif
#ifdef RTAUDIO_ENABLED
AudioDriverManager::add_driver(&driver_rtaudio);
#endif
#ifdef XAUDIO2_ENABLED
AudioDriverManager::add_driver(&driver_xaudio2);
#endif

View file

@ -36,7 +36,6 @@
#include "core/os/os.h"
#include "core/project_settings.h"
#include "crash_handler_windows.h"
#include "drivers/rtaudio/audio_driver_rtaudio.h"
#include "drivers/unix/ip_unix.h"
#include "drivers/wasapi/audio_driver_wasapi.h"
#include "drivers/winmidi/midi_driver_winmidi.h"
@ -142,9 +141,6 @@ class OS_Windows : public OS {
#ifdef WASAPI_ENABLED
AudioDriverWASAPI driver_wasapi;
#endif
#ifdef RTAUDIO_ENABLED
AudioDriverRtAudio driver_rtaudio;
#endif
#ifdef XAUDIO2_ENABLED
AudioDriverXAudio2 driver_xaudio2;
#endif

11
thirdparty/README.md vendored
View file

@ -470,17 +470,6 @@ Files extracted from upstream source:
- License.txt
## rtaudio
- Upstream: http://www.music.mcgill.ca/~gary/rtaudio/
- Version: 4.1.2
- License: MIT-like
Files extracted from upstream source:
- `RtAudio.{cpp,h}`
## squish
- Upstream: https://sourceforge.net/projects/libsquish

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff