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