forked from naudio/NAudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNullWaveStream.cs
39 lines (33 loc) · 970 Bytes
/
NullWaveStream.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using NAudio.Wave;
namespace NAudioTests.Utils
{
class NullWaveStream : WaveStream
{
private readonly long length;
private long position;
public NullWaveStream(WaveFormat format, long length)
{
WaveFormat = format;
this.length = length;
}
public override WaveFormat WaveFormat { get; }
public override long Length => length;
public override long Position
{
get { return position; }
set { position = value; }
}
public override int Read(byte[] buffer, int offset, int count)
{
if (position > length)
{
return 0;
}
count = (int)Math.Min(count, length - position);
Array.Clear(buffer, offset, count);
position += count;
return count;
}
}
}