From 443ddf670b591b6e92d8efe591920e08cafa87fb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 5 Sep 2020 18:14:50 +0200 Subject: [PATCH] - let the ANM player wait until the sound has finished if it has reached the last frame before the sound ends. In Shadow Warrior there's a few where the sound plays a bit longer than the video. Fixes #341 --- source/common/audio/sound/s_sound.cpp | 10 ++++++++++ source/core/screenjob.cpp | 1 + 2 files changed, 11 insertions(+) diff --git a/source/common/audio/sound/s_sound.cpp b/source/common/audio/sound/s_sound.cpp index f92a7d830..a9445a619 100644 --- a/source/common/audio/sound/s_sound.cpp +++ b/source/common/audio/sound/s_sound.cpp @@ -1071,6 +1071,16 @@ int SoundEngine::GetSoundPlayingInfo (int sourcetype, const void *source, int so } } } + else + { + for (FSoundChan* chan = Channels; chan != NULL; chan = chan->NextChan) + { + if ((sourcetype == SOURCE_Any || (chan->SourceType == sourcetype && chan->Source == source))) + { + count++; + } + } + } return count; } diff --git a/source/core/screenjob.cpp b/source/core/screenjob.cpp index b0ef2963d..6c7663240 100644 --- a/source/core/screenjob.cpp +++ b/source/core/screenjob.cpp @@ -175,6 +175,7 @@ public: soundEngine->StartSound(SOURCE_None, nullptr, nullptr, CHAN_AUTO, CHANF_UI, sound, 1.f, ATTN_NONE); } } + if (!skiprequest && !nostopsound && curframe == numframes && soundEngine->GetSoundPlayingInfo(SOURCE_None, nullptr, -1)) return 1; curframe++; if (skiprequest && !nostopsound) soundEngine->StopAllChannels(); return skiprequest ? -1 : curframe < numframes? 1 : 0;