File: SourceDataLineOutputStream.java

package info (click to toggle)
libtritonus-java 20070428-12
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,960 kB
  • ctags: 11,917
  • sloc: ansic: 53,816; java: 45,226; sh: 3,022; makefile: 1,190; xml: 820; cpp: 147
file content (71 lines) | stat: -rw-r--r-- 1,284 bytes parent folder | download | duplicates (8)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 *	SourceDataLineOutputStream.java
 *
 *	Helper class for saint.
 */

import	java.io.InputStream;
import	java.io.IOException;
import	java.io.FileInputStream;
import	java.io.FileOutputStream;
import	java.io.OutputStream;

import	javax.sound.sampled.SourceDataLine;



public class SourceDataLineOutputStream
extends	OutputStream
{
	private static final boolean	DEBUG = true;

	private SourceDataLine	m_line;


	public SourceDataLineOutputStream(SourceDataLine line)
	{
		m_line = line;
	}


	public void write(int nByte)
	{
		if (DEBUG)
		{
			System.err.println("SourceDataLineOutputStream.write(int): called");
		}
		byte[]	abOneByte = new byte[1];
		abOneByte[0] = (byte) nByte;
		m_line.write(abOneByte, 0, 1);
	}



	public void write(byte[] abBuffer, int nOffset, int nLength)
		throws	IOException
	{
		if (DEBUG)
		{
			System.err.println("SourceDataLineOutputStream.write(byte[], int, int): called");
		}
		int	nWritten = m_line.write(abBuffer, nOffset, nLength);
		if (DEBUG)
		{
			System.err.println("SourceDataLineOutputStream.write(byte[], int, int): written: " + nWritten);
		}
	}


	public void flush()
	{
		if (DEBUG)
		{
			System.err.println("SourceDataLineOutputStream.flush(): called");
		}
		// m_line.drain();
	}
}



/*** SourceDataLineOutputStream.java ***/