From b343660dac50c753d227d296358fe1aa40da9c90 Mon Sep 17 00:00:00 2001 From: BimDav <67792882+BimDav@users.noreply.github.com> Date: Fri, 11 Feb 2022 14:35:30 +0100 Subject: [PATCH 01/11] has_setting now correctly returns true when the setting is present due to a feature tag (cherry picked from commit d39e416c61570addba7bd617f9208dc81f9031fb) --- core/project_settings.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/project_settings.cpp b/core/project_settings.cpp index f4a15d73a10..1b2cf65dbcf 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -531,7 +531,11 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bo bool ProjectSettings::has_setting(String p_var) const { _THREAD_SAFE_METHOD_ - return props.has(p_var); + StringName name = p_var; + if (!disable_feature_overrides && feature_overrides.has(name)) { + name = feature_overrides[name]; + } + return props.has(name); } void ProjectSettings::set_registering_order(bool p_enable) { From cb885e97c5f6fe7305a451eb0c1c96ed0702c19a Mon Sep 17 00:00:00 2001 From: Jean-Michel Bernard Date: Fri, 11 Feb 2022 18:44:17 +0100 Subject: [PATCH 02/11] Hide CollisionShape2D handles when node is not visible in tree. (cherry picked from commit ef995b222eaa491d0bcca92afb85b2bed38b11ae) --- editor/plugins/collision_shape_2d_editor_plugin.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index 3b8b94d7a47..8ffe764648b 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -326,6 +326,10 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref &p_e return false; } + if (!node->is_visible_in_tree()) { + return false; + } + if (shape_type == -1) { return false; } @@ -448,6 +452,10 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla return; } + if (!node->is_visible_in_tree()) { + return; + } + _get_current_shape_type(); if (shape_type == -1) { From 9b7147157d707039bedead35753961bc17694d27 Mon Sep 17 00:00:00 2001 From: Jean-Michel Bernard Date: Fri, 11 Feb 2022 20:10:57 +0100 Subject: [PATCH 03/11] Hide Polygon2D lines and handles when node is not visible in tree. (cherry picked from commit b0ebbd8ecebac52836fa9ecfc27635f5d12268f2) --- editor/plugins/abstract_polygon_2d_editor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 38d600ebf07..16539e7450d 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -273,6 +273,10 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref &p_event) return false; } + if (!_get_node()->is_visible_in_tree()) { + return false; + } + Ref mb = p_event; if (!_has_resource()) { @@ -506,6 +510,10 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl return; } + if (!_get_node()->is_visible_in_tree()) { + return; + } + Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform(); // All polygon points are sharp, so use the sharp handle icon const Ref handle = get_icon("EditorPathSharpHandle", "EditorIcons"); From d0fba915dc8af4273cf60240981fd6e252290803 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 19 Jan 2022 17:13:23 +0100 Subject: [PATCH 04/11] Allow using the web editor on any device orientation On tablets and foldable phones, the editor can remain usable while in portrait mode thanks to the wide display. (cherry picked from commit 078475f3545a302bee33440f2f154098f71e77ab) --- misc/dist/html/manifest.json | 1 - 1 file changed, 1 deletion(-) diff --git a/misc/dist/html/manifest.json b/misc/dist/html/manifest.json index adc8106e2ae..ccfb793b20a 100644 --- a/misc/dist/html/manifest.json +++ b/misc/dist/html/manifest.json @@ -5,7 +5,6 @@ "lang": "en", "start_url": "./godot.tools.html", "display": "standalone", - "orientation": "landscape", "theme_color": "#202531", "icons": [ { From 695da68188c3d091c32f9f319528f393cef5f608 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 20 Jan 2022 17:03:43 +0100 Subject: [PATCH 05/11] Tweak logo max width on the web editor The logo's maximum width is now dependent on the viewport height in addition to the page width. This prevents the "Start Godot editor" button from overflowing the page on mobile devices (although the "Clear persistent data" and "Web editor documentation" buttons will still overflow for now). (cherry picked from commit 34a4ff0cefedddc5ec6ddcd7ea80ce98fcf4177b) --- misc/dist/html/editor.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/dist/html/editor.html b/misc/dist/html/editor.html index fcd3277aaaa..bba8763efd3 100644 --- a/misc/dist/html/editor.html +++ b/misc/dist/html/editor.html @@ -271,7 +271,7 @@

