View Issue Details

IDProjectCategoryView StatusLast Update
0002711FSSCPsoundpublic2012-09-12 02:27
Reporteriss_mneur Assigned Toiss_mneur  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformHomebrew PCOSMicrosoft WindowsOS Version 7 x64 Ultimate
Product Version3.6.14 RC6 
Target Version3.6.14 RC6 
Summary0002711: Briefing audio stops after playing several (0000007:0000004) diaspora missions in one session
DescriptionBriefing audio stops after playing several (0000007:0000004) diaspora missions in one session.
Steps To ReproducePlay any 4-5 Diaspora missions in a row and you will have the briefing audio cut out.
TagsNo tags attached.

Activities

iss_mneur

2012-09-10 03:19

developer   ~0013958

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.

Swifty

2012-09-11 04:44

developer   ~0013961

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));"?

iss_mneur

2012-09-11 04:58

developer  

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];
 
 
mantis_2711.patch (1,577 bytes)   

iss_mneur

2012-09-11 04:59

developer   ~0013962

Sorry, that was the tail of some debugging code. The patch itself applies fine for me with TortiseSVN on the latest trunk.

Swifty

2012-09-11 08:42

developer   ~0013963

Played through seven missions in Diaspora without briefing audio dropping out. This patch works.

iss_mneur

2012-09-12 02:27

developer   ~0013965

committed in r9197

Issue History

Date Modified Username Field Change
2012-09-10 03:10 iss_mneur New Issue
2012-09-10 03:10 iss_mneur Status new => assigned
2012-09-10 03:10 iss_mneur Assigned To => iss_mneur
2012-09-10 03:11 iss_mneur File Added: mantis_2711.patch
2012-09-10 03:19 iss_mneur Note Added: 0013958
2012-09-10 03:19 iss_mneur Status assigned => code review
2012-09-11 04:44 Swifty Note Added: 0013961
2012-09-11 04:58 iss_mneur File Deleted: mantis_2711.patch
2012-09-11 04:58 iss_mneur File Added: mantis_2711.patch
2012-09-11 04:59 iss_mneur Note Added: 0013962
2012-09-11 08:42 Swifty Note Added: 0013963
2012-09-12 02:27 iss_mneur Note Added: 0013965
2012-09-12 02:27 iss_mneur Status code review => resolved
2012-09-12 02:27 iss_mneur Resolution open => fixed