forked from mono/csvorbis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOggDecoder.cs
54 lines (48 loc) · 963 Bytes
/
OggDecoder.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.IO;
using csogg;
using csvorbis;
namespace OggDecoder
{
/// <summary>
/// Ogg Vorbis decoder test application.
/// </summary>
class Decoder
{
/// <summary>
/// The main entry point for the application.
/// </summary>
//[STAThread]
static void Main(string[] args)
{
TextWriter s_err = Console.Error;
FileStream input = null, output = null;
if(args.Length == 2)
{
try
{
input = new FileStream(args[0], FileMode.Open, FileAccess.Read);
output = new FileStream(args[1], FileMode.OpenOrCreate);
}
catch(Exception e)
{
s_err.WriteLine(e);
}
}
else
{
return;
}
OggDecodeStream decode = new OggDecodeStream(input, true);
byte[] buffer = new byte[4096];
int read;
while ((read = decode.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, read);
}
// Close some files
input.Close();
output.Close();
}
}
}