Repository: godotengine/godot (language: cpp)

Issue:
Regression: Playing an Audio Stream animation backwards breaks the AudioStreamPlayer forever.
### Tested versions

- Reproducible in: 4.4dev7
- Not reproducible in: 4.3stable

### System information

Windows 11 - Vulkan 1.3.280 - Forward+ - Using Device #0: NVIDIA - NVIDIA GeForce RTX 3070 Ti

### Issue description

Playing an animation with an audio clip in it, when the clip exceeds the length of the animation, when the animation is played backwards it:

1) Does not start in the middle of the clip and
2) Breaks the AudioStreamPlayer until restart

### Steps to reproduce

1. Load the attached project.
2. Select the AnimationPlayer node in the main scene
3. Select the works track
4. Play the track backwards, it works as expected
5. Select the breaks track
6. Play that track backwards
7. Trying playing the track again, no audio plays
8. The AudoStreamPlayer can no longer play any audio

### Minimal reproduction project (MRP)

[anim-audio-mrp.zip](https://github.com/user-attachments/files/18250722/anim-audio-mrp.zip)

AudioServer crashes when playing sounds through an AnimationPlayer
### Tested versions

- Tested from Godot v4.4.dev4+
- Apparently not reproducible in Godot v4.4.dev3

### System information

Godot v4.4.dev6 - Windows 10.0.22621 - Multi-window, 3 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3050 (NVIDIA; 32.0.15.6081) - AMD Ryzen 5 4500 6-Core Processor (12 threads)

### Issue description

The AudioServer(? - unsure because no error occurs) crashes when attempting to mass play audio-streams though an AnimationPlayer.

Afterwards no sound is ever played until restarting the game.

EDIT: Here is a video showing the issue:
https://github.com/user-attachments/assets/f1291d12-9c0c-4bc2-9c0b-87b1881b3ba0


### Steps to reproduce

- Add an AudioStreamPlayer(2D/3D).
- Add an AnimationPlayer with a new animation.
- Set the length to a very small value (eg. 0.075).
- Add an AudioPlaybackTrack with any audio stream.
- Mass play the animation over and over until the AudioDriver(?) crashes.

MRP tested without code but with signals.

### Minimal reproduction project (MRP)

[audio-issue-test.zip](https://github.com/user-attachments/files/18052145/audio-issue-test.zip)

Mash the 'Play' button and at some point the AudioDriver(?) should crash.


Discussion / hints:
The mrp crash in 4.4 dev 4 but works in 4.4 dev 3 and after the problem starts, attempt to close the editor freeze everything and needs to be closed using the task manager. This looks like the same problem from #100173, a regression from #97625.
I can't reproduce this crash using the MRP. I'm on Linux though.
I was able to reproduce the issue and bisected to #97625, @SourceOfHTML

![Image](https://github.com/user-attachments/assets/25ee6660-230b-463f-9491-a50594c70548)

<br>

A detail is if you try to close the game after the bug started, the entire game will freeze and become unresponsive, only being able to  be closed by the task manager.

I did a small modification in the original mrp to make easier to debugger that, i used the `_physics_process` callback to call the animations in a way that make the bug happen in 1~2 seconds. I also added a code to kill the game process when press the Enter key to not need to open the task manager to do it (but needs to be pressed before attempt to close normally, otherwise everything will freeze).

[audio-issue-test2.zip](https://github.com/user-attachments/files/18187955/audio-issue-test2.zip)


<br>

Godot v4.4.dev3 - Windows 10.0.19045 - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated AMD Radeon RX 580 2048SP (Advanced Micro Devices, Inc.; 31.0.21921.1000) - AMD Ryzen 5 3600 6-Core Processor (12 threads)
Cannot reproduce on macOS (master). Is it a Windows-specific issue?
Me and the issue author is using Windows, the author of issue #100819 that seems to be the same problem also use windows and timothyqiu was unable to reproduce on Linux, so indeed seems to be windows specific.

Fix patch:
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index bfc91a2703f4..98440b0c81fa 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -1272,7 +1272,9 @@ void AudioServer::stop_playback_stream(Ref<AudioStreamPlayback> p_playback) {
 		return;
 	}
 
-	p_playback->stop();
+	if (!p_playback->is_playing()) {
+		p_playback->stop();
+	}
 
 	AudioStreamPlaybackListNode *playback_node = _find_playback_list_node(p_playback);
 	if (!playback_node) {


Test patch: