Release audio resource for video when StopVideo is called.

This commit is contained in:
RoosterDragon
2017-06-14 20:14:19 +01:00
committed by abcdefg30
parent 3f8c1ad5df
commit 5d8c9a560a

View File

@@ -40,7 +40,7 @@ namespace OpenRA
ISoundLoader[] loaders;
IReadOnlyFileSystem fileSystem;
Cache<string, ISoundSource> sounds;
ISoundSource rawSource;
ISoundSource videoSource;
ISound music;
ISound video;
MusicInfo currentMusic;
@@ -149,8 +149,9 @@ namespace OpenRA
public void PlayVideo(byte[] raw, int channels, int sampleBits, int sampleRate)
{
rawSource = soundEngine.AddSoundSourceFromMemory(raw, channels, sampleBits, sampleRate);
video = soundEngine.Play2D(rawSource, false, true, WPos.Zero, InternalSoundVolume, false);
StopVideo();
videoSource = soundEngine.AddSoundSourceFromMemory(raw, channels, sampleBits, sampleRate);
video = soundEngine.Play2D(videoSource, false, true, WPos.Zero, InternalSoundVolume, false);
}
public void PlayVideo()
@@ -168,7 +169,12 @@ namespace OpenRA
public void StopVideo()
{
if (video != null)
{
soundEngine.StopSound(video);
videoSource.Dispose();
videoSource = null;
video = null;
}
}
public void Tick()