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

DirectAudioRenderer

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

Fields Summary
static String
NAME
private boolean
osCanMix
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
		AudioFormat.NOT_SPECIFIED,	// # of channels
		AudioFormat.BIG_ENDIAN,
		AudioFormat.SIGNED
            ),

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

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

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

	gainControl = new MCA(this);

	osCanMix = nCanMix();
    
Methods Summary
public synchronized 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;
    
public booleanisExclusive()

	return !osCanMix;
    
private native intnBufferAvailable()

private native booleannCanMix()

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 synchronized 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);