summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/audio_stream_polyphonic.cpp32
-rw-r--r--scene/resources/audio_stream_polyphonic.h5
-rw-r--r--scene/resources/material.cpp2
-rw-r--r--scene/resources/polygon_path_finder.cpp4
4 files changed, 14 insertions, 29 deletions
diff --git a/scene/resources/audio_stream_polyphonic.cpp b/scene/resources/audio_stream_polyphonic.cpp
index 2e56ff3423..f7299b0789 100644
--- a/scene/resources/audio_stream_polyphonic.cpp
+++ b/scene/resources/audio_stream_polyphonic.cpp
@@ -87,7 +87,6 @@ void AudioStreamPlaybackPolyphonic::stop() {
AudioServer::get_singleton()->lock();
}
s.active.clear();
- s.finalizing.clear();
s.finish_request.clear();
s.stream_playback.unref();
s.stream.unref();
@@ -137,7 +136,7 @@ int AudioStreamPlaybackPolyphonic::mix(AudioFrame *p_buffer, float p_rate_scale,
continue;
}
- float volume_db = s.volume_db; // Copy because it can be overriden at any time.
+ float volume_db = s.volume_db; // Copy because it can be overridden at any time.
float next_volume = Math::db_to_linear(volume_db);
s.prev_volume_db = volume_db;
@@ -145,7 +144,6 @@ int AudioStreamPlaybackPolyphonic::mix(AudioFrame *p_buffer, float p_rate_scale,
if (s.pending_play.is_set()) {
// Did not get the chance to play, was finalized too soon.
s.active.clear();
- s.finalizing.set();
continue;
}
next_volume = 0;
@@ -163,6 +161,8 @@ int AudioStreamPlaybackPolyphonic::mix(AudioFrame *p_buffer, float p_rate_scale,
int offset = 0;
float volume = prev_volume;
+ bool stream_done = false;
+
while (todo) {
int to_mix = MIN(todo, int(INTERNAL_BUFFER_LEN));
int mixed = s.stream_playback->mix(internal_buffer, s.pitch_scale, to_mix);
@@ -175,7 +175,7 @@ int AudioStreamPlaybackPolyphonic::mix(AudioFrame *p_buffer, float p_rate_scale,
if (mixed < to_mix) {
// Stream is done.
s.active.clear();
- s.finalizing.set();
+ stream_done = true;
break;
}
@@ -183,34 +183,22 @@ int AudioStreamPlaybackPolyphonic::mix(AudioFrame *p_buffer, float p_rate_scale,
offset += to_mix;
}
+ if (stream_done) {
+ continue;
+ }
+
if (s.finish_request.is_set()) {
s.active.clear();
- s.finalizing.set();
}
}
return p_frames;
}
-void AudioStreamPlaybackPolyphonic::_check_finalized_streams() {
- if (!active) {
- return;
- }
-
- for (Stream &s : streams) {
- if (!s.active.is_set() && s.finalizing.is_set()) {
- s.stream_playback.unref();
- s.stream.unref();
- s.finalizing.clear();
- s.finish_request.clear();
- }
- }
-}
-
AudioStreamPlaybackPolyphonic::ID AudioStreamPlaybackPolyphonic::play_stream(const Ref<AudioStream> &p_stream, float p_from_offset, float p_volume_db, float p_pitch_scale) {
ERR_FAIL_COND_V(p_stream.is_null(), INVALID_ID);
for (uint32_t i = 0; i < streams.size(); i++) {
- if (!streams[i].active.is_set() && !streams[i].finish_request.is_set() && !streams[i].finalizing.is_set()) {
+ if (!streams[i].active.is_set()) {
// Can use this stream, as it's not active.
streams[i].stream = p_stream;
streams[i].stream_playback = streams[i].stream->instantiate_playback();
@@ -219,6 +207,7 @@ AudioStreamPlaybackPolyphonic::ID AudioStreamPlaybackPolyphonic::play_stream(con
streams[i].prev_volume_db = p_volume_db;
streams[i].pitch_scale = p_pitch_scale;
streams[i].id = id_counter++;
+ streams[i].finish_request.clear();
streams[i].pending_play.set();
streams[i].active.set();
return (ID(i) << INDEX_SHIFT) | ID(streams[i].id);
@@ -282,5 +271,4 @@ void AudioStreamPlaybackPolyphonic::_bind_methods() {
}
AudioStreamPlaybackPolyphonic::AudioStreamPlaybackPolyphonic() {
- SceneTree::get_singleton()->connect(SNAME("process_frame"), callable_mp(this, &AudioStreamPlaybackPolyphonic::_check_finalized_streams));
}
diff --git a/scene/resources/audio_stream_polyphonic.h b/scene/resources/audio_stream_polyphonic.h
index b5ccc7eb7f..e414401b6f 100644
--- a/scene/resources/audio_stream_polyphonic.h
+++ b/scene/resources/audio_stream_polyphonic.h
@@ -63,7 +63,6 @@ class AudioStreamPlaybackPolyphonic : public AudioStreamPlayback {
SafeFlag active;
SafeFlag pending_play;
SafeFlag finish_request;
- SafeFlag finalizing;
float play_offset = 0;
float pitch_scale = 1.0;
Ref<AudioStream> stream;
@@ -73,7 +72,7 @@ class AudioStreamPlaybackPolyphonic : public AudioStreamPlayback {
uint32_t id = 0;
Stream() :
- active(false), pending_play(false), finish_request(false), finalizing(false) {}
+ active(false), pending_play(false), finish_request(false) {}
};
LocalVector<Stream> streams;
@@ -84,8 +83,6 @@ class AudioStreamPlaybackPolyphonic : public AudioStreamPlayback {
_FORCE_INLINE_ Stream *_find_stream(int64_t p_id);
- void _check_finalized_streams();
-
friend class AudioStreamPolyphonic;
protected:
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index db7385428b..9c3a2ffb87 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -188,7 +188,7 @@ bool ShaderMaterial::_get(const StringName &p_name, Variant &r_ret) const {
if (shader.is_valid()) {
const StringName *sn = remap_cache.getptr(p_name);
if (sn) {
- // Only return a parameter if it was previosly set.
+ // Only return a parameter if it was previously set.
r_ret = get_shader_parameter(*sn);
return true;
}
diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp
index 85106883f9..3bbd0a0b5e 100644
--- a/scene/resources/polygon_path_finder.cpp
+++ b/scene/resources/polygon_path_finder.cpp
@@ -325,7 +325,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
}
const Point &np = points[least_cost_point];
- //open the neighbours for search
+ //open the neighbors for search
for (const int &E : np.connections) {
Point &p = points.write[E];
@@ -339,7 +339,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
p.distance = distance;
}
} else {
- //add to open neighbours
+ //add to open neighbors
p.prev = least_cost_point;
p.distance = distance;