|
@@ -38,7 +38,7 @@
|
|
|
void AudioStreamPlayer3D::_mix_audio() {
|
|
|
|
|
|
if (!stream_playback.is_valid() || !active ||
|
|
|
- (stream_paused && !stream_paused_fade_out)) {
|
|
|
+ (stream_paused && !stream_fade_out)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -53,7 +53,7 @@ void AudioStreamPlayer3D::_mix_audio() {
|
|
|
AudioFrame *buffer = mix_buffer.ptrw();
|
|
|
int buffer_size = mix_buffer.size();
|
|
|
|
|
|
- if (stream_paused_fade_out) {
|
|
|
+ if (stream_fade_out) {
|
|
|
// Short fadeout ramp
|
|
|
buffer_size = MIN(buffer_size, 128);
|
|
|
}
|
|
@@ -109,10 +109,10 @@ void AudioStreamPlayer3D::_mix_audio() {
|
|
|
int buffers = AudioServer::get_singleton()->get_channel_count();
|
|
|
|
|
|
for (int k = 0; k < buffers; k++) {
|
|
|
- AudioFrame target_volume = stream_paused_fade_out ? AudioFrame(0.f, 0.f) : current.vol[k];
|
|
|
- AudioFrame vol_prev = stream_paused_fade_in ? AudioFrame(0.f, 0.f) : prev_outputs[i].vol[k];
|
|
|
+ AudioFrame target_volume = stream_fade_out ? AudioFrame(0.f, 0.f) : current.vol[k];
|
|
|
+ AudioFrame vol_prev = stream_fade_in ? AudioFrame(0.f, 0.f) : prev_outputs[i].vol[k];
|
|
|
AudioFrame vol_inc = (target_volume - vol_prev) / float(buffer_size);
|
|
|
- AudioFrame vol = stream_paused_fade_in ? AudioFrame(0.f, 0.f) : current.vol[k];
|
|
|
+ AudioFrame vol = stream_fade_in ? AudioFrame(0.f, 0.f) : current.vol[k];
|
|
|
|
|
|
if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.bus_index, k))
|
|
|
continue; //may have been deleted, will be updated on process
|
|
@@ -198,9 +198,15 @@ void AudioStreamPlayer3D::_mix_audio() {
|
|
|
active = false;
|
|
|
}
|
|
|
|
|
|
+ if (stream_stop) {
|
|
|
+ active = false;
|
|
|
+ set_physics_process_internal(false);
|
|
|
+ setplay = -1;
|
|
|
+ }
|
|
|
+
|
|
|
output_ready = false;
|
|
|
- stream_paused_fade_in = false;
|
|
|
- stream_paused_fade_out = false;
|
|
|
+ stream_fade_in = false;
|
|
|
+ stream_fade_out = false;
|
|
|
}
|
|
|
|
|
|
float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const {
|
|
@@ -656,6 +662,7 @@ float AudioStreamPlayer3D::get_pitch_scale() const {
|
|
|
void AudioStreamPlayer3D::play(float p_from_pos) {
|
|
|
|
|
|
if (stream_playback.is_valid()) {
|
|
|
+ stream_stop = false;
|
|
|
active = true;
|
|
|
setplay = p_from_pos;
|
|
|
output_ready = false;
|
|
@@ -673,9 +680,8 @@ void AudioStreamPlayer3D::seek(float p_seconds) {
|
|
|
void AudioStreamPlayer3D::stop() {
|
|
|
|
|
|
if (stream_playback.is_valid()) {
|
|
|
- active = false;
|
|
|
- set_physics_process_internal(false);
|
|
|
- setplay = -1;
|
|
|
+ stream_stop = true;
|
|
|
+ stream_fade_out = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -869,8 +875,8 @@ void AudioStreamPlayer3D::set_stream_paused(bool p_pause) {
|
|
|
|
|
|
if (p_pause != stream_paused) {
|
|
|
stream_paused = p_pause;
|
|
|
- stream_paused_fade_in = stream_paused ? false : true;
|
|
|
- stream_paused_fade_out = stream_paused ? true : false;
|
|
|
+ stream_fade_in = stream_paused ? false : true;
|
|
|
+ stream_fade_out = stream_paused ? true : false;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1008,8 +1014,9 @@ AudioStreamPlayer3D::AudioStreamPlayer3D() {
|
|
|
out_of_range_mode = OUT_OF_RANGE_MIX;
|
|
|
doppler_tracking = DOPPLER_TRACKING_DISABLED;
|
|
|
stream_paused = false;
|
|
|
- stream_paused_fade_in = false;
|
|
|
- stream_paused_fade_out = false;
|
|
|
+ stream_fade_in = false;
|
|
|
+ stream_fade_out = false;
|
|
|
+ stream_stop = false;
|
|
|
|
|
|
velocity_tracker.instance();
|
|
|
AudioServer::get_singleton()->connect("bus_layout_changed", this, "_bus_layout_changed");
|