FileDocCategorySizeDatePackage
DSound.javaAPI DocJMF 2.1.1e2228Mon May 12 12:21:20 BST 2003com.sun.media.protocol.dsound

DSound

public class DSound extends Object

Fields Summary
private static boolean
opened
private static AudioFormat
format
private static int
bufSize
private static long
directSound
private long
dsBuffer
static boolean
loaded
Constructors Summary
public DSound(AudioFormat format, int bufferSize)


     
	if (!loaded) {
	    try {
		JMFSecurityManager.checkCapture();
		JMFSecurityManager.loadLibrary("jmdaudc");
		loaded = true;
	    } catch (UnsatisfiedLinkError e) {
		loaded = false;
		throw e;
	    }
	}
    
	this.format = format;
	this.bufSize = bufferSize;
    
Methods Summary
public synchronized voidclose()

	if (dsBuffer != 0)
	    nClose(dsBuffer);
	dsBuffer = 0;
    
public voidflush()

	nFlush(dsBuffer);
    
public intgetBufferSize()

	return bufSize;
    
public javax.media.format.AudioFormatgetFormat()

	return format;
    
public static booleanisFormatSupported(javax.media.format.AudioFormat format, int bufSize)

	return true;
    
public static booleanisOpen()

	return opened;
    
private native synchronized voidnClose(long dsBuffer)

private native synchronized voidnFlush(long dsBuffer)

private native longnOpen(int sampleRate, int sampleSize, int channels, int bufferSize)

private native synchronized intnRead(long dsBuffer, byte[] data, int offset, int len)

private native synchronized voidnStart(long dsBuffer)

private native synchronized voidnStop(long dsBuffer)

public voidopen()

	
	dsBuffer = nOpen((int) format.getSampleRate(),
			 format.getSampleSizeInBits(),
			 format.getChannels(),
			 bufSize);
	if (dsBuffer == 0)
	    throw new Error("Couldn't create capture buffer");
    
public intread(byte[] data, int offset, int len)

	return nRead(dsBuffer, data, offset, len);
    
public voidstart()

	nStart(dsBuffer);
    
public voidstop()

	nStop(dsBuffer);