diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-01-16 19:19:45 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2017-01-16 19:19:45 +0100 |
commit | 7b059965e8df745c5b45b4ec6bfbdfe1a7397642 (patch) | |
tree | bdba6b41f51fcb4c8aa5178aebd378bdf97b93a8 | |
parent | 6a3dae5be944d9e226cca7bf0bd80fb0036e8324 (diff) |
Adapt platforms to AudioServer refactoring
Fixes compilation on Windows and likely other platforms (at least
as far as AudioServer changes were concerned), though they were
not tested.
34 files changed, 123 insertions, 316 deletions
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index c16341a4a0..8984d412a3 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -30,11 +30,9 @@ #ifdef ALSA_ENABLED -#include <errno.h> #include "globals.h" - - +#include <errno.h> Error AudioDriverALSA::init() { @@ -46,7 +44,7 @@ Error AudioDriverALSA::init() { samples_out = NULL; mix_rate = GLOBAL_DEF("audio/mix_rate",44100); - output_format = SPEAKER_MODE_STEREO; + speaker_mode = SPEAKER_MODE_STEREO; channels = 2; @@ -207,14 +205,16 @@ int AudioDriverALSA::get_mix_rate() const { AudioDriver::SpeakerMode AudioDriverALSA::get_speaker_mode() const { - return output_format; + return speaker_mode; }; + void AudioDriverALSA::lock() { if (!thread || !mutex) return; mutex->lock(); }; + void AudioDriverALSA::unlock() { if (!thread || !mutex) diff --git a/drivers/alsa/audio_driver_alsa.h b/drivers/alsa/audio_driver_alsa.h index 96eb86ace1..6ab98312b2 100644 --- a/drivers/alsa/audio_driver_alsa.h +++ b/drivers/alsa/audio_driver_alsa.h @@ -48,7 +48,7 @@ class AudioDriverALSA : public AudioDriver { static void thread_func(void* p_udata); unsigned int mix_rate; - SpeakerMode output_format; + SpeakerMode speaker_mode; snd_pcm_uframes_t buffer_size; snd_pcm_uframes_t period_size; diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index b656d06d29..14b1b229b2 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -44,7 +44,7 @@ Error AudioDriverPulseAudio::init() { samples_out = NULL; mix_rate = GLOBAL_DEF("audio/mix_rate",44100); - output_format = SPEAKER_MODE_STEREO; + speaker_mode = SPEAKER_MODE_STEREO; channels = 2; pa_sample_spec spec; @@ -151,7 +151,7 @@ int AudioDriverPulseAudio::get_mix_rate() const { AudioDriver::SpeakerMode AudioDriverPulseAudio::get_speaker_mode() const { - return output_format; + return speaker_mode; } void AudioDriverPulseAudio::lock() { diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.h b/drivers/pulseaudio/audio_driver_pulseaudio.h index c385afba9a..36ae8c2e53 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.h +++ b/drivers/pulseaudio/audio_driver_pulseaudio.h @@ -48,7 +48,7 @@ class AudioDriverPulseAudio : public AudioDriver{ static void thread_func(void* p_udata); unsigned int mix_rate; - SpeakerMode output_format; + SpeakerMode speaker_mode; unsigned int buffer_size; int channels; diff --git a/drivers/rtaudio/audio_driver_rtaudio.cpp b/drivers/rtaudio/audio_driver_rtaudio.cpp index 6a54eb43fb..6ada0aaa68 100644 --- a/drivers/rtaudio/audio_driver_rtaudio.cpp +++ b/drivers/rtaudio/audio_driver_rtaudio.cpp @@ -85,6 +85,8 @@ Error AudioDriverRtAudio::init() { 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("audio/output","stereo"); if (channels=="5.1") @@ -95,6 +97,7 @@ Error AudioDriverRtAudio::init() { output_format=OUTPUT_MONO; else output_format=OUTPUT_STEREO; + */ RtAudio::StreamParameters parameters; parameters.deviceId = dac->getDefaultOutputDevice(); @@ -125,11 +128,10 @@ Error AudioDriverRtAudio::init() { while(true) { while( true) { - switch(output_format) { - case OUTPUT_MONO: parameters.nChannels = 1; break; - case OUTPUT_STEREO: parameters.nChannels = 2; break; - case OUTPUT_QUAD: parameters.nChannels = 4; break; - case OUTPUT_5_1: parameters.nChannels = 6; break; + switch(speaker_mode) { + case SPEAKER_MODE_STEREO: parameters.nChannels = 2; break; + case SPEAKER_SURROUND_51: parameters.nChannels = 6; break; + case SPEAKER_SURROUND_71: parameters.nChannels = 8; break; }; try { @@ -142,11 +144,10 @@ Error AudioDriverRtAudio::init() { // try with less channels ERR_PRINT("Unable to open audio, retrying with fewer channels.."); - switch(output_format) { - case OUTPUT_MONO: ERR_EXPLAIN("Unable to open audio."); ERR_FAIL_V( ERR_UNAVAILABLE ); break; - case OUTPUT_STEREO: output_format=OUTPUT_MONO; break; - case OUTPUT_QUAD: output_format=OUTPUT_STEREO; break; - case OUTPUT_5_1: output_format=OUTPUT_QUAD; break; + switch(speaker_mode) { + case SPEAKER_MODE_STEREO: speaker_mode=SPEAKER_MODE_STEREO; break; + case SPEAKER_SURROUND_51: speaker_mode=SPEAKER_SURROUND_51; break; + case SPEAKER_SURROUND_71: speaker_mode=SPEAKER_SURROUND_71; break; }; } } @@ -189,9 +190,9 @@ int AudioDriverRtAudio::get_mix_rate() const { return mix_rate; } -AudioDriverSW::OutputFormat AudioDriverRtAudio::get_output_format() const { +AudioDriver::SpeakerMode AudioDriverRtAudio::get_speaker_mode() const { - return output_format; + return speaker_mode; } void AudioDriverRtAudio::start() { @@ -229,7 +230,7 @@ AudioDriverRtAudio::AudioDriverRtAudio() mutex=NULL; mix_rate=44100; - output_format=OUTPUT_STEREO; + speaker_mode=SPEAKER_MODE_STEREO; } diff --git a/drivers/rtaudio/audio_driver_rtaudio.h b/drivers/rtaudio/audio_driver_rtaudio.h index aa7fae038a..3f293db6a6 100644 --- a/drivers/rtaudio/audio_driver_rtaudio.h +++ b/drivers/rtaudio/audio_driver_rtaudio.h @@ -31,16 +31,16 @@ #ifdef RTAUDIO_ENABLED -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include <RtAudio.h> -class AudioDriverRtAudio : public AudioDriverSW { +class AudioDriverRtAudio : public AudioDriver { static int callback( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, double streamTime, RtAudioStreamStatus status, void *userData ); - OutputFormat output_format; + SpeakerMode speaker_mode; Mutex *mutex; RtAudio *dac; int mix_rate; @@ -53,7 +53,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const ; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp index fd0e64b3dd..fa55c97325 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.cpp +++ b/drivers/xaudio2/audio_driver_xaudio2.cpp @@ -46,7 +46,8 @@ Error AudioDriverXAudio2::init() { mix_rate = 48000; - output_format = OUTPUT_STEREO; + // FIXME: speaker_mode seems unused in the Xaudio2 driver so far + speaker_mode = SPEAKER_MODE_STEREO; channels = 2; int latency = GLOBAL_DEF("audio/output_latency", 25); @@ -156,9 +157,9 @@ int AudioDriverXAudio2::get_mix_rate() const { return mix_rate; }; -AudioDriver::OutputFormat AudioDriverXAudio2::get_output_format() const { +AudioDriver::SpeakerMode AudioDriverXAudio2::get_speaker_mode() const { - return output_format; + return speaker_mode; }; float AudioDriverXAudio2::get_latency() { diff --git a/drivers/xaudio2/audio_driver_xaudio2.h b/drivers/xaudio2/audio_driver_xaudio2.h index b6425602ca..afafb84c23 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.h +++ b/drivers/xaudio2/audio_driver_xaudio2.h @@ -29,8 +29,7 @@ #ifndef AUDIO_DRIVER_XAUDIO2_H #define AUDIO_DRIVER_XAUDIO2_H -#include "servers/audio/audio_server_sw.h" - +#include "servers/audio_server.h" #include "core/os/thread.h" #include "core/os/mutex.h" @@ -72,7 +71,7 @@ class AudioDriverXAudio2 : public AudioDriver { int buffer_size; unsigned int mix_rate; - OutputFormat output_format; + SpeakerMode speaker_mode; int channels; @@ -96,7 +95,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual float get_latency(); virtual void lock(); virtual void unlock(); diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index a041678c0c..e0e89e6344 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -27,9 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "audio_driver_jandroid.h" + #include "globals.h" #include "os/os.h" #include "thread_jandroid.h" + #ifndef ANDROID_NATIVE_ACTIVITY AudioDriverAndroid* AudioDriverAndroid::s_ad=NULL; @@ -199,9 +201,9 @@ int AudioDriverAndroid::get_mix_rate() const { return mix_rate; } -AudioDriver::OutputFormat AudioDriverAndroid::get_output_format() const{ +AudioDriver::SpeakerMode AudioDriverAndroid::get_speaker_mode() const{ - return OUTPUT_STEREO; + return SPEAKER_MODE_STEREO; } void AudioDriverAndroid::lock(){ diff --git a/platform/android/audio_driver_jandroid.h b/platform/android/audio_driver_jandroid.h index bdb59c76fd..f485df2001 100644 --- a/platform/android/audio_driver_jandroid.h +++ b/platform/android/audio_driver_jandroid.h @@ -29,7 +29,8 @@ #ifndef AUDIO_DRIVER_ANDROID_H #define AUDIO_DRIVER_ANDROID_H -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" + #ifndef ANDROID_NATIVE_ACTIVITY #include "java_glue.h" @@ -65,7 +66,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const ; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index 7a9f6f73f9..2ec80f23c3 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -27,11 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "audio_driver_opensl.h" -#include <string.h> - - - +#include <string.h> #define MAX_NUMBER_INTERFACES 3 #define MAX_NUMBER_OUTPUT_DEVICES 6 @@ -373,9 +370,9 @@ int AudioDriverOpenSL::get_mix_rate() const { return 44100; } -AudioDriver::OutputFormat AudioDriverOpenSL::get_output_format() const{ +AudioDriver::SpeakerMode AudioDriverOpenSL::get_speaker_mode() const{ - return OUTPUT_STEREO; + return SPEAKER_MODE_STEREO; } void AudioDriverOpenSL::lock(){ diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h index 4915129041..1baaa95052 100644 --- a/platform/android/audio_driver_opensl.h +++ b/platform/android/audio_driver_opensl.h @@ -29,13 +29,11 @@ #ifndef AUDIO_DRIVER_OPENSL_H #define AUDIO_DRIVER_OPENSL_H - - -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include "os/mutex.h" -#include <SLES/OpenSLES.h> -#include "SLES/OpenSLES_Android.h" +#include <SLES/OpenSLES.h> +#include <SLES/OpenSLES_Android.h> class AudioDriverOpenSL : public AudioDriver { @@ -94,7 +92,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const ; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index c40e07b450..1095689a5b 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -27,18 +27,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "os_android.h" -#include "drivers/gles2/rasterizer_gles2.h" +#include "drivers/gles2/rasterizer_gles2.h" #include "core/io/file_access_buffered_fa.h" #include "drivers/unix/file_access_unix.h" #include "drivers/unix/dir_access_unix.h" - #include "servers/visual/visual_server_raster.h" #include "servers/visual/visual_server_wrap_mt.h" #include "main/main.h" - #include "file_access_android.h" - #include "core/globals.h" #ifdef ANDROID_NATIVE_ACTIVITY @@ -154,19 +151,6 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_ ERR_PRINT("Initializing audio failed."); } - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); - - audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,true); - audio_server->init(); - - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - - // physics_server = memnew( PhysicsServerSW ); physics_server->init(); //physics_2d_server = memnew( Physics2DServerSW ); diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 9ed7ba5fac..bf1db57ba5 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -33,31 +33,20 @@ #include "drivers/unix/os_unix.h" #include "os/main_loop.h" #include "servers/physics/physics_server_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/physics_2d/physics_2d_server_wrap_mt.h" #include "servers/visual/rasterizer.h" #include "main/input_default.h" - -//#ifdef USE_JAVA_FILE_ACCESS - +#include "audio_driver_jandroid.h" +#include "audio_driver_opensl.h" #ifdef ANDROID_NATIVE_ACTIVITY - #include <android/sensor.h> #include <android/log.h> #include <android_native_app_glue.h> - -#else - - #endif -#include "audio_driver_jandroid.h" -#include "audio_driver_opensl.h" - typedef void (*GFXInitFunc)(void *ud,bool gl2); typedef int (*OpenURIFunc)(const String&); typedef String (*GetDataDirFunc)(); @@ -118,10 +107,6 @@ private: Rasterizer *rasterizer; VisualServer *visual_server; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; diff --git a/platform/bb10/audio_driver_bb10.cpp b/platform/bb10/audio_driver_bb10.cpp index 6a56bfdbf0..b6ea0bc267 100644 --- a/platform/bb10/audio_driver_bb10.cpp +++ b/platform/bb10/audio_driver_bb10.cpp @@ -44,7 +44,7 @@ Error AudioDriverBB10::init(const char* p_name) { samples_out = NULL; mix_rate = 44100; - output_format = OUTPUT_STEREO; + speaker_mode = SPEAKER_MODE_STEREO; char* dev_name; if (p_name == NULL) { @@ -70,7 +70,7 @@ Error AudioDriverBB10::init(const char* p_name) { ERR_FAIL_COND_V(!(cinfo.formats & SND_PCM_FMT_S16_LE), FAILED); printf("voices %i\n", cinfo.max_voices); - output_format = cinfo.max_voices >= 2 ? OUTPUT_STEREO : OUTPUT_MONO; + speaker_mode = SPEAKER_MODE_STEREO; snd_pcm_channel_params_t cp; zeromem(&cp, sizeof(cp)); @@ -84,7 +84,7 @@ Error AudioDriverBB10::init(const char* p_name) { cp.buf.block.frags_min = 1; cp.format.interleave = 1; cp.format.rate = mix_rate; - cp.format.voices = output_format == OUTPUT_MONO ? 1 : 2; + cp.format.voices = speaker_mode; cp.format.format = SND_PCM_SFMT_S16_LE; ret = snd_pcm_plugin_params(pcm_handle, &cp); @@ -121,7 +121,7 @@ void AudioDriverBB10::thread_func(void* p_udata) { AudioDriverBB10* ad = (AudioDriverBB10*)p_udata; - int channels = (ad->output_format == OUTPUT_MONO ? 1 : 2); + int channels = speaker_mode; int frame_count = ad->sample_buf_count / channels; int bytes_out = frame_count * channels * 2; @@ -204,16 +204,18 @@ int AudioDriverBB10::get_mix_rate() const { return mix_rate; }; -AudioDriver::OutputFormat AudioDriverBB10::get_output_format() const { +AudioDriver::SpeakerMode AudioDriverBB10::get_speaker_mode() const { - return output_format; + return speaker_mode; }; + void AudioDriverBB10::lock() { if (!thread) return; mutex->lock(); }; + void AudioDriverBB10::unlock() { if (!thread) diff --git a/platform/bb10/audio_driver_bb10.h b/platform/bb10/audio_driver_bb10.h index bede583097..efb98b1b91 100644 --- a/platform/bb10/audio_driver_bb10.h +++ b/platform/bb10/audio_driver_bb10.h @@ -26,7 +26,7 @@ /* 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/audio_server_sw.h" +#include "servers/audio_server.h" #include "core/os/thread.h" #include "core/os/mutex.h" @@ -47,7 +47,7 @@ class AudioDriverBB10 : public AudioDriver { static void thread_func(void* p_udata); int mix_rate; - OutputFormat output_format; + SpeakerMode speaker_mode; int pcm_frag_size; int pcm_max_frags; @@ -67,7 +67,7 @@ public: virtual Error init(const char* p_name); virtual void start(); virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/platform/bb10/os_bb10.cpp b/platform/bb10/os_bb10.cpp index ea2e326b05..c51f1c6092 100644 --- a/platform/bb10/os_bb10.cpp +++ b/platform/bb10/os_bb10.cpp @@ -31,22 +31,21 @@ #include "drivers/gles2/rasterizer_gles2.h" #include "servers/visual/visual_server_raster.h" #include "core/os/dir_access.h" - #include "core/globals.h" #include "main/main.h" #include "bbutil.h" +#include "core/os/keyboard.h" + #include <stdlib.h> #include <stdbool.h> #include <assert.h> -#include "core/os/keyboard.h" - -#include "bps/bps.h" -#include "bps/screen.h" -#include "bps/navigator.h" -#include "bps/accelerometer.h" -#include "bps/orientation.h" -#include "bps/virtualkeyboard.h" -#include "bps/audiodevice.h" +#include <bps/bps.h> +#include <bps/screen.h> +#include <bps/navigator.h> +#include <bps/accelerometer.h> +#include <bps/orientation.h> +#include <bps/virtualkeyboard.h> +#include <bps/audiodevice.h> #ifdef BB10_SCORELOOP_ENABLED #include "modules/scoreloop/scoreloop_bb10.h" @@ -141,18 +140,6 @@ void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi audio_driver->set_singleton(); audio_driver->init(NULL); - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); - audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,false); - audio_server->init(); - - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - - // physics_server = memnew( PhysicsServerSW ); physics_server->init(); physics_2d_server = memnew( Physics2DServerSW ); @@ -185,22 +172,12 @@ void OSBB10::finalize() { memdelete(main_loop); main_loop=NULL; - spatial_sound_server->finish(); - memdelete(spatial_sound_server); - spatial_sound_2d_server->finish(); - memdelete(spatial_sound_2d_server); - /* if (debugger_connection_console) { memdelete(debugger_connection_console); } */ - memdelete(sample_manager); - - audio_server->finish(); - memdelete(audio_server); - visual_server->finish(); memdelete(visual_server); memdelete(rasterizer); diff --git a/platform/bb10/os_bb10.h b/platform/bb10/os_bb10.h index 5c484cd120..9cf2091d49 100644 --- a/platform/bb10/os_bb10.h +++ b/platform/bb10/os_bb10.h @@ -34,9 +34,7 @@ #include "os/main_loop.h" #include "main/input_default.h" #include "servers/physics/physics_server_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/visual/rasterizer.h" #include "audio_driver_bb10.h" @@ -44,8 +42,7 @@ #include <screen/screen.h> #include <sys/platform.h> -#include "bps/event.h" - +#include <bps/event.h> #include <stdint.h> class OSBB10 : public OS_Unix { @@ -58,11 +55,6 @@ class OSBB10 : public OS_Unix { Rasterizer *rasterizer; VisualServer *visual_server; - //AudioDriverPSP audio_driver_psp; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; AudioDriverBB10* audio_driver; diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp index 2af93061f8..c6afe7a261 100644 --- a/platform/haiku/audio_driver_media_kit.cpp +++ b/platform/haiku/audio_driver_media_kit.cpp @@ -38,7 +38,7 @@ Error AudioDriverMediaKit::init() { active = false; mix_rate = 44100; - output_format = OUTPUT_STEREO; + speaker_mode = SPEAKER_MODE_STEREO; channels = 2; int latency = GLOBAL_DEF("audio/output_latency", 25); @@ -99,8 +99,8 @@ int AudioDriverMediaKit::get_mix_rate() const { return mix_rate; } -AudioDriverSW::OutputFormat AudioDriverMediaKit::get_output_format() const { - return output_format; +AudioDriverSW::SpeakerMode AudioDriverMediaKit::get_speaker_mode() const { + return speaker_mode; } void AudioDriverMediaKit::lock() { diff --git a/platform/haiku/audio_driver_media_kit.h b/platform/haiku/audio_driver_media_kit.h index fbf6bc20de..ce760f8dd7 100644 --- a/platform/haiku/audio_driver_media_kit.h +++ b/platform/haiku/audio_driver_media_kit.h @@ -26,7 +26,7 @@ /* 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/audio_server_sw.h" +#include "servers/audio_server.h" #ifdef MEDIA_KIT_ENABLED @@ -36,7 +36,7 @@ #include <kernel/image.h> // needed for image_id #include <SoundPlayer.h> -class AudioDriverMediaKit : public AudioDriverSW { +class AudioDriverMediaKit : public AudioDriver { Mutex* mutex; BSoundPlayer* player; @@ -45,7 +45,7 @@ class AudioDriverMediaKit : public AudioDriverSW { static void PlayBuffer(void* cookie, void* buffer, size_t size, const media_raw_audio_format& format); unsigned int mix_rate; - OutputFormat output_format; + SpeakerMode speaker_mode; unsigned int buffer_size; int channels; @@ -60,7 +60,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index c5d2dbde85..9f218aeff4 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -40,7 +40,7 @@ OS_Haiku::OS_Haiku() { #ifdef MEDIA_KIT_ENABLED - AudioDriverManagerSW::add_driver(&driver_media_kit); + AudioDriverManager::add_driver(&driver_media_kit); #endif }; @@ -143,15 +143,6 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_ if (AudioDriverManager::get_driver(p_audio_driver)->init() != OK) { ERR_PRINT("Initializing audio failed."); } - - sample_manager = memnew(SampleManagerMallocSW); - audio_server = memnew(AudioServerSW(sample_manager)); - audio_server->init(); - - spatial_sound_server = memnew(SpatialSoundServerSW); - spatial_sound_server->init(); - spatial_sound_2d_server = memnew(SpatialSound2DServerSW); - spatial_sound_2d_server->init(); } void OS_Haiku::finalize() { @@ -161,17 +152,6 @@ void OS_Haiku::finalize() { main_loop = NULL; - spatial_sound_server->finish(); - memdelete(spatial_sound_server); - - spatial_sound_2d_server->finish(); - memdelete(spatial_sound_2d_server); - - memdelete(sample_manager); - - audio_server->finish(); - memdelete(audio_server); - visual_server->finish(); memdelete(visual_server); memdelete(rasterizer); diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index fc873f49ad..531c7a56c3 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -34,12 +34,8 @@ #include "servers/visual/rasterizer.h" #include "servers/physics_server.h" #include "servers/physics_2d/physics_2d_server_sw.h" -#include "servers/audio/audio_server_sw.h" -#include "servers/audio/sample_manager_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" +#include "servers/audio_server.h" #include "main/input_default.h" - #include "audio_driver_media_kit.h" #include "context_gl_haiku.h" #include "haiku_application.h" @@ -57,10 +53,6 @@ private: VideoMode current_video_mode; PhysicsServer* physics_server; Physics2DServer* physics_2d_server; - AudioServerSW* audio_server; - SampleManagerMallocSW* sample_manager; - SpatialSoundServerSW* spatial_sound_server; - SpatialSound2DServerSW* spatial_sound_2d_server; #ifdef MEDIA_KIT_ENABLED AudioDriverMediaKit driver_media_kit; diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp index 71332c897e..bff01d7c37 100644 --- a/platform/javascript/audio_driver_javascript.cpp +++ b/platform/javascript/audio_driver_javascript.cpp @@ -27,20 +27,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "audio_driver_javascript.h" -#include <string.h> - - - - +#include <string.h> #define MAX_NUMBER_INTERFACES 3 #define MAX_NUMBER_OUTPUT_DEVICES 6 /* Structure for passing information to callback function */ - - //AudioDriverJavaScript* AudioDriverJavaScript::s_ad=NULL; const char* AudioDriverJavaScript::get_name() const { @@ -53,19 +47,23 @@ Error AudioDriverJavaScript::init(){ return OK; } + void AudioDriverJavaScript::start(){ } + int AudioDriverJavaScript::get_mix_rate() const { return 44100; } -AudioDriver::OutputFormat AudioDriverJavaScript::get_output_format() const{ - return OUTPUT_STEREO; +AudioDriver::SpeakerMode AudioDriverJavaScript::get_speaker_mode() const{ + + return SPEAKER_MODE_STEREO; } + void AudioDriverJavaScript::lock(){ /* @@ -74,6 +72,7 @@ void AudioDriverJavaScript::lock(){ */ } + void AudioDriverJavaScript::unlock() { /* @@ -82,11 +81,11 @@ void AudioDriverJavaScript::unlock() { */ } + void AudioDriverJavaScript::finish(){ } - AudioDriverJavaScript::AudioDriverJavaScript() { } diff --git a/platform/javascript/audio_driver_javascript.h b/platform/javascript/audio_driver_javascript.h index 572d24b4fc..da146fcdd0 100644 --- a/platform/javascript/audio_driver_javascript.h +++ b/platform/javascript/audio_driver_javascript.h @@ -29,8 +29,8 @@ #ifndef AUDIO_DRIVER_JAVASCRIPT_H #define AUDIO_DRIVER_JAVASCRIPT_H +#include "servers/audio_server.h" -#include "servers/audio/audio_server_sw.h" #include "os/mutex.h" class AudioDriverJavaScript : public AudioDriver { @@ -43,7 +43,7 @@ public: virtual Error init(); virtual void start(); virtual int get_mix_rate() const ; - virtual OutputFormat get_output_format() const; + virtual SpeakerMode get_speaker_mode() const; virtual void lock(); virtual void unlock(); virtual void finish(); diff --git a/platform/javascript/audio_server_javascript.h b/platform/javascript/audio_server_javascript.h index 8e61e94dfc..f8c8774e4c 100644 --- a/platform/javascript/audio_server_javascript.h +++ b/platform/javascript/audio_server_javascript.h @@ -29,7 +29,6 @@ #ifndef AUDIO_SERVER_JAVASCRIPT_H #define AUDIO_SERVER_JAVASCRIPT_H - #include "servers/audio_server.h" class AudioServerJavascript : public AudioServer { diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 396657461b..317a6676a4 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -27,24 +27,24 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "os_javascript.h" + #include "drivers/gles2/rasterizer_gles2.h" #include "core/io/file_access_buffered_fa.h" #include "drivers/unix/file_access_unix.h" #include "drivers/unix/dir_access_unix.h" - #include "servers/visual/visual_server_raster.h" - #include "main/main.h" - #include "core/globals.h" -#include "stdlib.h" -#include "emscripten.h" #include "dom_keys.h" +#include <stdlib.h> +#include <emscripten.h> + int OS_JavaScript::get_video_driver_count() const { return 1; } + const char * OS_JavaScript::get_video_driver_name(int p_driver) const { return "GLES2"; @@ -261,27 +261,6 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int ERR_PRINT("Initializing audio failed."); }*/ - print_line("Init SM"); - - //sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerJavascript ); - - print_line("Init Mixer"); - - //audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,false); - audio_server->init(); - - print_line("Init SoundServer"); - - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - - print_line("Init SpatialSoundServer"); - - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - - // print_line("Init Physicsserver"); physics_server = memnew( PhysicsServerSW ); diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 370322e93d..d11494a8aa 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -35,15 +35,16 @@ #include "servers/physics/physics_server_sw.h" #include "servers/spatial_sound/spatial_sound_server_sw.h" #include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/visual/rasterizer.h" #include "audio_server_javascript.h" #include "audio_driver_javascript.h" #include "main/input_default.h" -#include "emscripten/html5.h" #include "javascript_eval.h" +#include <emscripten/html5.h> + typedef void (*GFXInitFunc)(void *ud,bool gl2,int w, int h, bool fs); typedef String (*GetDataDirFunc)(); @@ -71,10 +72,6 @@ private: Rasterizer *rasterizer; VisualServer *visual_server; - AudioServerJavascript *audio_server; - //SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; AudioDriverJavaScript audio_driver_javascript; diff --git a/platform/server/os_server.h b/platform/server/os_server.h index f7fe586b1b..2b6225c48d 100644 --- a/platform/server/os_server.h +++ b/platform/server/os_server.h @@ -29,17 +29,13 @@ #ifndef OS_SERVER_H #define OS_SERVER_H - #include "main/input_default.h" #include "drivers/unix/os_unix.h" #include "servers/visual_server.h" #include "servers/visual/rasterizer.h" #include "servers/audio/audio_driver_dummy.h" #include "servers/physics_server.h" -#include "servers/audio/audio_server_sw.h" -#include "servers/audio/sample_manager_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" +#include "servers/audio_server.h" #include "drivers/rtaudio/audio_driver_rtaudio.h" #include "servers/physics_2d/physics_2d_server_sw.h" @@ -66,11 +62,6 @@ class OS_Server : public OS_Unix { virtual void delete_main_loop(); IP_Unix *ip_unix; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; - bool force_quit; InputDefault *input; diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 831b129bdc..90c21e11a1 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -36,16 +36,12 @@ #include "main/main.h" #include "drivers/windows/file_access_windows.h" #include "drivers/windows/dir_access_windows.h" - - #include "servers/visual/visual_server_raster.h" -#include "servers/audio/audio_server_sw.h" -#include "servers/visual/visual_server_wrap_mt.h" - +#include "servers/audio_server.h" +//#include "servers/visual/visual_server_wrap_mt.h" #include "os/memory_pool_dynamic_prealloc.h" #include "globals.h" #include "io/marshalls.h" - #include "platform/windows/packet_peer_udp_winsock.h" #include "platform/windows/stream_peer_winsock.h" #include "platform/windows/tcp_server_winsock.h" @@ -147,6 +143,7 @@ int OSUWP::get_audio_driver_count() const { return AudioDriverManager::get_driver_count(); } + const char * OSUWP::get_audio_driver_name(int p_driver) const { AudioDriver* driver = AudioDriverManager::get_driver(p_driver); @@ -295,16 +292,6 @@ void OSUWP::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio ERR_PRINT("Initializing audio failed."); } - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); - - audio_server->init(); - - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - managed_object->update_clipboard(); Clipboard::ContentChanged += ref new EventHandler<Platform::Object^>(managed_object, &ManagedType::on_clipboard_changed); @@ -407,22 +394,12 @@ void OSUWP::finalize() { if (rasterizer) memdelete(rasterizer); - spatial_sound_server->finish(); - memdelete(spatial_sound_server); - spatial_sound_2d_server->finish(); - memdelete(spatial_sound_2d_server); - /* if (debugger_connection_console) { memdelete(debugger_connection_console); } */ - memdelete(sample_manager); - - audio_server->finish(); - memdelete(audio_server); - memdelete(input); physics_server->finish(); diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index f9e050e7a3..f65aa2d8d9 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -34,28 +34,19 @@ #include "servers/visual_server.h" #include "servers/visual/rasterizer.h" #include "servers/physics/physics_server_sw.h" - -#include "servers/audio/audio_server_sw.h" -#include "servers/audio/sample_manager_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" +#include "servers/audio_server.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "drivers/xaudio2/audio_driver_xaudio2.h" - #include "gl_context_egl.h" - #include "core/math/math_2d.h" #include "core/ustring.h" +#include "main/input_default.h" +#include "joypad_uwp.h" #include <windows.h> - #include <io.h> - #include <fcntl.h> #include <stdio.h> -#include "main/input_default.h" - -#include "joypad_uwp.h" /** @author Juan Linietsky <reduzio@gmail.com> @@ -119,10 +110,6 @@ private: MainLoop *main_loop; AudioDriverXAudio2 audio_driver; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; MouseMode mouse_mode; bool alt_mem; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index c15f5225d9..6439de67a6 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -30,30 +30,25 @@ #include "os_windows.h" #include "drivers/gles3/rasterizer_gles3.h" - #include "drivers/windows/thread_windows.h" #include "drivers/windows/semaphore_windows.h" #include "drivers/windows/mutex_windows.h" #include "drivers/windows/rw_lock_windows.h" -#include "main/main.h" #include "drivers/windows/file_access_windows.h" #include "drivers/windows/dir_access_windows.h" - - #include "servers/visual/visual_server_raster.h" -#include "servers/audio/audio_server_sw.h" +#include "servers/audio_server.h" //#include "servers/visual/visual_server_wrap_mt.h" - +#include "main/main.h" #include "tcp_server_winsock.h" #include "packet_peer_udp_winsock.h" #include "stream_peer_winsock.h" #include "lang_table.h" - #include "globals.h" #include "io/marshalls.h" #include "joypad.h" -#include "shlobj.h" +#include <shlobj.h> #include <regstr.h> #include <process.h> @@ -1131,16 +1126,6 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_ ERR_PRINT("Initializing audio failed."); } - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); - - audio_server->init(); - - spatial_sound_server = memnew( SpatialSoundServerSW ); - spatial_sound_server->init(); - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); - spatial_sound_2d_server->init(); - TRACKMOUSEEVENT tme; tme.cbSize=sizeof(TRACKMOUSEEVENT); tme.dwFlags=TME_LEAVE; @@ -1271,22 +1256,12 @@ void OS_Windows::finalize() { SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc); }; - spatial_sound_server->finish(); - memdelete(spatial_sound_server); - spatial_sound_2d_server->finish(); - memdelete(spatial_sound_2d_server); - /* if (debugger_connection_console) { memdelete(debugger_connection_console); } */ - memdelete(sample_manager); - - audio_server->finish(); - memdelete(audio_server); - physics_server->finish(); memdelete(physics_server); @@ -2432,10 +2407,10 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) { user_proc = NULL; #ifdef RTAUDIO_ENABLED - AudioDriverManagerSW::add_driver(&driver_rtaudio); + AudioDriverManager::add_driver(&driver_rtaudio); #endif #ifdef XAUDIO2_ENABLED - AudioDriverManagerSW::add_driver(&driver_xaudio2); + AudioDriverManager::add_driver(&driver_xaudio2); #endif } diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 7ca89e6366..a5c8ecbe1b 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -35,29 +35,24 @@ #include "servers/visual_server.h" #include "servers/visual/rasterizer.h" #include "servers/physics/physics_server_sw.h" - -#include "servers/audio/audio_server_sw.h" -#include "servers/audio/sample_manager_sw.h" +#include "servers/audio_server.h" #include "drivers/rtaudio/audio_driver_rtaudio.h" #ifdef XAUDIO2_ENABLED #include "drivers/xaudio2/audio_driver_xaudio2.h" #endif -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" #include "drivers/unix/ip_unix.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/physics_2d/physics_2d_server_wrap_mt.h" - #include "main/input_default.h" +#include "key_mapping_win.h" -#include <windows.h> -#include "key_mapping_win.h" +#include <windows.h> #include <windowsx.h> #include <io.h> - #include <fcntl.h> #include <stdio.h> + /** @author Juan Linietsky <reduzio@gmail.com> */ @@ -116,11 +111,6 @@ class OS_Windows : public OS { WNDPROC user_proc; - AudioServerSW *audio_server; - SampleManagerMallocSW *sample_manager; - SpatialSoundServerSW *spatial_sound_server; - SpatialSound2DServerSW *spatial_sound_2d_server; - MouseMode mouse_mode; bool alt_mem; bool gr_mem; diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp index 0d9a915188..6e0c0089ca 100644 --- a/servers/audio/audio_driver_dummy.cpp +++ b/servers/audio/audio_driver_dummy.cpp @@ -43,7 +43,7 @@ Error AudioDriverDummy::init() { mix_rate = 44100; - output_format = SPEAKER_MODE_STEREO; + speaker_mode = SPEAKER_MODE_STEREO; channels = 2; int latency = GLOBAL_DEF("audio/output_latency",25); @@ -99,14 +99,16 @@ int AudioDriverDummy::get_mix_rate() const { AudioDriver::SpeakerMode AudioDriverDummy::get_speaker_mode() const { - return output_format; + return speaker_mode; }; + void AudioDriverDummy::lock() { if (!thread || !mutex) return; mutex->lock(); }; + void AudioDriverDummy::unlock() { if (!thread || !mutex) diff --git a/servers/audio/audio_driver_dummy.h b/servers/audio/audio_driver_dummy.h index a848b0630a..78ec41ea09 100644 --- a/servers/audio/audio_driver_dummy.h +++ b/servers/audio/audio_driver_dummy.h @@ -46,7 +46,7 @@ class AudioDriverDummy : public AudioDriver { int buffer_size; unsigned int mix_rate; - SpeakerMode output_format; + SpeakerMode speaker_mode; int channels; |