Class AbstractAudioRenderer<T extends AudioSystem>

  • Type Parameters:
    T - the runtime type of the AudioSystem which provides the playback device used by the AbstractAudioRenderer
    All Implemented Interfaces:
    javax.media.Controls, javax.media.PlugIn, javax.media.Renderer
    Direct Known Subclasses:
    MacCoreaudioRenderer, PortAudioRenderer, PulseAudioRenderer, WASAPIRenderer

    public abstract class AbstractAudioRenderer<T extends AudioSystem>
    extends AbstractRenderer<javax.media.format.AudioFormat>
    Provides an abstract base implementation of Renderer which processes media in AudioFormat in order to facilitate extenders.
    Author:
    Lyubomir Marinov
    • Field Detail

      • JAVA_AUDIO_FORMAT_ENDIAN

        public static final int JAVA_AUDIO_FORMAT_ENDIAN
        The byte order of the running Java virtual machine expressed in the endian term of AudioFormat.
        See Also:
        Constant Field Values
      • NATIVE_AUDIO_FORMAT_ENDIAN

        public static final int NATIVE_AUDIO_FORMAT_ENDIAN
        The native byte order of the hardware upon which this Java virtual machine is running expressed in the endian term of AudioFormat.
      • audioSystem

        protected final T extends AudioSystem audioSystem
        The AudioSystem which provides the playback device used by this Renderer.
    • Constructor Detail

      • AbstractAudioRenderer

        protected AbstractAudioRenderer​(T audioSystem)
        Initializes a new AbstractAudioRenderer instance which is to use playback devices provided by a specific AudioSystem.
        Parameters:
        audioSystem - the AudioSystem which is to provide the playback devices to be used by the new instance
      • AbstractAudioRenderer

        protected AbstractAudioRenderer​(T audioSystem,
                                        AudioSystem.DataFlow dataFlow)
        Initializes a new AbstractAudioRenderer instance which is to use notification or playback (as determined by dataFlow) devices provided by a specific AudioSystem.
        Parameters:
        audioSystem - the AudioSystem which is to provide the notification or playback devices to be used by the new instance
        dataFlow - the flow of the media data to be implemented by the new instance i.e. whether notification or playback devices provided by the specified audioSystem are to be used by the new instance. Must be either AudioSystem.DataFlow.NOTIFY or AudioSystem.DataFlow.PLAYBACK.
        Throws:
        IllegalArgumentException - if the specified dataFlow is neither AudioSystem.DataFlow.NOTIFY nor AudioSystem.DataFlow.PLAYBACK
      • AbstractAudioRenderer

        protected AbstractAudioRenderer​(String locatorProtocol)
        Initializes a new AbstractAudioRenderer instance which is to use playback devices provided by an AudioSystem specified by the protocol of the MediaLocators of the CaptureDeviceInfos registered by the AudioSystem.
        Parameters:
        locatorProtocol - the protocol of the MediaLocators of the CaptureDeviceInfo registered by the AudioSystem which is to provide the playback devices to be used by the new instance
      • AbstractAudioRenderer

        protected AbstractAudioRenderer​(String locatorProtocol,
                                        AudioSystem.DataFlow dataFlow)
        Initializes a new AbstractAudioRenderer instance which is to use notification or playback devices provided by an AudioSystem specified by the protocol of the MediaLocators of the CaptureDeviceInfos registered by the AudioSystem.
        Parameters:
        locatorProtocol - the protocol of the MediaLocators of the CaptureDeviceInfo registered by the AudioSystem which is to provide the notification or playback devices to be used by the new instance
        dataFlow - the flow of the media data to be implemented by the new instance i.e. whether notification or playback devices provided by the specified audioSystem are to be used by the new instance. Must be either AudioSystem.DataFlow.NOTIFY or AudioSystem.DataFlow.PLAYBACK.
        Throws:
        IllegalArgumentException - if the specified dataFlow is neither AudioSystem.DataFlow.NOTIFY nor AudioSystem.DataFlow.PLAYBACK
    • Method Detail

      • close

        public void close()
      • getControls

        public Object[] getControls()
        Implements Controls.getControls(). Gets the available controls over this instance. AbstractAudioRenderer returns a GainControl if available.
        Specified by:
        getControls in interface javax.media.Controls
        Overrides:
        getControls in class ControlsAdapter
        Returns:
        an array of Objects which represent the available controls over this instance
      • getGainControl

        protected javax.media.GainControl getGainControl()
        Gets the GainControl, if any, which controls the volume level of the audio (to be) played back by this Renderer.
        Returns:
        the GainControl, if any, which controls the volume level of the audio (to be) played back by this Renderer
      • getLocator

        public javax.media.MediaLocator getLocator()
        Gets the MediaLocator which specifies the playback device to be used by this Renderer.
        Returns:
        the MediaLocator which specifies the playback device to be used by this Renderer
      • getSupportedInputFormats

        public javax.media.Format[] getSupportedInputFormats()
      • open

        public void open()
                  throws javax.media.ResourceUnavailableException
        Throws:
        javax.media.ResourceUnavailableException
      • playbackDevicePropertyChange

        protected void playbackDevicePropertyChange​(PropertyChangeEvent ev)
        Notifies this instance that the value of the property of audioSystem which identifies the default notification or playback (as determined by dataFlow) device has changed. The default implementation does nothing so extenders may safely not call back to their AbstractAudioRenderer super.
        Parameters:
        ev - a PropertyChangeEvent which specifies details about the change such as the name of the property and its old and new values
      • setLocator

        public void setLocator​(javax.media.MediaLocator locator)
        Sets the MediaLocator which specifies the playback device to be used by this Renderer.
        Parameters:
        locator - the MediaLocator which specifies the playback device to be used by this Renderer
      • setVolumeControl

        public void setVolumeControl​(VolumeControl volumeControl)
        Sets the VolumeControl which is to control the volume (level) of the audio (to be) played back by this Renderer.
        Parameters:
        volumeControl - the VolumeControl which is to control the volume (level) of the audio (to be) played back by this Renderer
      • useAudioThreadPriority

        public static void useAudioThreadPriority()
        Changes the priority of the current thread to a value which is considered appropriate for the purposes of audio processing.