- Godot Engine logo + Godot Engine logo
@GODOT_VERSION@
From 48f32374776a9b17b71f1667dc43e070d0c4ea6a Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Sat, 12 Feb 2022 10:25:53 +0200 Subject: [PATCH 06/11] [macOS] Add missing translation file. (cherry picked from commit 1aa6a95081cc931d6fbe5c46281630208204c10b) --- .../osx_tools.app/Contents/Resources/en.lproj/InfoPlist.strings | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 misc/dist/osx_tools.app/Contents/Resources/en.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/en.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/en.lproj/InfoPlist.strings new file mode 100644 index 00000000000..e69de29bb2d From 5ca3a360d1a8ac657f9d8bd99c48d66e64e2bdb1 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sat, 12 Feb 2022 22:17:35 +0100 Subject: [PATCH 07/11] Clarify identical `hash()` return values due to collisions (cherry picked from commit 08541fe11d1e3945549f33a013b3d655413dcfa6) --- doc/classes/Array.xml | 4 ++-- doc/classes/Dictionary.xml | 3 ++- doc/classes/String.xml | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index 92c320e0a18..6839f1d8328 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -221,8 +221,8 @@ - Returns a hashed integer value representing the array and its contents. - [b]Note:[/b] Arrays with equal contents can still produce different hashes. Only the exact same arrays will produce the same hashed integer value. + Returns a hashed 32-bit integer value representing the array and its contents. + [b]Note:[/b] [Array]s with equal content will always produce identical hash values. However, the reverse is not true. Returning identical hash values does [i]not[/i] imply the arrays are equal, because different arrays can have identical hash values due to hash collisions. diff --git a/doc/classes/Dictionary.xml b/doc/classes/Dictionary.xml index 6742bd2723b..b197e7c460f 100644 --- a/doc/classes/Dictionary.xml +++ b/doc/classes/Dictionary.xml @@ -147,7 +147,7 @@ - Returns a hashed integer value representing the dictionary contents. This can be used to compare dictionaries by value: + Returns a hashed 32-bit integer value representing the dictionary contents. This can be used to compare dictionaries by value: [codeblock] var dict1 = {0: 10} var dict2 = {0: 10} @@ -155,6 +155,7 @@ print(dict1.hash() == dict2.hash()) [/codeblock] [b]Note:[/b] Dictionaries with the same keys/values but in a different order will have a different hash. + [b]Note:[/b] Dictionaries with equal content will always produce identical hash values. However, the reverse is not true. Returning identical hash values does [i]not[/i] imply the dictionaries are equal, because different dictionaries can have identical hash values due to hash collisions. diff --git a/doc/classes/String.xml b/doc/classes/String.xml index d3c3e0ad635..1e2dfacd4aa 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -351,7 +351,8 @@ - Hashes the string and returns a 32-bit integer. + Returns the 32-bit hash value representing the string's contents. + [b]Note:[/b] [String]s with equal content will always produce identical hash values. However, the reverse is not true. Returning identical hash values does [i]not[/i] imply the strings are equal, because different strings can have identical hash values due to hash collisions. From 6471d0a57ac36de62a798658b804efa4c5407b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20T=2E=20Listwon?= Date: Fri, 11 Feb 2022 20:21:26 +0100 Subject: [PATCH 08/11] Pass audio samples untouched for pitch_scale around 1.0f (cherry picked from commit c02e979dbf6587e847b401b1b19702e2bc937d5a) --- servers/audio/effects/audio_effect_pitch_shift.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp index 8ce8f58f75d..fdac74ccd32 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.cpp +++ b/servers/audio/effects/audio_effect_pitch_shift.cpp @@ -292,6 +292,14 @@ void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign) void AudioEffectPitchShiftInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { float sample_rate = AudioServer::get_singleton()->get_mix_rate(); + // For pitch_scale 1.0 it's cheaper to just pass samples without processing them. + if (Math::is_equal_approx(base->pitch_scale, 1.0f)) { + for (int i = 0; i < p_frame_count; i++) { + p_dst_frames[i] = p_src_frames[i]; + } + return; + } + float *in_l = (float *)p_src_frames; float *in_r = in_l + 1; From 51d028fce093e40104302f5f30a0a2435951d3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20T=2E=20Listwon?= Date: Fri, 11 Feb 2022 20:15:32 +0100 Subject: [PATCH 09/11] Audio quality improvements in PitchShift (cherry picked from commit 29b6ed92837d80181259f5392e07747f01661a06) --- .../effects/audio_effect_pitch_shift.cpp | 86 +++++++++++-------- .../audio/effects/audio_effect_pitch_shift.h | 39 ++++----- 2 files changed, 71 insertions(+), 54 deletions(-) diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp index fdac74ccd32..6e9f92c5513 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.cpp +++ b/servers/audio/effects/audio_effect_pitch_shift.cpp @@ -74,7 +74,7 @@ * *****************************************************************************/ -void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long fftFrameSize, long osamp, float sampleRate, float *indata, float *outdata,int stride) { +void SMBPitchShift::PitchShift(float pitchShift, int64_t numSampsToProcess, int64_t fftFrameSize, int64_t osamp, float sampleRate, float *indata, float *outdata,int stride) { /* @@ -85,19 +85,32 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff */ double magn, phase, tmp, window, real, imag; - double freqPerBin, expct; - long i,k, qpd, index, inFifoLatency, stepSize, fftFrameSize2; + double freqPerBin, expct, reciprocalFftFrameSize; + int64_t i,k, qpd, index, inFifoLatency, stepSize, fftFrameSize2; /* set up some handy variables */ fftFrameSize2 = fftFrameSize/2; + reciprocalFftFrameSize = 1./fftFrameSize; stepSize = fftFrameSize/osamp; - freqPerBin = sampleRate/(double)fftFrameSize; - expct = 2.*Math_PI*(double)stepSize/(double)fftFrameSize; + freqPerBin = reciprocalFftFrameSize * sampleRate; + expct = Math_TAU * reciprocalFftFrameSize * stepSize; inFifoLatency = fftFrameSize-stepSize; - if (gRover == 0) { gRover = inFifoLatency; -} + if (gRover == 0) { + gRover = inFifoLatency; + } - /* initialize our static arrays */ + // If pitchShift changes clear arrays to prevent some artifacts and quality loss. + if (lastPitchShift != pitchShift) { + lastPitchShift = pitchShift; + memset(gInFIFO, 0, MAX_FRAME_LENGTH * sizeof(float)); + memset(gOutFIFO, 0, MAX_FRAME_LENGTH * sizeof(float)); + memset(gFFTworksp, 0, 2 * MAX_FRAME_LENGTH * sizeof(double)); + memset(gLastPhase, 0, (MAX_FRAME_LENGTH / 2 + 1) * sizeof(double)); + memset(gSumPhase, 0, (MAX_FRAME_LENGTH / 2 + 1) * sizeof(double)); + memset(gOutputAccum, 0, 2 * MAX_FRAME_LENGTH * sizeof(double)); + memset(gAnaFreq, 0, MAX_FRAME_LENGTH * sizeof(double)); + memset(gAnaMagn, 0, MAX_FRAME_LENGTH * sizeof(double)); + } /* main processing loop */ for (i = 0; i < numSampsToProcess; i++){ @@ -113,7 +126,7 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff /* do windowing and re,im interleave */ for (k = 0; k < fftFrameSize;k++) { - window = -.5*cos(2.*Math_PI*(double)k/(double)fftFrameSize)+.5; + window = -.5*cos(Math_TAU * reciprocalFftFrameSize * k)+.5; gFFTworksp[2*k] = gInFIFO[k] * window; gFFTworksp[2*k+1] = 0.; } @@ -143,13 +156,15 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff /* map delta phase into +/- Pi interval */ qpd = tmp/Math_PI; - if (qpd >= 0) { qpd += qpd&1; - } else { qpd -= qpd&1; -} + if (qpd >= 0) { + qpd += qpd&1; + } else { + qpd -= qpd&1; + } tmp -= Math_PI*(double)qpd; /* get deviation from bin frequency from the +/- Pi interval */ - tmp = osamp*tmp/(2.*Math_PI); + tmp = osamp*tmp/Math_TAU; /* compute the k-th partials' true frequency */ tmp = (double)k*freqPerBin + tmp*freqPerBin; @@ -162,8 +177,8 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff /* ***************** PROCESSING ******************* */ /* this does the actual pitch shifting */ - memset(gSynMagn, 0, fftFrameSize*sizeof(float)); - memset(gSynFreq, 0, fftFrameSize*sizeof(float)); + memset(gSynMagn, 0, fftFrameSize*sizeof(double)); + memset(gSynFreq, 0, fftFrameSize*sizeof(double)); for (k = 0; k <= fftFrameSize2; k++) { index = k*pitchShift; if (index <= fftFrameSize2) { @@ -187,7 +202,7 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff tmp /= freqPerBin; /* take osamp into account */ - tmp = 2.*Math_PI*tmp/osamp; + tmp = Math_TAU*tmp/osamp; /* add the overlap phase advance back in */ tmp += (double)k*expct; @@ -202,35 +217,35 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff } /* zero negative frequencies */ - for (k = fftFrameSize+2; k < 2*fftFrameSize; k++) { gFFTworksp[k] = 0.; -} + for (k = fftFrameSize+2; k < 2*MAX_FRAME_LENGTH; k++) { + gFFTworksp[k] = 0.; + } /* do inverse transform */ smbFft(gFFTworksp, fftFrameSize, 1); /* do windowing and add to output accumulator */ for(k=0; k < fftFrameSize; k++) { - window = -.5*cos(2.*Math_PI*(double)k/(double)fftFrameSize)+.5; + window = -.5*cos(Math_TAU * reciprocalFftFrameSize * k)+.5; gOutputAccum[k] += 2.*window*gFFTworksp[2*k]/(fftFrameSize2*osamp); } - for (k = 0; k < stepSize; k++) { gOutFIFO[k] = gOutputAccum[k]; -} + for (k = 0; k < stepSize; k++) { + gOutFIFO[k] = gOutputAccum[k]; + } /* shift accumulator */ - memmove(gOutputAccum, gOutputAccum+stepSize, fftFrameSize*sizeof(float)); + memmove(gOutputAccum, gOutputAccum+stepSize, fftFrameSize*sizeof(double)); /* move input FIFO */ - for (k = 0; k < inFifoLatency; k++) { gInFIFO[k] = gInFIFO[k+stepSize]; -} + for (k = 0; k < inFifoLatency; k++) { + gInFIFO[k] = gInFIFO[k+stepSize]; + } } } - - - } -void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign) +void SMBPitchShift::smbFft(double *fftBuffer, int64_t fftFrameSize, int64_t sign) /* FFT routine, (C)1996 S.M.Bernsee. Sign = -1 is FFT, 1 is iFFT (inverse) Fills fftBuffer[0...2*fftFrameSize-1] with the Fourier transform of the @@ -243,14 +258,16 @@ void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign) of the frequencies of interest is in fftBuffer[0...fftFrameSize]. */ { - float wr, wi, arg, *p1, *p2, temp; - float tr, ti, ur, ui, *p1r, *p1i, *p2r, *p2i; - long i, bitm, j, le, le2, k; + double wr, wi, arg, *p1, *p2, temp; + double tr, ti, ur, ui, *p1r, *p1i, *p2r, *p2i; + int64_t i, bitm, j, le, le2, k, logN; + logN = (int64_t)(log(fftFrameSize) / log(2.) + .5); for (i = 2; i < 2*fftFrameSize-2; i += 2) { for (bitm = 2, j = 0; bitm < 2*fftFrameSize; bitm <<= 1) { - if (i & bitm) { j++; -} + if (i & bitm) { + j++; + } j <<= 1; } if (i < j) { @@ -260,7 +277,8 @@ void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign) *p1 = *p2; *p2 = temp; } } - for (k = 0, le = 2; k < (long)(log((double)fftFrameSize)/log(2.)+.5); k++) { + + for (k = 0, le = 2; k < logN; k++) { le <<= 1; le2 = le>>1; ur = 1.0; diff --git a/servers/audio/effects/audio_effect_pitch_shift.h b/servers/audio/effects/audio_effect_pitch_shift.h index 6559752e8a7..97207a30fe0 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.h +++ b/servers/audio/effects/audio_effect_pitch_shift.h @@ -40,31 +40,33 @@ class SMBPitchShift { float gInFIFO[MAX_FRAME_LENGTH]; float gOutFIFO[MAX_FRAME_LENGTH]; - float gFFTworksp[2 * MAX_FRAME_LENGTH]; - float gLastPhase[MAX_FRAME_LENGTH / 2 + 1]; - float gSumPhase[MAX_FRAME_LENGTH / 2 + 1]; - float gOutputAccum[2 * MAX_FRAME_LENGTH]; - float gAnaFreq[MAX_FRAME_LENGTH]; - float gAnaMagn[MAX_FRAME_LENGTH]; - float gSynFreq[MAX_FRAME_LENGTH]; - float gSynMagn[MAX_FRAME_LENGTH]; - long gRover; + double gFFTworksp[2 * MAX_FRAME_LENGTH]; + double gLastPhase[MAX_FRAME_LENGTH / 2 + 1]; + double gSumPhase[MAX_FRAME_LENGTH / 2 + 1]; + double gOutputAccum[2 * MAX_FRAME_LENGTH]; + double gAnaFreq[MAX_FRAME_LENGTH]; + double gAnaMagn[MAX_FRAME_LENGTH]; + double gSynFreq[MAX_FRAME_LENGTH]; + double gSynMagn[MAX_FRAME_LENGTH]; + int64_t gRover; + float lastPitchShift; - void smbFft(float *fftBuffer, long fftFrameSize, long sign); + void smbFft(double *fftBuffer, int64_t fftFrameSize, int64_t sign); public: - void PitchShift(float pitchShift, long numSampsToProcess, long fftFrameSize, long osamp, float sampleRate, float *indata, float *outdata, int stride); + void PitchShift(float pitchShift, int64_t numSampsToProcess, int64_t fftFrameSize, int64_t osamp, float sampleRate, float *indata, float *outdata, int stride); SMBPitchShift() { gRover = 0; memset(gInFIFO, 0, MAX_FRAME_LENGTH * sizeof(float)); memset(gOutFIFO, 0, MAX_FRAME_LENGTH * sizeof(float)); - memset(gFFTworksp, 0, 2 * MAX_FRAME_LENGTH * sizeof(float)); - memset(gLastPhase, 0, (MAX_FRAME_LENGTH / 2 + 1) * sizeof(float)); - memset(gSumPhase, 0, (MAX_FRAME_LENGTH / 2 + 1) * sizeof(float)); - memset(gOutputAccum, 0, 2 * MAX_FRAME_LENGTH * sizeof(float)); - memset(gAnaFreq, 0, MAX_FRAME_LENGTH * sizeof(float)); - memset(gAnaMagn, 0, MAX_FRAME_LENGTH * sizeof(float)); + memset(gFFTworksp, 0, 2 * MAX_FRAME_LENGTH * sizeof(double)); + memset(gLastPhase, 0, (MAX_FRAME_LENGTH / 2 + 1) * sizeof(double)); + memset(gSumPhase, 0, (MAX_FRAME_LENGTH / 2 + 1) * sizeof(double)); + memset(gOutputAccum, 0, 2 * MAX_FRAME_LENGTH * sizeof(double)); + memset(gAnaFreq, 0, MAX_FRAME_LENGTH * sizeof(double)); + memset(gAnaMagn, 0, MAX_FRAME_LENGTH * sizeof(double)); + lastPitchShift = 1.0; } }; @@ -101,9 +103,6 @@ public: float pitch_scale; int oversampling; FFT_Size fft_size; - float wet; - float dry; - bool filter; protected: static void _bind_methods(); From 273abf522580314cf29c42622a7c83f7317945a4 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 14 Feb 2022 23:04:05 +0300 Subject: [PATCH 10/11] Fixed variant decoding Segmentation Fault (cherry picked from commit 6aede992a9db749d6e420b645416d9a6f5fe356b) --- core/io/marshalls.cpp | 11 ++++++----- core/io/marshalls.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 48658e7e9bc..0a2be1fcb8d 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -99,7 +99,8 @@ static Error _decode_string(const uint8_t *&buf, int &len, int *r_len, String &r return OK; } -Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len, bool p_allow_objects) { +Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len, bool p_allow_objects, int p_depth) { + ERR_FAIL_COND_V_MSG(p_depth > Variant::MAX_RECURSION_DEPTH, ERR_OUT_OF_MEMORY, "Variant is too deep. Bailing."); const uint8_t *buf = p_buffer; int len = p_len; @@ -430,7 +431,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int Variant value; int used; - err = decode_variant(value, buf, len, &used, p_allow_objects); + err = decode_variant(value, buf, len, &used, p_allow_objects, p_depth + 1); if (err) { return err; } @@ -473,7 +474,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int Variant key, value; int used; - Error err = decode_variant(key, buf, len, &used, p_allow_objects); + Error err = decode_variant(key, buf, len, &used, p_allow_objects, p_depth + 1); ERR_FAIL_COND_V_MSG(err != OK, err, "Error when trying to decode Variant."); buf += used; @@ -482,7 +483,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int (*r_len) += used; } - err = decode_variant(value, buf, len, &used, p_allow_objects); + err = decode_variant(value, buf, len, &used, p_allow_objects, p_depth + 1); ERR_FAIL_COND_V_MSG(err != OK, err, "Error when trying to decode Variant."); buf += used; @@ -515,7 +516,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int for (int i = 0; i < count; i++) { int used = 0; Variant v; - Error err = decode_variant(v, buf, len, &used, p_allow_objects); + Error err = decode_variant(v, buf, len, &used, p_allow_objects, p_depth + 1); ERR_FAIL_COND_V_MSG(err != OK, err, "Error when trying to decode Variant."); buf += used; len -= used; diff --git a/core/io/marshalls.h b/core/io/marshalls.h index 65096214e98..951af9881f6 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -180,7 +180,7 @@ public: EncodedObjectAsID(); }; -Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = nullptr, bool p_allow_objects = false); +Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = nullptr, bool p_allow_objects = false, int p_depth = 0); Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects = false, int p_depth = 0); #endif From 7dcb25e37b3187b06781977212f3443707bc5307 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Mon, 14 Feb 2022 18:03:34 +0100 Subject: [PATCH 11/11] Improve documentation for AudioServer device properties and methods (cherry picked from commit 743b5608e3f194233b74047e1da2c228f5a8172c) --- doc/classes/AudioServer.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/classes/AudioServer.xml b/doc/classes/AudioServer.xml index d07be409a09..d56534ab626 100644 --- a/doc/classes/AudioServer.xml +++ b/doc/classes/AudioServer.xml @@ -32,7 +32,7 @@ - Name of the current device for audio input (see [method capture_get_device_list]). + Name of the current device for audio input (see [method capture_get_device_list]). The value [code]"Default"[/code] means that the system-wide default audio input is currently used. @@ -45,7 +45,7 @@ - Sets which audio input device is used for audio capture. + Sets which audio input device is used for audio capture. On systems with multiple audio inputs (such as analog and USB), this can be used to select the audio input device. Setting the value [code]"Default"[/code] will record audio from the system-wide default audio input. If an invalid device name is set, the value will be reverted back to [code]"Default"[/code]. @@ -309,7 +309,7 @@ Number of available audio buses. - Name of the current device for audio output (see [method get_device_list]). + Name of the current device for audio output (see [method get_device_list]). On systems with multiple audio outputs (such as analog, USB and HDMI audio), this can be used to select the audio output device. The value [code]"Default"[/code] will play audio on the system-wide default audio output. If an invalid device name is set, the value will be reverted back to [code]"Default"[/code]. Scales the rate at which audio is played (i.e. setting it to [code]0.5[/code] will make the audio be played twice as fast).