Package org.jitsi.impl.neomedia.device
Class PulseAudioSystem
- java.lang.Object
-
- org.jitsi.utils.event.PropertyChangeNotifier
-
- org.jitsi.impl.neomedia.device.DeviceSystem
-
- org.jitsi.impl.neomedia.device.AudioSystem
-
- org.jitsi.impl.neomedia.device.PulseAudioSystem
-
public class PulseAudioSystem extends AudioSystem
Implements an AudioSystem using the native PulseAudio API/library.- Author:
- Lyubomir Marinov
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jitsi.impl.neomedia.device.AudioSystem
AudioSystem.DataFlow
-
-
Field Summary
Fields Modifier and Type Field Description static StringMEDIA_ROLE_EVENTThe PulseAudio logic role of media which represents an event, notification.static StringMEDIA_ROLE_PHONEThe PulseAudio logic role of media which represents telephony call audio.-
Fields inherited from class org.jitsi.impl.neomedia.device.AudioSystem
FEATURE_AGC, FEATURE_DENOISE, FEATURE_ECHO_CANCELLATION, FEATURE_NOTIFY_AND_PLAYBACK_DEVICES, LOCATOR_PROTOCOL_AUDIORECORD, LOCATOR_PROTOCOL_AUDIOSILENCE, LOCATOR_PROTOCOL_JAVASOUND, LOCATOR_PROTOCOL_MACCOREAUDIO, LOCATOR_PROTOCOL_OPENSLES, LOCATOR_PROTOCOL_PORTAUDIO, LOCATOR_PROTOCOL_PULSEAUDIO, LOCATOR_PROTOCOL_WASAPI, PNAME_DENOISE, PNAME_ECHOCANCEL
-
Fields inherited from class org.jitsi.impl.neomedia.device.DeviceSystem
FEATURE_REINITIALIZE, LOCATOR_PROTOCOL_ANDROIDCAMERA, LOCATOR_PROTOCOL_CIVIL, LOCATOR_PROTOCOL_DIRECTSHOW, LOCATOR_PROTOCOL_IMGSTREAMING, LOCATOR_PROTOCOL_MEDIARECORDER, LOCATOR_PROTOCOL_QUICKTIME, LOCATOR_PROTOCOL_VIDEO4LINUX2, PROP_DEVICES
-
-
Constructor Summary
Constructors Constructor Description PulseAudioSystem()Initializes a new PulseAudioSystem instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcorkStream(long stream, boolean b)Pause or resume the playback of a specific PulseAudio stream temporarily.javax.media.RenderercreateRenderer(boolean playback)Initializes a new Renderer instance which is to either perform playback on or sound a notification through a device contributed by this system.longcreateStream(int sampleRate, int channels, String mediaName, String mediaRole)Initializes a new PulseAudio stream which is to input or output audio at a specific sample rate and with a specific number of channels.protected voiddoInitialize()Invoked byDeviceSystem.initialize()to perform the very logic of the initialization of this DeviceSystem.longgetContext()Returns the connection context for asynchronous communication with the PulseAudio server.static PulseAudioSystemgetPulseAudioSystem()Returns the one and only instance of PulseAudioSystem known to the AudioSystem framework.voidlockMainloop()Locks the PulseAudio event loop object associated with this PulseAudioSystem, effectively blocking the PulseAudio event loop thread from processing events.voidsignalMainloop(boolean waitForAccept)Signals all threads waiting for a signalling event inwaitMainloop().StringtoString()Returns a human-readable String representation of this PulseAudioSystem.voidunlockMainloop()Unlocks the PulseAudio event look object associated with this PulseAudioSystem, inverse oflockMainloop().intwaitForStreamState(long stream, int stateToWaitFor)Waits for a specific PulseAudio stream to get into a specific state, PA_STREAM_FAILED, or PA_STREAM_TERMINATED.voidwaitMainloop()Wait for an event to be signalled by the PulseAudio event loop thread associated with this PulseAudioSystem.-
Methods inherited from class org.jitsi.impl.neomedia.device.AudioSystem
createRenderer, getAudioInputStream, getAudioSystem, getAudioSystems, getDevice, getDevices, getFormat, getPropertyName, getSelectedDevice, isAutomaticGainControl, isDenoise, isEchoCancel, postInitialize, postInitializeSpecificDevices, preInitialize, setAutomaticGainControl, setCaptureDevices, setDenoise, setDevice, setEchoCancel, setPlaybackDevices
-
Methods inherited from class org.jitsi.impl.neomedia.device.DeviceSystem
filterDeviceListByLocatorProtocol, getDeviceSystems, getFeatures, getFormat, getLocatorProtocol, getMediaType, getRendererClassName, initialize, initializeDeviceSystems, initializeDeviceSystems
-
-
-
-
Field Detail
-
MEDIA_ROLE_EVENT
public static final String MEDIA_ROLE_EVENT
The PulseAudio logic role of media which represents an event, notification.- See Also:
- Constant Field Values
-
MEDIA_ROLE_PHONE
public static final String MEDIA_ROLE_PHONE
The PulseAudio logic role of media which represents telephony call audio.- See Also:
- Constant Field Values
-
-
Method Detail
-
corkStream
public static void corkStream(long stream, boolean b) throws IOExceptionPause or resume the playback of a specific PulseAudio stream temporarily.- Parameters:
stream- the PulseAudio stream to pause or resume the playback ofb- true to pause or false to resume the playback of the specified stream- Throws:
IOException
-
getPulseAudioSystem
public static PulseAudioSystem getPulseAudioSystem()
Returns the one and only instance of PulseAudioSystem known to the AudioSystem framework.- Returns:
- the one and only instance of PulseAudioSystem known to the AudioSystem framework or null if no such system is known to the AudioSystem framework
-
createRenderer
public javax.media.Renderer createRenderer(boolean playback)
Initializes a new Renderer instance which is to either perform playback on or sound a notification through a device contributed by this system. The (default) implementation of AudioSystem ignores the value of the playback argument and delegates toDeviceSystem.createRenderer(). Overrides the implementation provided by AudioSystem because the PulseAudio Renderer implementation does not follow the convention of AudioSystem.- Overrides:
createRendererin classAudioSystem- Parameters:
playback- true if the new instance is to perform playback or false if the new instance is to sound a notification- Returns:
- a new Renderer instance which is to either perform playback on or sound a notification through a device contributed by this system
-
createStream
public long createStream(int sampleRate, int channels, String mediaName, String mediaRole) throws RuntimeExceptionInitializes a new PulseAudio stream which is to input or output audio at a specific sample rate and with a specific number of channels. The new audio stream is to be associated with a specific human-readable name and is to have a specific PulseAudio logic role.- Parameters:
sampleRate- the sample rate at which the new PulseAudio stream is to input or outputchannels- the number of channels of the audio to be input or output by the new PulseAudio streammediaName- the human-readable name of the new PulseAudio streammediaRole- the PulseAudio logic role of the new stream- Returns:
- a new PulseAudio stream which is to input or output audio at the specified sampleRate, with the specified number of channels, to be associated with the specified human-readable mediaName, and have the specified PulseAudio logic mediaRole
- Throws:
RuntimeException
-
doInitialize
protected void doInitialize() throws ExceptionInvoked byDeviceSystem.initialize()to perform the very logic of the initialization of this DeviceSystem. This instance has been prepared for initialization by an earlier call toDeviceSystem.preInitialize()and the initialization will be completed with a subsequent call toDeviceSystem.postInitialize().- Specified by:
doInitializein classDeviceSystem- Throws:
Exception- if an error occurs during the initialization of this instance. The initialization of this instance will be completed with a subsequent call to postInitialize() regardless of any Exception thrown by doInitialize().
-
getContext
public long getContext()
Returns the connection context for asynchronous communication with the PulseAudio server. If such a context does not exist, it is created.- Returns:
- the connection context for asynchronous communication with the PulseAudio server
-
lockMainloop
public void lockMainloop()
Locks the PulseAudio event loop object associated with this PulseAudioSystem, effectively blocking the PulseAudio event loop thread from processing events. May be used to enforce exclusive access to all PulseAudio objects attached to the PulseAudio event loop. The lock is recursive. The method may not be called inside the PulseAudio event loop thread. Events that are dispatched from the PulseAudio event loop thread are executed with the lock held.
-
signalMainloop
public void signalMainloop(boolean waitForAccept)
Signals all threads waiting for a signalling event inwaitMainloop().- Parameters:
waitForAccept- true to not return before the signal is accepted by a pa_threaded_mainloop_accept(); otherwise, false
-
toString
public String toString()
Returns a human-readable String representation of this PulseAudioSystem. Always returns "PulseAudio".- Overrides:
toStringin classDeviceSystem- Returns:
- "PulseAudio" as a human-readable String representation of this PulseAudioSystem
-
unlockMainloop
public void unlockMainloop()
Unlocks the PulseAudio event look object associated with this PulseAudioSystem, inverse oflockMainloop().
-
waitForStreamState
public int waitForStreamState(long stream, int stateToWaitFor)Waits for a specific PulseAudio stream to get into a specific state, PA_STREAM_FAILED, or PA_STREAM_TERMINATED.- Parameters:
stream- the PulseAudio stream to wait forstateToWaitFor- the PulseAudio state of the specified stream to wait for- Returns:
- the state of the specified stream which caused the method to return
-
waitMainloop
public void waitMainloop()
Wait for an event to be signalled by the PulseAudio event loop thread associated with this PulseAudioSystem.
-
-