Fixed AssetBrowserLogic disposing audio streams prematurely

This commit is contained in:
penev92
2022-01-04 23:58:07 +02:00
committed by Matthias Mailänder
parent 6fb228ddd1
commit b6b417d42f

View File

@@ -481,20 +481,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// Mute music so it doesn't interfere with the current asset. // Mute music so it doesn't interfere with the current asset.
MuteSounds(); MuteSounds();
using (var soundStream = Game.ModData.DefaultFileSystem.Open(prefix + filename)) currentAudioStream = Game.ModData.DefaultFileSystem.Open(prefix + filename);
foreach (var modDataSoundLoader in Game.ModData.SoundLoaders)
{ {
foreach (var modDataSoundLoader in Game.ModData.SoundLoaders) if (modDataSoundLoader.TryParseSound(currentAudioStream, out currentSoundFormat))
{ {
if (modDataSoundLoader.TryParseSound(soundStream, out currentSoundFormat)) if (frameSlider != null)
{ {
if (frameSlider != null) frameSlider.MaximumValue = currentSoundFormat.LengthInSeconds * currentSoundFormat.SampleRate;
{ frameSlider.Ticks = 0;
frameSlider.MaximumValue = currentSoundFormat.LengthInSeconds * currentSoundFormat.SampleRate;
frameSlider.Ticks = 0;
}
break;
} }
break;
} }
} }
} }