FileDocCategorySizeDatePackage
DirectAudioRenderer.javaAPI DocJMF 2.1.1e7808Mon May 12 12:21:32 BST 2003com.sun.media.renderer.audio

DirectAudioRenderer

public class DirectAudioRenderer extends AudioRenderer
DirectAudioRenderer to render audio to a device directly. This is used in conjunction DirectAudioOutput.
version

Fields Summary
static String
NAME
static boolean
loaded
private int
nativeData
Constructors Summary
public DirectAudioRenderer()


      
        super();

	//
	// This line advertizes all the formats that are supported
	// by this renderer.
	// Here we assume the renderer can support all linear/PCM formats.
	//
	supportedFormats = new Format[] {

            new AudioFormat(
                AudioFormat.LINEAR,
		44100,				// Sample rate
		AudioFormat.NOT_SPECIFIED,	// Sample size
		2,	// # of channels
		AudioFormat.LITTLE_ENDIAN,
		AudioFormat.NOT_SPECIFIED
            ),
            new AudioFormat(
                AudioFormat.LINEAR,
		44100,				// Sample rate
		AudioFormat.NOT_SPECIFIED,	// Sample size
		1,	// # of channels
		AudioFormat.LITTLE_ENDIAN,
		AudioFormat.NOT_SPECIFIED
            ),

            new AudioFormat(
                AudioFormat.LINEAR,
		22050,				// Sample rate
		AudioFormat.NOT_SPECIFIED,	// Sample size
		AudioFormat.NOT_SPECIFIED,	// # of channels
		AudioFormat.LITTLE_ENDIAN,
		AudioFormat.NOT_SPECIFIED
            ),

            new AudioFormat(
                AudioFormat.LINEAR,
		11025,		 		// Sample rate
		AudioFormat.NOT_SPECIFIED,	// Sample size
		AudioFormat.NOT_SPECIFIED,	// # of channels
		AudioFormat.LITTLE_ENDIAN,
		AudioFormat.NOT_SPECIFIED
            ),

            new AudioFormat(
                AudioFormat.LINEAR,
		8000,				// Sample rate
		AudioFormat.NOT_SPECIFIED,	// Sample size
		AudioFormat.NOT_SPECIFIED,	// # of channels
		AudioFormat.LITTLE_ENDIAN,
		AudioFormat.NOT_SPECIFIED
            ),
	};

	gainControl = new MCA(this);
    
Methods Summary
public voidclose()
Close the renderer and the device.

        super.close();
    
protected com.sun.media.renderer.audio.device.AudioOutputcreateDevice(javax.media.format.AudioFormat format)
Create the device - DirectAudioOutput.

	return (new DirectAudioOutput());
    
public voidflush()

	device.flush();
    
public java.lang.StringgetName()

	return NAME;
    
private static synchronized booleangrabDevice()
Grab the audio device without opening it.

	// If the device can be claimed without being opened,
	// then fill in this method.
	return true;
    
private native intnBufferAvailable()

private native voidnClose()

private native voidnDrain()

private native voidnFlush()

private native longnGetSamplesPlayed()

private native booleannOpen(int rate, int sizeInBits, int channels, int bufSize)
native method declaraions

private native voidnPause()

private native voidnResume()

private native voidnSetGain(float g)

private native voidnSetMute(boolean m)

private native intnWrite(byte[] data, int off, int len)

public voidopen()

	if (device == null && inputFormat != null) {
	    if (!initDevice(inputFormat))
		throw new ResourceUnavailableException("Cannot intialize audio device for playback");
	}
    
public floatsetRate(float factor)
Set the rate of the renderer.

	// Assume the rate cannot be changed for this renderer.
	return super.setRate(1.0f);