浏览代码

[Audio] Fix pausing stream on entering tree

The paused notifications are only sent when pause status is changed,
this ensures that streams that are non-processing do not play when added
to the tree. Also ensures that the `process_mode` property applies
generally.

(cherry picked from commit 72fccd82c556b6f0d9678fc12eb8c331ff86d9f4)
A Thousand Ships 1 年之前
父节点
当前提交
578fa8603d
共有 3 个文件被更改,包括 3 次插入3 次删除
  1. 1 1
      scene/2d/audio_stream_player_2d.cpp
  2. 1 1
      scene/3d/audio_stream_player_3d.cpp
  3. 1 1
      scene/audio/audio_stream_player.cpp

+ 1 - 1
scene/2d/audio_stream_player_2d.cpp

@@ -43,7 +43,7 @@ void AudioStreamPlayer2D::_notification(int p_what) {
 			if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
 				play();
 			}
-			set_stream_paused(false);
+			set_stream_paused(!can_process());
 		} break;
 
 		case NOTIFICATION_EXIT_TREE: {

+ 1 - 1
scene/3d/audio_stream_player_3d.cpp

@@ -244,7 +244,7 @@ void AudioStreamPlayer3D::_notification(int p_what) {
 			if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
 				play();
 			}
-			set_stream_paused(false);
+			set_stream_paused(!can_process());
 		} break;
 
 		case NOTIFICATION_EXIT_TREE: {

+ 1 - 1
scene/audio/audio_stream_player.cpp

@@ -40,7 +40,7 @@ void AudioStreamPlayer::_notification(int p_what) {
 			if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
 				play();
 			}
-			set_stream_paused(false);
+			set_stream_paused(!can_process());
 		} break;
 
 		case NOTIFICATION_INTERNAL_PROCESS: {