You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Merge pull request #19646 from chanon/fix-audiostream-cant-set-null-stream
Fix can't set AudioStreamPlayer stream to null
This commit is contained in:
@@ -259,7 +259,6 @@ void AudioStreamPlayer2D::_notification(int p_what) {
|
|||||||
|
|
||||||
void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) {
|
void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) {
|
||||||
|
|
||||||
ERR_FAIL_COND(!p_stream.is_valid());
|
|
||||||
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());
|
||||||
@@ -271,14 +270,15 @@ void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) {
|
|||||||
setseek = -1;
|
setseek = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream = p_stream;
|
if (p_stream.is_valid()) {
|
||||||
stream_playback = p_stream->instance_playback();
|
stream = p_stream;
|
||||||
|
stream_playback = p_stream->instance_playback();
|
||||||
|
}
|
||||||
|
|
||||||
AudioServer::get_singleton()->unlock();
|
AudioServer::get_singleton()->unlock();
|
||||||
|
|
||||||
if (stream_playback.is_null()) {
|
if (p_stream.is_valid() && stream_playback.is_null()) {
|
||||||
stream.unref();
|
stream.unref();
|
||||||
ERR_FAIL_COND(stream_playback.is_null());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -569,7 +569,6 @@ void AudioStreamPlayer3D::_notification(int p_what) {
|
|||||||
|
|
||||||
void AudioStreamPlayer3D::set_stream(Ref<AudioStream> p_stream) {
|
void AudioStreamPlayer3D::set_stream(Ref<AudioStream> p_stream) {
|
||||||
|
|
||||||
ERR_FAIL_COND(!p_stream.is_valid());
|
|
||||||
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());
|
||||||
@@ -581,14 +580,15 @@ void AudioStreamPlayer3D::set_stream(Ref<AudioStream> p_stream) {
|
|||||||
setseek = -1;
|
setseek = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream = p_stream;
|
if (p_stream.is_valid()) {
|
||||||
stream_playback = p_stream->instance_playback();
|
stream = p_stream;
|
||||||
|
stream_playback = p_stream->instance_playback();
|
||||||
|
}
|
||||||
|
|
||||||
AudioServer::get_singleton()->unlock();
|
AudioServer::get_singleton()->unlock();
|
||||||
|
|
||||||
if (stream_playback.is_null()) {
|
if (p_stream.is_valid() && stream_playback.is_null()) {
|
||||||
stream.unref();
|
stream.unref();
|
||||||
ERR_FAIL_COND(stream_playback.is_null());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -176,7 +176,6 @@ void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) {
|
|||||||
|
|
||||||
if (p_stream.is_valid() && stream_playback.is_null()) {
|
if (p_stream.is_valid() && stream_playback.is_null()) {
|
||||||
stream.unref();
|
stream.unref();
|
||||||
ERR_FAIL_COND(stream_playback.is_null());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user