mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-12-03 12:49:30 +00:00
8e6e5424bb
Every sound played through a BackgroundAudio shares the one audio context, which is suspended rather than closed when a sound ends so that it can be reused. The handler suspended it whenever any source finished, so a sound that started while an earlier one was still going was cut off part way through. Suspending is not stopping either: the cut-off buffer stayed where it was and picked up again the next time anything was played, which is how a notification for one room ends up sounding in another. The context is now suspended only once nothing this instance started is still running, and each source is disconnected as it ends. A looping sound holds the count up until it is stopped, and stopping it ends it, so the context is still suspended as soon as everything is quiet. Tests: the context is suspended when a lone sound ends, and left running while a second sound outlasts the first.