Fixed Mp3Loader and OggLoader not resetting stream position
This commit is contained in:
committed by
Matthias Mailänder
parent
87b92b53a4
commit
6fb228ddd1
@@ -48,6 +48,9 @@ namespace OpenRA.Mods.Common.AudioLoaders
|
|||||||
readonly Stream stream;
|
readonly Stream stream;
|
||||||
|
|
||||||
public Mp3Format(Stream stream)
|
public Mp3Format(Stream stream)
|
||||||
|
{
|
||||||
|
var startPosition = stream.Position;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
mp3 = new MP3Stream(stream);
|
mp3 = new MP3Stream(stream);
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
@@ -63,6 +66,11 @@ namespace OpenRA.Mods.Common.AudioLoaders
|
|||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
stream.Position = startPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Stream Clone(Mp3Format cloneFrom)
|
Stream Clone(Mp3Format cloneFrom)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,16 +48,24 @@ namespace OpenRA.Mods.Common.AudioLoaders
|
|||||||
readonly Stream stream;
|
readonly Stream stream;
|
||||||
|
|
||||||
public OggFormat(Stream stream)
|
public OggFormat(Stream stream)
|
||||||
|
{
|
||||||
|
var startPosition = stream.Position;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
reader = new VorbisReader(stream);
|
reader = new VorbisReader(stream, false);
|
||||||
LengthInSeconds = (float) reader.TotalTime.TotalSeconds;
|
LengthInSeconds = (float)reader.TotalTime.TotalSeconds;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
stream.Position = startPosition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OggFormat(OggFormat cloneFrom)
|
OggFormat(OggFormat cloneFrom)
|
||||||
{
|
{
|
||||||
stream = SegmentStream.CreateWithoutOwningStream(cloneFrom.stream, 0, (int)cloneFrom.stream.Length);
|
stream = SegmentStream.CreateWithoutOwningStream(cloneFrom.stream, 0, (int)cloneFrom.stream.Length);
|
||||||
reader = new VorbisReader(stream)
|
reader = new VorbisReader(stream, false)
|
||||||
{
|
{
|
||||||
// Tell NVorbis to clip samples so we don't have to range-check during reading.
|
// Tell NVorbis to clip samples so we don't have to range-check during reading.
|
||||||
ClipSamples = true
|
ClipSamples = true
|
||||||
|
|||||||
Reference in New Issue
Block a user