forked from filoe/cscore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileCachedSoundSource.cs
36 lines (32 loc) · 958 Bytes
/
FileCachedSoundSource.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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CSCore;
using CSCore.Streams;
namespace CSCoreWaveform
{
public class FileCachedSoundSource : CachedSoundSource
{
private string _filename;
public FileCachedSoundSource(IWaveSource source) : base(source)
{
}
protected override Stream CreateStream()
{
_filename = @"D:\Temp\waveform.tmp";
//_filename = Path.GetTempFileName();
return new FileStream(_filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 4096, FileOptions.DeleteOnClose | FileOptions.Asynchronous);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (File.Exists(_filename))
{
File.Delete(_filename);
}
}
}
}