|
|
Bug is caused by play-sound-from-file leaking AudioStream handles. The briefing code also leaks the music AudioStream on missions that use only a video for the briefing because the AudioStream is never played, so the audio stream is never "serviced".
Both leaks come back to Destroy_And_Fade not checking if the Stream is still active before setting the flags. If the stream is not active the stream is not able to delete itself as Destroy_And_Fade expects it to. |
|
|
|
I think I'm getting errors when applying this patch. Do you think you can make a new one? What's with line 24 where it reads "m_bLooping, m_bFade, m_bDestroy_when_faded));"? |
|
|
|
mantis_2711.patch (1,577 bytes)
Index: code/sound/audiostr.cpp
===================================================================
--- code/sound/audiostr.cpp (revision 9116)
+++ code/sound/audiostr.cpp (working copy)
@@ -260,6 +260,7 @@
uint GetMaxWriteSize (void);
bool ServiceBuffer (void);
static bool TimerCallback (ptr_u dwUser);
+ bool PlaybackDone(void);
ALuint m_source_id; // name of openAL source
ALuint m_buffer_ids[MAX_STREAM_BUFFERS]; // names of buffers
@@ -1375,13 +1382,11 @@
m_bPastLimit = true;
}
-
- // see if we're done
- ALint state = 0;
- OpenAL_ErrorPrint( alGetSourcei(m_source_id, AL_SOURCE_STATE, &state) );
-
- if ( m_bReadingDone && (state != AL_PLAYING) ) {
+ if ( PlaybackDone() ) {
if ( m_bDestroy_when_faded == true ) {
LEAVE_CRITICAL_SECTION( write_lock );
Destroy();
@@ -1508,11 +1514,20 @@
}
-// Fade_and_Destroy
+/** Have stream fade out and be destroyed when inaudabile.
+If stream is already done or never started just destroy it now.
+*/
void AudioStream::Fade_and_Destroy (void)
{
- m_bFade = true;
- m_bDestroy_when_faded = true;
+ if (!m_fPlaying || PlaybackDone())
+ {
+ Destroy();
+ }
+ else
+ {
+ m_bFade = true;
+ m_bDestroy_when_faded = true;
+ }
}
// Fade_and_Destroy
@@ -1586,8 +1601,18 @@
return m_lVolume;
}
+bool AudioStream::PlaybackDone()
+{
+ ALint state = 0;
+ OpenAL_ErrorPrint( alGetSourcei(m_source_id, AL_SOURCE_STATE, &state) );
+ if (m_bReadingDone && (state != AL_PLAYING))
+ return true;
+ else
+ return false;
+}
+
AudioStream Audio_streams[MAX_AUDIO_STREAMS];
|
|
|
|
Sorry, that was the tail of some debugging code. The patch itself applies fine for me with TortiseSVN on the latest trunk. |
|
|
|
Played through seven missions in Diaspora without briefing audio dropping out. This patch works. |
|
|
|
committed in r9197 |
|