Merge pull request #1077 from MihailRis/fix-audio-streams-cleanup
Some checks are pending
x86-64 AppImage / build-appimage (ubuntu-22.04) (push) Waiting to run
Build / Build (push) Waiting to run
Macos Build / build-dmg (push) Waiting to run
Windows Build (CLang) / build-windows (clang, windows-latest) (push) Waiting to run
MSVC Build / build-windows (windows-2022) (push) Waiting to run

fix audio streams cleanup
This commit is contained in:
MihailRis 2026-11-03 23:21:18 +03:00 • committed by GitHub
commit 3ee20855a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View file

@ -275,8 +275,7 @@ void ALStream::update(double delta) {
unqueueBuffers(alsource);
uint preloaded = enqueueBuffers(alsource);
// alspeaker->stopped is assigned to false at ALSpeaker::play(...)
if (speaker->isStopped() && !alspeaker->manuallyStopped) { //TODO: -V560 false-positive?
if (speaker->isStopped()) {
if (preloaded) {
speaker->play();
} else if (isStopOnEnd()){

View file

@ -349,7 +349,8 @@ void remove_lower_priority_speaker(int priority) {
for (auto it = speakers.begin(); it != speakers.end();) {
if (it->second->getPriority() < priority && it->second->isPaused()) {
it->second->stop();
it = speakers.erase(it);
streams.erase(it->first);
speakers.erase(it);
return;
}
it++;
@ -357,7 +358,8 @@ void remove_lower_priority_speaker(int priority) {
for (auto it = speakers.begin(); it != speakers.end();) {
if (it->second->getPriority() < priority) {
it->second->stop();
it = speakers.erase(it);
streams.erase(it->first);
speakers.erase(it);
return;
}
it++;
@ -445,6 +447,7 @@ speakerid_t audio::play_stream(
int channel
) {
std::shared_ptr<Stream> stream(open_stream(file, false));
stream->setStopOnEnd(true);
return play(stream, position, relative, volume, pitch, loop, channel);
}
@ -520,8 +523,8 @@ void audio::update(double delta) {
if (speaker->isStopped()) {
auto foundStream = streams.find(it->first);
if (foundStream == streams.end() ||
(!speaker->isManuallyStopped() &&
foundStream->second->isStopOnEnd())) {
speaker->isManuallyStopped() ||
foundStream->second->isStopOnEnd()) {
streams.erase(it->first);
it = speakers.erase(it);
} else {