summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/math/math_funcs.cpp25
-rw-r--r--core/math/math_funcs.h7
-rw-r--r--core/math/pcg.cpp15
-rw-r--r--core/math/pcg.h14
-rw-r--r--doc/base/classes.xml10
-rw-r--r--drivers/alsa/audio_driver_alsa.cpp10
-rw-r--r--drivers/alsa/audio_driver_alsa.h2
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp4
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.h2
-rw-r--r--drivers/rtaudio/audio_driver_rtaudio.cpp27
-rw-r--r--drivers/rtaudio/audio_driver_rtaudio.h8
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.cpp7
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.h7
-rw-r--r--modules/gdscript/gd_functions.cpp4
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp4
-rw-r--r--platform/android/audio_driver_jandroid.cpp6
-rw-r--r--platform/android/audio_driver_jandroid.h5
-rw-r--r--platform/android/audio_driver_opensl.cpp9
-rw-r--r--platform/android/audio_driver_opensl.h10
-rw-r--r--platform/android/os_android.cpp18
-rw-r--r--platform/android/os_android.h21
-rw-r--r--platform/bb10/audio_driver_bb10.cpp14
-rw-r--r--platform/bb10/audio_driver_bb10.h6
-rw-r--r--platform/bb10/os_bb10.cpp41
-rw-r--r--platform/bb10/os_bb10.h12
-rw-r--r--platform/haiku/audio_driver_media_kit.cpp6
-rw-r--r--platform/haiku/audio_driver_media_kit.h8
-rw-r--r--platform/haiku/os_haiku.cpp22
-rw-r--r--platform/haiku/os_haiku.h10
-rw-r--r--platform/javascript/audio_driver_javascript.cpp19
-rw-r--r--platform/javascript/audio_driver_javascript.h4
-rw-r--r--platform/javascript/audio_server_javascript.h1
-rw-r--r--platform/javascript/os_javascript.cpp31
-rw-r--r--platform/javascript/os_javascript.h9
-rw-r--r--platform/server/os_server.h11
-rw-r--r--platform/uwp/os_uwp.cpp29
-rw-r--r--platform/uwp/os_uwp.h19
-rw-r--r--platform/windows/os_windows.cpp47
-rw-r--r--platform/windows/os_windows.h18
-rw-r--r--servers/audio/audio_driver_dummy.cpp6
-rw-r--r--servers/audio/audio_driver_dummy.h2
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp6
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.h2
-rw-r--r--tools/editor/scene_tree_dock.cpp18
-rw-r--r--tools/editor/scene_tree_dock.h1
45 files changed, 200 insertions, 357 deletions
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 8353aa0ebe..ef8c1ec539 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -31,8 +31,9 @@
#include "core/os/os.h"
#include "float.h"
-uint32_t Math::default_seed=1;
+#include "pcg.h"
+pcg32_random_t Math::default_pcg = {1, PCG_DEFAULT_INC_64};
#define PHI 0x9e3779b9
@@ -40,28 +41,26 @@ uint32_t Math::default_seed=1;
static uint32_t Q[4096];
#endif
-uint32_t Math::rand_from_seed(uint32_t *seed) {
- // Xorshift31 PRNG
- if ( *seed == 0 ) *seed = Math::RANDOM_MAX;
- (*seed) ^= (*seed) << 13;
- (*seed) ^= (*seed) >> 17;
- (*seed) ^= (*seed) << 5;
- return (*seed) & Math::RANDOM_MAX;
+// TODO: we should eventually expose pcg.inc too
+uint32_t Math::rand_from_seed(uint64_t *seed) {
+ pcg32_random_t pcg = {*seed, PCG_DEFAULT_INC_64};
+ uint32_t r = pcg32_random_r(&pcg);
+ *seed = pcg.state;
+ return r;
}
-void Math::seed(uint32_t x) {
- default_seed=x;
+void Math::seed(uint64_t x) {
+ default_pcg.state=x;
}
void Math::randomize() {
OS::Time time = OS::get_singleton()->get_time();
- seed(OS::get_singleton()->get_ticks_usec()*(time.hour+1)*(time.min+1)*(time.sec+1)*rand()); /* *OS::get_singleton()->get_time().sec); // windows doesn't have get_time(), returns always 0 */
+ seed(OS::get_singleton()->get_ticks_usec()*(time.hour+1)*(time.min+1)*(time.sec+1)*rand()); // TODO: can be simplified.
}
uint32_t Math::rand() {
-
- return rand_from_seed(&default_seed);
+ return pcg32_random_r(&default_pcg);
}
double Math::randf() {
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 8ce59224ff..e81646b1ca 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -31,6 +31,7 @@
#include "typedefs.h"
#include "math_defs.h"
+#include "pcg.h"
#ifndef NO_MATH_H
#include <math.h>
@@ -41,8 +42,8 @@
class Math {
+ static pcg32_random_t default_pcg;
- static uint32_t default_seed;
public:
Math() {} // useless to instance
@@ -150,12 +151,12 @@ public:
}
- static uint32_t rand_from_seed(uint32_t *seed);
+ static uint32_t rand_from_seed(uint64_t *seed);
static double ease(double p_x, double p_c);
static int step_decimals(double p_step);
static double stepify(double p_value,double p_step);
- static void seed(uint32_t x=0);
+ static void seed(uint64_t x=0);
static void randomize();
static uint32_t larger_prime(uint32_t p_val);
static double dectime(double p_value,double p_amount, double p_step);
diff --git a/core/math/pcg.cpp b/core/math/pcg.cpp
new file mode 100644
index 0000000000..eac3b36d36
--- /dev/null
+++ b/core/math/pcg.cpp
@@ -0,0 +1,15 @@
+// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / pcg-random.org
+// Licensed under Apache License 2.0 (NO WARRANTY, etc. see website)
+
+#include "pcg.h"
+
+uint32_t pcg32_random_r(pcg32_random_t* rng)
+{
+ uint64_t oldstate = rng->state;
+ // Advance internal state
+ rng->state = oldstate * 6364136223846793005ULL + (rng->inc|1);
+ // Calculate output function (XSH RR), uses old state for max ILP
+ uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u;
+ uint32_t rot = oldstate >> 59u;
+ return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
+}
diff --git a/core/math/pcg.h b/core/math/pcg.h
new file mode 100644
index 0000000000..81f4c9770e
--- /dev/null
+++ b/core/math/pcg.h
@@ -0,0 +1,14 @@
+// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / pcg-random.org
+// Licensed under Apache License 2.0 (NO WARRANTY, etc. see website)
+
+#ifndef RANDOM_H
+#define RANDOM_H
+
+#include "typedefs.h"
+
+#define PCG_DEFAULT_INC_64 1442695040888963407ULL
+
+typedef struct { uint64_t state; uint64_t inc; } pcg32_random_t;
+uint32_t pcg32_random_r(pcg32_random_t* rng);
+
+#endif // RANDOM_H
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 0088f576f0..0b8c5cc11c 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -463,7 +463,7 @@
<argument index="1" name="to" type="float">
</argument>
<description>
- Random range, any floating point value between 'from' and 'to'
+ Random range, any floating point value between 'from' and 'to'.
</description>
</method>
<method name="rand_seed">
@@ -472,28 +472,28 @@
<argument index="0" name="seed" type="int">
</argument>
<description>
- Random from seed, pass a seed and an array with both number and new seed is returned.
+ Random from seed: pass a seed, and an array with both number and new seed is returned. "Seed" here refers to the internal state of the pseudo random number generator. The internal state of the current implementation is 64 bits.
</description>
</method>
<method name="randf">
<return type="float">
</return>
<description>
- Random value (0 to 1 float).
+ Return a random floating point value between 0 and 1.
</description>
</method>
<method name="randi">
<return type="int">
</return>
<description>
- Random 32 bits value (integer). To obtain a value from 0 to N, you can use remainder, like (for random from 0 to 19): randi() % 20.
+ Return a random 32 bits integer value. To obtain a random value between 0 to N (where N is smaller than 2^32 - 1), you can use remainder. For example, to get a random integer between 0 and 19 inclusive, you can use randi() % 20.
</description>
</method>
<method name="randomize">
<return type="Nil">
</return>
<description>
- Reset the seed of the random number generator with a new, different one.
+ Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
</description>
</method>
<method name="range">
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/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index f1e9f7de08..4f3516c097 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -351,14 +351,14 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
case MATH_SEED: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- uint32_t seed=*p_args[0];
+ uint64_t seed=*p_args[0];
Math::seed(seed);
r_ret=Variant();
} break;
case MATH_RANDSEED: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- uint32_t seed=*p_args[0];
+ uint64_t seed=*p_args[0];
int ret = Math::rand_from_seed(&seed);
Array reta;
reta.push_back(ret);
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 422e323d6d..169af6fbec 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -802,14 +802,14 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp
case VisualScriptBuiltinFunc::MATH_SEED: {
VALIDATE_ARG_NUM(0);
- uint32_t seed=*p_inputs[0];
+ uint64_t seed=*p_inputs[0];
Math::seed(seed);
} break;
case VisualScriptBuiltinFunc::MATH_RANDSEED: {
VALIDATE_ARG_NUM(0);
- uint32_t seed=*p_inputs[0];
+ uint64_t seed=*p_inputs[0];
int ret = Math::rand_from_seed(&seed);
Array reta;
reta.push_back(ret);
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..d1d769adf7 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);
@@ -1325,18 +1300,10 @@ void OS_Windows::vprint(const char* p_format, va_list p_list, bool p_stderr) {
MultiByteToWideChar(CP_UTF8,0,buf,len,wbuf,wlen);
wbuf[wlen]=0;
-// Recent MinGW and MSVC compilers seem to disagree on the case here
-#ifdef __MINGW32__
- if (p_stderr)
- fwprintf(stderr, L"%S", wbuf);
- else
- wprintf(L"%S", wbuf);
-#else // MSVC
if (p_stderr)
- fwprintf(stderr, L"%s", wbuf);
+ fwprintf(stderr, L"%ls", wbuf);
else
- wprintf(L"%s", wbuf);
-#endif
+ wprintf(L"%ls", wbuf);
#ifdef STDOUT_FILE
//vwfprintf(stdo,p_format,p_list);
@@ -2432,10 +2399,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;
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index f45194f53f..4b67df3a98 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -2297,10 +2297,10 @@ void SpatialEditorViewport::reset() {
message_time=0;
message="";
last_message="";
- name=TTR("Top");
+ name="";
- cursor.x_rot=0;
- cursor.y_rot=0;
+ cursor.x_rot=0.5;
+ cursor.y_rot=0.5;
cursor.distance=4;
cursor.region_select=false;
_update_name();
diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h
index 6e5243e6ab..36f807c11f 100644
--- a/tools/editor/plugins/spatial_editor_plugin.h
+++ b/tools/editor/plugins/spatial_editor_plugin.h
@@ -208,7 +208,7 @@ private:
bool region_select;
Point2 region_begin,region_end;
- Cursor() { x_rot=y_rot=0; distance=4; region_select=false; }
+ Cursor() { x_rot=y_rot=0.5; distance=4; region_select=false; }
} cursor;
RID move_gizmo_instance[3], rotate_gizmo_instance[3];
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index bd81c57676..6247a9b578 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -105,6 +105,9 @@ void SceneTreeDock::_unhandled_key_input(InputEvent p_event) {
else if (ED_IS_SHORTCUT("scene_tree/delete_no_confirm", p_event)) {
_tool_selected(TOOL_ERASE, true);
}
+ else if(ED_IS_SHORTCUT("scene_tree/copy_node_path", p_event)) {
+ _tool_selected(TOOL_COPY_NODE_PATH);
+ }
else if (ED_IS_SHORTCUT("scene_tree/delete", p_event)) {
_tool_selected(TOOL_ERASE);
}
@@ -674,7 +677,17 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
new_scene_from_dialog->set_title(TTR("Save New Scene As.."));
} break;
+ case TOOL_COPY_NODE_PATH: {
+ List<Node*> selection = editor_selection->get_selected_node_list();
+ if(List<Node*>::Element *e = selection.front()) {
+ if(Node *node = e->get()) {
+ Node *root = EditorNode::get_singleton()->get_edited_scene();
+ NodePath path = root->get_path().rel_path_to(node->get_path());
+ OS::get_singleton()->set_clipboard(path);
+ }
+ }
+ } break;
}
}
@@ -1808,11 +1821,11 @@ void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) {
menu->add_separator();
menu->add_icon_shortcut(get_icon("Blend","EditorIcons"),ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE);
menu->add_icon_shortcut(get_icon("Save","EditorIcons"),ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM);
+ menu->add_separator();
+ menu->add_icon_shortcut(get_icon("Duplicate","EditorIcons"), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH);
}
menu->add_separator();
-
menu->add_icon_shortcut(get_icon("Remove","EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE);
-
menu->set_size(Size2(1,1));
menu->set_pos(p_menu_pos);
menu->popup();
@@ -1914,6 +1927,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
ED_SHORTCUT("scene_tree/reparent", TTR("Reparent"));
ED_SHORTCUT("scene_tree/merge_from_scene", TTR("Merge From Scene"));
ED_SHORTCUT("scene_tree/save_branch_as_scene", TTR("Save Branch as Scene"));
+ ED_SHORTCUT("scene_tree/copy_node_path", TTR("Copy Node Path"), KEY_MASK_CMD|KEY_C);
ED_SHORTCUT("scene_tree/delete_no_confirm", TTR("Delete (No Confirm)"), KEY_MASK_SHIFT|KEY_DELETE);
ED_SHORTCUT("scene_tree/delete", TTR("Delete"), KEY_DELETE);
diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h
index 0699da3474..2ee7ba3d06 100644
--- a/tools/editor/scene_tree_dock.h
+++ b/tools/editor/scene_tree_dock.h
@@ -68,6 +68,7 @@ class SceneTreeDock : public VBoxContainer {
TOOL_MERGE_FROM_SCENE,
TOOL_MULTI_EDIT,
TOOL_ERASE,
+ TOOL_COPY_NODE_PATH,
TOOL_BUTTON_MAX
};