diff --git a/android/src/services/audio.ts b/android/src/services/audio.ts index 4852bd4..91ba372 100644 --- a/android/src/services/audio.ts +++ b/android/src/services/audio.ts @@ -1098,14 +1098,15 @@ class AudioService { if (this.preloadedPath) RNFS.unlink(this.preloadedPath).catch(() => {}); this.preloadedPath = ''; } - // PCM-Stream ebenfalls hart stoppen (Cancel/Abbruch) - if (this.pcmStreamActive) { - PcmStreamPlayer?.stop().catch(() => {}); - this.pcmStreamActive = false; - this.pcmBuffer = []; - this.pcmBytesCollected = 0; - this.pcmMessageId = ''; - } + // PCM-Stream ebenfalls hart stoppen (Cancel/Abbruch). + // pcmStreamActive wird beim isFinal-Chunk schon false gesetzt — der + // AudioTrack spielt aber noch sekundenlang aus seinem Buffer ab. Daher + // IMMER stop() aufrufen, ohne den Flag zu pruefen (ist idempotent). + PcmStreamPlayer?.stop().catch(() => {}); + this.pcmStreamActive = false; + this.pcmBuffer = []; + this.pcmBytesCollected = 0; + this.pcmMessageId = ''; // Audio-Focus sofort freigeben — User hat explizit abgebrochen this._cancelDeferredFocusRelease(); AudioFocus?.release().catch(() => {});