Repository: godotengine/godot (language: cpp)

Issue:
[4.4 Beta3] A Web Audio malfunction that causes the entire game to stop.
### Tested versions

4.4 Beta 3

### System information

Ubuntu 22.04, Chromium

### Issue description

An error occurs at any time while the game im gameplay:

![Image](https://github.com/user-attachments/assets/c0e21ca5-be5c-4a72-bcf9-82f6f9b7cabf)

```
index.js:9 Uncaught InvalidStateError: Failed to execute 'stop' on 'AudioScheduledSourceNode': cannot call stop without calling start first.
    at SampleNode._pause (index.js:9:168760)
    at SampleNode.pause (index.js:9:165983)
    at SampleNode.pauseSampleNode (index.js:9:164123)
    at Object.sample_set_pause (index.js:9:175865)
    at _godot_audio_sample_set_pause (index.js:9:181003)
    at 0a684d66:0x51b2e
    at 0a684d66:0x168ccc8
    at 0a684d66:0x168c8f8
    at 0a684d66:0x147ac38
    at 0a684d66:0x147e48f
```

See - https://pn-games.com/play/audio-test

Open Developer Tools -> Console -> Try test

### Steps to reproduce

It's just that the play/stop methods are called periodically for sounds.

In this case, the stop method is preceded by a playing check, something like 

```
if snd.playing:
    snd.stop()
```

### Minimal reproduction project (MRP)

[web-audio-error.zip](https://github.com/user-attachments/files/18825091/web-audio-error.zip)

Export this to HTML5 Application and run. Instructoin is inside.


Discussion / hints:
So far, the only information I've been able to find from the error text is here. I assume this applies to the JavaScript part of the engine.

https://developer.mozilla.org/en-US/docs/Web/API/AudioScheduledSourceNode/stop

What is written here very accurately describes the error that the browser debugging console shows me.
Updated.

Fix patch:
diff --git a/platform/web/js/libs/library_godot_audio.js b/platform/web/js/libs/library_godot_audio.js
index d04862795308..759d893fd946 100644
--- a/platform/web/js/libs/library_godot_audio.js
+++ b/platform/web/js/libs/library_godot_audio.js
@@ -735,6 +735,9 @@ class SampleNode {
 	 * @returns {void}
 	 */
 	_pause() {
+		if (!this.isStarted) {
+			return;
+		}
 		this.isPaused = true;
 		this.pauseTime = (GodotAudio.ctx.currentTime - this._sourceStartTime) / this.getPlaybackRate();
 		this._source.stop();


Test patch: