FileDocCategorySizeDatePackage
SunAudioRenderer.javaAPI DocJMF 2.1.1e5217Mon May 12 12:20:48 BST 2003com.sun.media.renderer.audio

SunAudioRenderer

public class SunAudioRenderer extends AudioRenderer
SunAudioRenderer
version

Fields Summary
static String
NAME
public static String
vendor
public static String
version
public static boolean
runningOnMac
public static boolean
useSystemTime
private BasicClock
clock
private long
startMediaTime
public static long
DEVICE_LATENCY
Constructors Summary
public SunAudioRenderer()


      
        super();

	if (useSystemTime) {
	    timeBase = new SystemTimeBase();
	    clock = new BasicClock();
	}

	supportedFormats = new Format[1];
        supportedFormats[0] = new AudioFormat(
                AudioFormat.ULAW,
                8000,
                8,
                1,
                Format.NOT_SPECIFIED,
                Format.NOT_SPECIFIED
            );

	gainControl = new MCA(this);
    
Methods Summary
public voidclose()

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

	return (new SunAudioOutput());
    
public longgetMediaNanoseconds()


       
	if (useSystemTime) {
	    long t = clock.getMediaNanoseconds();
	    if (t - startMediaTime < DEVICE_LATENCY) {
		return startMediaTime;
	    }
	    return t - DEVICE_LATENCY;
	}
	return super.getMediaNanoseconds();
    
public javax.media.TimegetMediaTime()

	return (useSystemTime ? clock.getMediaTime() : super.getMediaTime());
    
public java.lang.StringgetName()

	return NAME;
    
public floatgetRate()

	return (useSystemTime ? clock.getRate() : super.getRate());
    
public javax.media.TimegetStopTime()

	if (useSystemTime)
	    return clock.getStopTime();
	else
	    return super.getStopTime();
    
public javax.media.TimegetSyncTime()

	return (useSystemTime ? clock.getSyncTime() : super.getSyncTime());
    
public javax.media.TimeBasegetTimeBase()

	return (useSystemTime ? clock.getTimeBase() : super.getTimeBase());
    
private static synchronized booleangrabDevice()


	/*
	  The following lines cause JMF to crash on the Mac.
	  Check to make sure we are not running on the Mac.
	*/

	if (runningOnMac) {
	    if (!sun.audio.AudioPlayer.player.isAlive()) {
                System.out.println("Audio device is busy");
                return false;
            }
	}
	return true;
    
public javax.media.TimemapToTimeBase(javax.media.Time t)

	return (useSystemTime ? clock.mapToTimeBase(t) : super.mapToTimeBase(t));
    
public voidopen()

	if (!grabDevice()) {
	    throw new ResourceUnavailableException("AudioRenderer: Failed to initialize audio device.");
	}
    
public voidsetMediaTime(javax.media.Time now)

	if (useSystemTime) {
	    clock.setMediaTime(now);
	    startMediaTime = now.getNanoseconds();
	} else
	    super.setMediaTime(now);
    
public floatsetRate(float factor)

	// sun.audio does not support rate change.
	return super.setRate(1.0f);
    
public voidsetStopTime(javax.media.Time t)

	if (useSystemTime)
	    clock.setStopTime(t);
	else
	    super.setStopTime(t);
    
public voidsetTimeBase(javax.media.TimeBase master)
Specialized clock methods to use system timebase instead of audio timebase for the mac.

	if (useSystemTime) {
	    if (!(master instanceof SystemTimeBase)) {
		Log.warning("AudioRenderer cannot be controlled by time bases other than its own: " + master);
		/**
		Silently allows the time base to be set to make
		addController slightly more useful.
	 	-ivg
		throw new IncompatibleTimeBaseException();
		*/
	    }
	    clock.setTimeBase(master);
	} else {
	    super.setTimeBase(master);
	}
    
public voidstop()

	super.stop();
	if (useSystemTime)
	    clock.stop();
    
public voidsyncStart(javax.media.Time at)

	super.syncStart(at);
	if (useSystemTime)
	    clock.syncStart(at);