[3.x] instance audio streams before AudioServer::lock call
(cherry picked from commit 027546ee8a
)
This commit is contained in:
parent
64d3520faf
commit
883c3dc413
@ -271,6 +271,9 @@ void AudioStreamPlayer2D::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) {
|
void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) {
|
||||||
|
// Instancing audio streams can cause large memory allocations, do it prior to AudioServer::lock.
|
||||||
|
Ref<AudioStreamPlayback> pre_instanced_playback = p_stream->instance_playback();
|
||||||
|
|
||||||
AudioServer::get_singleton()->lock();
|
AudioServer::get_singleton()->lock();
|
||||||
|
|
||||||
mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size());
|
mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size());
|
||||||
@ -284,7 +287,7 @@ void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) {
|
|||||||
|
|
||||||
if (p_stream.is_valid()) {
|
if (p_stream.is_valid()) {
|
||||||
stream = p_stream;
|
stream = p_stream;
|
||||||
stream_playback = p_stream->instance_playback();
|
stream_playback = pre_instanced_playback;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioServer::get_singleton()->unlock();
|
AudioServer::get_singleton()->unlock();
|
||||||
|
@ -622,6 +622,9 @@ void AudioStreamPlayer3D::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlayer3D::set_stream(Ref<AudioStream> p_stream) {
|
void AudioStreamPlayer3D::set_stream(Ref<AudioStream> p_stream) {
|
||||||
|
// Instancing audio streams can cause large memory allocations, do it prior to AudioServer::lock.
|
||||||
|
Ref<AudioStreamPlayback> pre_instanced_playback = p_stream->instance_playback();
|
||||||
|
|
||||||
AudioServer::get_singleton()->lock();
|
AudioServer::get_singleton()->lock();
|
||||||
|
|
||||||
mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size());
|
mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size());
|
||||||
@ -635,7 +638,7 @@ void AudioStreamPlayer3D::set_stream(Ref<AudioStream> p_stream) {
|
|||||||
|
|
||||||
if (p_stream.is_valid()) {
|
if (p_stream.is_valid()) {
|
||||||
stream = p_stream;
|
stream = p_stream;
|
||||||
stream_playback = p_stream->instance_playback();
|
stream_playback = pre_instanced_playback;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioServer::get_singleton()->unlock();
|
AudioServer::get_singleton()->unlock();
|
||||||
|
@ -167,6 +167,9 @@ void AudioStreamPlayer::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) {
|
void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) {
|
||||||
|
// Instancing audio streams can cause large memory allocations, do it prior to AudioServer::lock.
|
||||||
|
Ref<AudioStreamPlayback> pre_instanced_playback = p_stream->instance_playback();
|
||||||
|
|
||||||
AudioServer::get_singleton()->lock();
|
AudioServer::get_singleton()->lock();
|
||||||
|
|
||||||
if (active.is_set() && stream_playback.is_valid() && !stream_paused) {
|
if (active.is_set() && stream_playback.is_valid() && !stream_paused) {
|
||||||
@ -203,7 +206,7 @@ void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) {
|
|||||||
|
|
||||||
if (p_stream.is_valid()) {
|
if (p_stream.is_valid()) {
|
||||||
stream = p_stream;
|
stream = p_stream;
|
||||||
stream_playback = p_stream->instance_playback();
|
stream_playback = pre_instanced_playback;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioServer::get_singleton()->unlock();
|
AudioServer::get_singleton()->unlock();
|
||||||
|
Loading…
Reference in New Issue
Block a user