From 58d4c4f9ae89fe43eb31004bb614885e83c3943d Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 14 Feb 2007 20:18:22 +0000 Subject: [PATCH] - Fixed: S_ClearSoundData() did not stop any channels before freeing the samples, a problem for the alternate sound renderer if it happened to be playing any sounds at the time, since it would try to keep on playing them. SVN r483 (trunk) --- docs/rh-log.txt | 7 ++++++- src/s_advsound.cpp | 1 + src/sound/altsound.cpp | 17 +++++++++++++++++ src/sound/altsound.h | 3 +++ src/sound/fmodsound.cpp | 9 +++++++++ src/sound/fmodsound.h | 3 +++ src/sound/i_sound.h | 3 +++ 7 files changed, 42 insertions(+), 1 deletion(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 78040ef17..50e3c5017 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,8 @@ +February 14, 2007 +- Fixed: S_ClearSoundData() did not stop any channels before freeing the + samples, a problem for the alternate sound renderer if it happened to be + playing any sounds at the time, since it would try to keep on playing them. + February 12, 2007 - Added two new cvars (win_x and win_y) that keep track of the window position when not playing in fullscreen mode. @@ -43,7 +48,7 @@ February 3, 2007 February 2, 2007 - Added a new fixrtext tool that sets the IMAGE_SCN_MEM_WRITE flag for - .rtext files in the assembly object files. Now I can avoid doing this at + .rtext sections in the assembly object files. Now I can avoid doing this at runtime, which means that ZDoom is now UPX-compatible if anyone wants to pack it. diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index ada2aaa43..ef64f5a9b 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -746,6 +746,7 @@ static void S_ClearSoundData() if (GSnd != NULL) { + GSnd->StopAllChannels(); for (i = 0; i < S_sfx.Size(); ++i) { GSnd->UnloadSound (&S_sfx[i]); diff --git a/src/sound/altsound.cpp b/src/sound/altsound.cpp index f9b359178..7f5cdfd0b 100644 --- a/src/sound/altsound.cpp +++ b/src/sound/altsound.cpp @@ -546,6 +546,23 @@ void AltSoundRenderer::StopSound (long handle) chan->Sample = NULL; } +//========================================================================== +// +// AltSoundRenderer :: StopAllChannels +// +//========================================================================== + +void AltSoundRenderer::StopAllChannels () +{ + if (Channels != NULL) + { + for (int i = 0; i < NumChannels; ++i) + { + Channels[i].Sample = NULL; + } + } +} + //========================================================================== // // AltSoundRenderer :: SetSfxPaused diff --git a/src/sound/altsound.h b/src/sound/altsound.h index dd6c41e60..c79851d37 100644 --- a/src/sound/altsound.h +++ b/src/sound/altsound.h @@ -30,6 +30,9 @@ public: // Stops a sound channel. void StopSound (long handle); + // Stops all sounds. + void StopAllChannels (); + // Pauses or resumes all sound effect channels. void SetSfxPaused (bool paused); diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index e10f33d82..411f4ded9 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -756,6 +756,15 @@ void FMODSoundRenderer::StopSound (long handle) } } +void FMODSoundRenderer::StopAllChannels () +{ + for (long i = 1; i <= NumChannels; ++i) + { + StopSound (i); + } +} + + void FMODSoundRenderer::SetSfxPaused (bool paused) { for (int i = 0; i < NumChannels; ++i) diff --git a/src/sound/fmodsound.h b/src/sound/fmodsound.h index 17766d0d8..a63a5b71b 100644 --- a/src/sound/fmodsound.h +++ b/src/sound/fmodsound.h @@ -32,6 +32,9 @@ public: // Stops a sound channel. void StopSound (long handle); + // Stops all sounds. + void StopAllChannels (); + // Pauses or resumes all sound effect channels. void SetSfxPaused (bool paused); diff --git a/src/sound/i_sound.h b/src/sound/i_sound.h index 280a9aec8..0ec2d2ebe 100644 --- a/src/sound/i_sound.h +++ b/src/sound/i_sound.h @@ -99,6 +99,9 @@ public: // Stops a sound channel. virtual void StopSound (long handle) = 0; + // Stops all sounds. + virtual void StopAllChannels () = 0; + // Pauses or resumes all sound effect channels. virtual void SetSfxPaused (bool paused) = 0;