Merge pull request #39934 from starryalley/fix-videoplayer-race

VideoPlayer: fix possible race condition
This commit is contained in:
Rémi Verschelde 2020-06-29 14:52:58 +02:00 committed by GitHub
commit 4599381fad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -201,10 +201,9 @@ bool VideoPlayer::has_expand() const {
void VideoPlayer::set_stream(const Ref<VideoStream> &p_stream) {
stop();
AudioServer::get_singleton()->lock();
mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size());
AudioServer::get_singleton()->unlock();
stream = p_stream;
if (stream.is_valid()) {
stream->set_audio_track(audio_track);
@ -212,6 +211,7 @@ void VideoPlayer::set_stream(const Ref<VideoStream> &p_stream) {
} else {
playback = Ref<VideoStreamPlayback>();
}
AudioServer::get_singleton()->unlock();
if (!playback.is_null()) {
playback->set_loop(loops);