mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
FLACReader.Position was returning nonsense (thanks, Ivailo)
This commit is contained in:
@@ -229,7 +229,7 @@ namespace CUETools { namespace Codecs { namespace FLAC {
|
|||||||
|
|
||||||
virtual property Int64 Remaining {
|
virtual property Int64 Remaining {
|
||||||
Int64 get() {
|
Int64 get() {
|
||||||
return _sampleCount - _sampleOffset + SamplesInBuffer;
|
return _sampleCount - Position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +273,6 @@ namespace CUETools { namespace Codecs { namespace FLAC {
|
|||||||
throw gcnew Exception(String::Format("an error occurred while decoding: {0}", state));
|
throw gcnew Exception(String::Format("an error occurred while decoding: {0}", state));
|
||||||
}
|
}
|
||||||
} while (_bufferLength == 0);
|
} while (_bufferLength == 0);
|
||||||
_sampleOffset += _bufferLength;
|
|
||||||
}
|
}
|
||||||
Int32 copyCount = Math::Min(samplesNeeded, SamplesInBuffer);
|
Int32 copyCount = Math::Min(samplesNeeded, SamplesInBuffer);
|
||||||
Array::Copy(_sampleBuffer->Bytes, _bufferOffset * pcm->BlockAlign, buff->Bytes, buffOffset * pcm->BlockAlign, copyCount * pcm->BlockAlign);
|
Array::Copy(_sampleBuffer->Bytes, _bufferOffset * pcm->BlockAlign, buff->Bytes, buffOffset * pcm->BlockAlign, copyCount * pcm->BlockAlign);
|
||||||
@@ -349,6 +348,7 @@ namespace CUETools { namespace Codecs { namespace FLAC {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_bufferLength = sampleCount;
|
_bufferLength = sampleCount;
|
||||||
|
_sampleOffset += _bufferLength;
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,15 @@ namespace CUETools.TestCodecs
|
|||||||
CollectionAssert.AreEqual(testSamples2, target.Samples, "CUETools.Codecs.AudioBuffer.Samples was not set correctly.");
|
CollectionAssert.AreEqual(testSamples2, target.Samples, "CUETools.Codecs.AudioBuffer.Samples was not set correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public static void AreEqual(AudioBuffer buff1, AudioBuffer buff2)
|
||||||
|
{
|
||||||
|
var bytes1 = new byte[buff1.ByteLength];
|
||||||
|
var bytes2 = new byte[buff2.ByteLength];
|
||||||
|
Array.Copy(buff1.Bytes, bytes1, buff1.ByteLength);
|
||||||
|
Array.Copy(buff2.Bytes, bytes2, buff2.ByteLength);
|
||||||
|
CollectionAssert.AreEqual(bytes1, bytes2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -55,16 +55,22 @@ namespace CUETools.TestCodecs
|
|||||||
var r = new FLACReader("test.flac", null);
|
var r = new FLACReader("test.flac", null);
|
||||||
var buff1 = new AudioBuffer(r, 16536);
|
var buff1 = new AudioBuffer(r, 16536);
|
||||||
var buff2 = new AudioBuffer(r, 16536);
|
var buff2 = new AudioBuffer(r, 16536);
|
||||||
|
Assert.AreEqual(0, r.Position);
|
||||||
r.Read(buff1, 7777);
|
r.Read(buff1, 7777);
|
||||||
|
Assert.AreEqual(7777, r.Position);
|
||||||
r.Position = 0;
|
r.Position = 0;
|
||||||
|
Assert.AreEqual(0, r.Position);
|
||||||
r.Read(buff2, 7777);
|
r.Read(buff2, 7777);
|
||||||
|
Assert.AreEqual(7777, r.Position);
|
||||||
|
AudioBufferTest.AreEqual(buff1, buff2);
|
||||||
|
r.Read(buff1, 7777);
|
||||||
|
Assert.AreEqual(7777+7777, r.Position);
|
||||||
|
r.Position = 7777;
|
||||||
|
Assert.AreEqual(7777, r.Position);
|
||||||
|
r.Read(buff2, 7777);
|
||||||
|
Assert.AreEqual(7777+7777, r.Position);
|
||||||
|
AudioBufferTest.AreEqual(buff1, buff2);
|
||||||
r.Close();
|
r.Close();
|
||||||
Assert.AreEqual(buff1.ByteLength, buff2.ByteLength);
|
|
||||||
var bytes1 = new byte[buff1.ByteLength];
|
|
||||||
var bytes2 = new byte[buff2.ByteLength];
|
|
||||||
Array.Copy(buff1.Bytes, bytes1, buff1.ByteLength);
|
|
||||||
Array.Copy(buff2.Bytes, bytes2, buff2.ByteLength);
|
|
||||||
CollectionAssert.AreEqual(bytes1, bytes2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,16 +156,22 @@ namespace CUETools.TestCodecs
|
|||||||
var r = new FlakeReader("test.flac", null);
|
var r = new FlakeReader("test.flac", null);
|
||||||
var buff1 = new AudioBuffer(r, 16536);
|
var buff1 = new AudioBuffer(r, 16536);
|
||||||
var buff2 = new AudioBuffer(r, 16536);
|
var buff2 = new AudioBuffer(r, 16536);
|
||||||
|
Assert.AreEqual(0, r.Position);
|
||||||
r.Read(buff1, 7777);
|
r.Read(buff1, 7777);
|
||||||
|
Assert.AreEqual(7777, r.Position);
|
||||||
r.Position = 0;
|
r.Position = 0;
|
||||||
|
Assert.AreEqual(0, r.Position);
|
||||||
r.Read(buff2, 7777);
|
r.Read(buff2, 7777);
|
||||||
|
Assert.AreEqual(7777, r.Position);
|
||||||
|
AudioBufferTest.AreEqual(buff1, buff2);
|
||||||
|
r.Read(buff1, 7777);
|
||||||
|
Assert.AreEqual(7777 + 7777, r.Position);
|
||||||
|
r.Position = 7777;
|
||||||
|
Assert.AreEqual(7777, r.Position);
|
||||||
|
r.Read(buff2, 7777);
|
||||||
|
Assert.AreEqual(7777 + 7777, r.Position);
|
||||||
|
AudioBufferTest.AreEqual(buff1, buff2);
|
||||||
r.Close();
|
r.Close();
|
||||||
Assert.AreEqual(buff1.ByteLength, buff2.ByteLength);
|
|
||||||
var bytes1 = new byte[buff1.ByteLength];
|
|
||||||
var bytes2 = new byte[buff2.ByteLength];
|
|
||||||
Array.Copy(buff1.Bytes, bytes1, buff1.ByteLength);
|
|
||||||
Array.Copy(buff2.Bytes, bytes2, buff2.ByteLength);
|
|
||||||
CollectionAssert.AreEqual(bytes1, bytes2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ Global
|
|||||||
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|Win32.ActiveCfg = Release|Any CPU
|
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||||
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|x64.ActiveCfg = Release|Any CPU
|
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|x86.ActiveCfg = Release|Any CPU
|
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Any CPU.ActiveCfg = Debug|x64
|
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||||
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Mixed Platforms.ActiveCfg = Debug|x64
|
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Mixed Platforms.ActiveCfg = Debug|x64
|
||||||
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Mixed Platforms.Build.0 = Debug|x64
|
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Mixed Platforms.Build.0 = Debug|x64
|
||||||
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Win32.ActiveCfg = Debug|Win32
|
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
|||||||
Reference in New Issue
Block a user