| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jack4j.JackClient
public abstract class JackClient
Client of Jack daemon.
 The Java callback methods defined in this class (such as
 process(int), xRunCallback() etc.) will only work if
 both default native JackThreadInit callback and the default native callback
 for the event are set. For example, the process(int)
 method is called only if you call setDefaultThreadInitCallback() and
 setDefaultProcessCallback() before activating the client.
 
 
 See setAllDefaultCallbacks() if you want to set all native callbacks
 at once.
 
 
 Most methods correspond to functions defined in Jack library, except for
 localPort(String) and friends, that work with the internal Java
 structure.
| Constructor Summary | |
|---|---|
JackClient(java.lang.String clientName,
           boolean useExactName,
           boolean canStartServer,
           java.lang.String serverName)
Creates new, inactive Jack client.  | 
|
| Method Summary | |
|---|---|
 void | 
activate()
Activates the client.  | 
 JackLocalPort | 
addAudioPort(java.lang.String portName,
             java.util.Collection<JackPortFlag> flags)
Registers new port of standard audio type.  | 
 JackLocalMidiPort | 
addMidiPort(java.lang.String portName,
            java.util.Collection<JackPortFlag> flags)
Registers new port of standard MIDI type.  | 
 JackLocalPort | 
addPort(java.lang.String portName,
        java.util.Collection<JackPortFlag> flags,
        java.lang.String portType,
        int bufferSize)
Registers new port.  | 
abstract  int | 
bufferSizeCallback(int newBufferSize)
Called when Jack buffer size changes.  | 
abstract  void | 
clientRegistrationCallback(java.lang.String clientName,
                           boolean registered)
Called when another Jack client is registered/unregistered.  | 
 void | 
close()
Closes the client.  | 
 boolean | 
connect(java.lang.String sourcePortName,
        java.lang.String destinationPortName)
Establish a connection between two ports.  | 
 float | 
cpuLoad()
Returns current CPU load.  | 
 void | 
deactivate()
Deactivates the client.  | 
 void | 
disconnect(java.lang.String sourcePortName,
           java.lang.String destinationPortName)
Remove a connection between two ports.  | 
protected  void | 
finalize()
 | 
 int | 
framesSinceCycleStart()
Returns time in frames since Jack server began the current process cycle.  | 
 long | 
framesToTime(int frameTime)
Converts time in microseconds to frame time.  | 
 int | 
frameTime()
Returns current frame time (running counter).  | 
abstract  void | 
freewheelCallback(boolean onoff)
Called when Jack enters or leaves "freewheel" mode.  | 
 java.lang.String[] | 
getAllPortConnections(JackPort port)
Returns full port names of to which the specified port is connected.  | 
 int | 
getBufferSize()
Returns buffer size.  | 
 long | 
getCallbackStruct()
Returns the pointer to C structure that can be used by native Jack callbacks.  | 
 long | 
getClientHandle()
Returns the pointer to C jack_client_t structure,
 represented as long. | 
 java.lang.String | 
getClientName()
Returns real client name (which may be different than the one specified in constructor).  | 
 JackClientThread | 
getClientThread()
Returns the object that allows operations on client thread.  | 
 java.lang.String[] | 
getPorts(java.lang.String portNamePattern,
         java.lang.String typeNamePattern,
         java.util.EnumSet<JackPortFlag> flagSet)
Returns names of ports that fulfill given criteria.  | 
 java.lang.String[] | 
getPorts(java.lang.String portNamePattern,
         java.lang.String typeNamePattern,
         long flags)
Returns names of ports that fulfill given criteria.  | 
 int | 
getSampleRate()
Returns current sample rate.  | 
 Statistics | 
getStatistics()
Returns the Statistics object associated with this client. | 
 int | 
getTotalPortLatency(JackPort port)
Returns port total latency.  | 
abstract  int | 
graphOrderCallback()
Called whenever the processing graph is reordered.  | 
 JackInternalClient | 
internalClientByName(java.lang.String clientName)
Returns an object that represents internal client with specified name.  | 
 boolean | 
isActive()
Returns true if the client was activated  | 
 boolean | 
isMine(JackPort port)
Returns true if the specified port is owned by this client.  | 
 boolean | 
isOpen()
Returns true if the client is still open.  | 
 boolean | 
isProcessMethodSynchronized()
Returns a value indicating whether the native process callback will obtain a lock on JackClient structure before calling process(int) method. | 
 boolean | 
isRealtime()
Returns true if the server runs in real-time mode.  | 
 boolean | 
isShutdown()
Returns true if the Jack client thread was shut down.  | 
 int | 
lastFrameTime()
Returns frame time after the last processing of the graph.  | 
 JackInternalClient | 
loadInternalClient(java.lang.String clientName,
                   boolean useExactName,
                   java.lang.String sharedObjectName,
                   java.lang.String initValue)
Loads internal client.  | 
 JackLocalPort | 
localPort(java.lang.String name)
Returns port registered under given (short) name, or null if such port doesn't exist.  | 
 java.util.Set<java.lang.String> | 
localPortNames()
Returns unmodifiable set of (short) names of ports registered by this client.  | 
 JackPort | 
portById(long id)
Returns (local or foreign) port with given ID, or null if it doesn't exist.  | 
 JackPort | 
portByName(java.lang.String name)
Returns (local or foreign) port with given name, or null if it doesn't exist.  | 
abstract  void | 
portConnectCallback(long portAId,
                    long portBId,
                    boolean connected)
CURRENTLY NOT WORKING.  | 
abstract  void | 
portRegistrationCallback(long portId,
                         boolean registered)
Called when Jack port is registered/unregistered.  | 
abstract  int | 
process(int bufferSize)
Called during each process cycle.  | 
 void | 
recomputeTotalLatencies()
Recomputes port latencies.  | 
 void | 
recomputeTotalPortLatency(JackPort port)
Recomputes port latency.  | 
 void | 
removePort(java.lang.String portName)
Unregisters given port.  | 
 void | 
requestPortMonitorByName(java.lang.String portName,
                         boolean on)
If the port can be monitored, sets monitoring on or off.  | 
abstract  int | 
sampleRateCallback(int newSampleRate)
Called when Jack sample rate changes.  | 
 void | 
setAllDefaultCallbacks()
Sets all available default native callbacks.  | 
 void | 
setBufferSize(int bufferSize)
Sets buffer size used by Jack server.  | 
 void | 
setBufferSizeCallback(long pointer,
                      long arg)
Sets custom JackBufferSizeCallback for this client.  | 
 void | 
setClientRegistrationCallback(long pointer,
                              long arg)
Sets custom JackClientRegistrationCallback for this client.  | 
 void | 
setDefaultBufferSizeCallback()
Sets the default native JackBufferSizeCallback for this client.  | 
 void | 
setDefaultClientRegistrationCallback()
Sets the default native JackClientRegistrationCallback for this client.  | 
 void | 
setDefaultFreewheelCallback()
Sets the default native JackFreewheelCallback for this client.  | 
 void | 
setDefaultGraphOrderCallback()
Sets the default native JackGraphOrderCallback for this client.  | 
 void | 
setDefaultPortConnectCallback()
Sets the default native JackPortConnectCallback for this client.  | 
 void | 
setDefaultPortRegistrationCallback()
Sets the default native JackPortRegistrationCallback for this client.  | 
 void | 
setDefaultProcessCallback()
Sets the default native JackProcessCallback for this client.  | 
 void | 
setDefaultSampleRateCallback()
Sets the default native JackSampleRateCallback for this client.  | 
 void | 
setDefaultShutdownCallback()
Sets the default "on shutdown" callback for this client.  | 
 void | 
setDefaultThreadInitCallback()
Sets the default native JackThreadInitCallback for this client.  | 
 void | 
setDefaultXRunCallback()
Sets the default native JackXRunCallback for this client.  | 
 void | 
setFreewheel(boolean onoff)
Starts or stops Jack "freewheel" mode.  | 
 void | 
setFreewheelCallback(long pointer,
                     long arg)
Sets custom JackFreewheelCallback for this client.  | 
 void | 
setGraphOrderCallback(long pointer,
                      long arg)
Sets custom JackGraphOrderCallback for this client.  | 
 void | 
setPortConnectCallback(long pointer,
                       long arg)
Sets custom JackPortConnectCallback for this client.  | 
 void | 
setPortRegistrationCallback(long pointer,
                            long arg)
Sets custom JackPortRegistrationCallback for this client.  | 
 void | 
setProcessCallback(long pointer,
                   long arg)
Sets custom JackProcessCallback for this client.  | 
 boolean | 
setProcessMethodSynchronized(boolean synchronize)
Sets a flag indicating whether the native process callback will obtain a lock on JackClient structure before calling process(int) method. | 
 void | 
setSampleRateCallback(long pointer,
                      long arg)
Sets custom JackSampleRateCallback for this client.  | 
 void | 
setShutdownCallback(long pointer,
                    long arg)
Sets custom "on shutdown" callback for this client.  | 
 void | 
setThreadInitCallback(long pointer,
                      long arg)
Sets custom JackThreadInitCallback for this client.  | 
 void | 
setXRunCallback(long pointer,
                long arg)
Sets custom JackXRunCallback for this client.  | 
abstract  void | 
threadInitCallback()
Called once, when Jack server initializes client thread.  | 
 int | 
threadWait(int status)
Calls jack_thread_wait. | 
 long | 
time()
Returns current time in microseconds.  | 
 int | 
timeToFrames(long microseconds)
Converts time in microseconds to frame time.  | 
abstract  int | 
xRunCallback()
Called when Jack XRUN occurs.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public JackClient(java.lang.String clientName,
                  boolean useExactName,
                  boolean canStartServer,
                  java.lang.String serverName)
           throws JackException
clientName - desired client nameuseExactName - if true, server won't modify the client name and exception is
            thrown if client with that name already existscanStartServer - if true, the server will be started unless it's already
            runningserverName - if not null, connects to specified server; otherwise, connects
            to default server
JackException - if communication with the server fails| Method Detail | 
|---|
protected void finalize()
                 throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.ThrowableObject.finalize()public boolean isProcessMethodSynchronized()
process(int) method.
public boolean setProcessMethodSynchronized(boolean synchronize)
process(int) method.
 
 
 If the flag is set, the process method behaves as a
 synchronized method.
public long getClientHandle()
jack_client_t structure,
 represented as long.
public long getCallbackStruct()
 The pointer is represented as long value.
public void setDefaultShutdownCallback()
                                throws JackException
JackException
public void setShutdownCallback(long pointer,
                                long arg)
                         throws JackException
 The pointer must be a native
 void(*)(void *arg) pointer, represented as
 long.
pointer - the pointer to native functionarg - the value passed as void* arg parameter to the
            callback
JackExceptionsetDefaultShutdownCallback()
public void setDefaultProcessCallback()
                               throws JackException
JackException
public void setProcessCallback(long pointer,
                               long arg)
                        throws JackException
 The pointer must be a native
 JackProcessCallback pointer, represented as
 long.
pointer - the pointer to native functionarg - the value passed as void* arg parameter to the
            callback
JackExceptionsetDefaultProcessCallback()
public void setDefaultThreadInitCallback()
                                  throws JackException
This callback must be set, otherwise the other callbacks will not work correctly!
JackException
public void setThreadInitCallback(long pointer,
                                  long arg)
                           throws JackException
 The pointer must be a native
 JackThreadInitCallback pointer, represented as
 long.
pointer - the pointer to native functionarg - the value passed as void* arg parameter to the
            callback
JackExceptionsetDefaultThreadInitCallback()
public void setDefaultFreewheelCallback()
                                 throws JackException
JackException
public void setFreewheelCallback(long pointer,
                                 long arg)
                          throws JackException
 The pointer must be a native
 JackFreewheelCallback pointer, represented as
 long.
pointer - the pointer to native functionarg - the value passed as void* arg parameter to the
            callback
JackExceptionsetDefaultFreewheelCallback()
public void setDefaultBufferSizeCallback()
                                  throws JackException
JackException
public void setBufferSizeCallback(long pointer,
                                  long arg)
                           throws JackException
 The pointer must be a native
 JackBufferSizeCallback pointer, represented as
 long.
pointer - the pointer to native functionarg - the value passed as void* arg parameter to the
            callback
JackExceptionsetDefaultBufferSizeCallback()
public void setDefaultSampleRateCallback()
                                  throws JackException
JackException
public void setSampleRateCallback(long pointer,
                                  long arg)
                           throws JackException
 The pointer must be a native
 JackSampleRateCallback pointer, represented as
 long.
pointer - the pointer to native functionarg - the value passed as void* arg parameter to the
            callback
JackExceptionsetDefaultSampleRateCallback()
public void setDefaultClientRegistrationCallback()
                                          throws JackException
JackException
public void setClientRegistrationCallback(long pointer,
                                          long arg)
                                   throws JackException
 The pointer must be a native
 JackClientRegistrationCallback pointer, represented as
 long.
pointer - the pointer to native functionarg - the value passed as void* arg parameter to the
            callback
JackExceptionsetDefaultClientRegistrationCallback()
public void setDefaultPortRegistrationCallback()
                                        throws JackException
JackException
public void setPortRegistrationCallback(long pointer,
                                        long arg)
                                 throws JackException
 The pointer must be a native
 JackPortRegistrationCallback pointer, represented as
 long.
pointer - the pointer to native functionarg - the value passed as void* arg parameter to the
            callback
JackExceptionsetDefaultPortRegistrationCallback()
public void setDefaultPortConnectCallback()
                                   throws JackException
JackException
public void setPortConnectCallback(long pointer,
                                   long arg)
                            throws JackException
 The pointer must be a native
 JackPortConnectCallback pointer, represented as
 long.
pointer - the pointer to native functionarg - the value passed as void* arg parameter to the
            callback
JackExceptionsetDefaultPortConnectCallback()
public void setDefaultGraphOrderCallback()
                                  throws JackException
JackException
public void setGraphOrderCallback(long pointer,
                                  long arg)
                           throws JackException
 The pointer must be a native
 JackGraphOrderCallback pointer, represented as
 long.
pointer - the pointer to native functionarg - the value passed as void* arg parameter to the
            callback
JackExceptionsetDefaultGraphOrderCallback()
public void setDefaultXRunCallback()
                            throws JackException
JackException
public void setXRunCallback(long pointer,
                            long arg)
                     throws JackException
 The pointer must be a native JackXRunCallback
 pointer, represented as long.
pointer - the pointer to native functionarg - the value passed as void* arg parameter to the
            callback
JackExceptionsetDefaultXRunCallback()
public void setAllDefaultCallbacks()
                            throws JackException
 The Java callback methods (such as process(int)) will only work
 if the default native callback is set for thread initialization and for
 the corresponding event. It's recommended to call this method to set all
 those native callbacks at once.
 
 
This method currently doesn't set the JackPortConnectCallback, because using that callback causes buggy behavior of Jackd 0.109.2.
JackExceptionpublic boolean isOpen()
public java.lang.String getClientName()
                               throws JackException
JackException
public void close()
           throws JackException
The client is completely unusable after this call.
JackException
public boolean isRealtime()
                   throws JackException
JackExceptionpublic boolean isActive()
public void activate()
              throws JackException
JackException
public void deactivate()
                throws JackException
JackExceptionpublic boolean isShutdown()
 This method only works if the correct "on shutdown" callback was set,
 preferably using setDefaultShutdownCallback().
public int threadWait(int status)
               throws JackException
jack_thread_wait.
JackException
public void setFreewheel(boolean onoff)
                  throws JackException
JackException
public void setBufferSize(int bufferSize)
                   throws JackException
This can cause audio gap.
java.lang.IllegalArgumentException - if the bufferSize is not a power of two
JackException - if jack_set_buffer_size fails
public int getBufferSize()
                  throws JackException
 Should only be used before activate(). If you want to
 monitor buffer size changes, see bufferSizeCallback(int).
JackException
public int getSampleRate()
                  throws JackException
JackException
public JackLocalPort addPort(java.lang.String portName,
                             java.util.Collection<JackPortFlag> flags,
                             java.lang.String portType,
                             int bufferSize)
                      throws JackException
 Tip: you can to use EnumSet as flags parameter.
portName - short name of the new portflags - set of port flagsportType - port type, currently only built-ins
            JackConstants.JACK_DEFAULT_AUDIO_TYPE() and
            JackConstants.JACK_DEFAULT_MIDI_TYPE() are allowedbufferSize - must be non-zero for non-standard portType, otherwise is
            ignored
JackException - if port registration fails
public JackLocalPort addAudioPort(java.lang.String portName,
                                  java.util.Collection<JackPortFlag> flags)
                           throws JackException
 Calls addPort(String, Collection, String, int) with portType set
 to JackConstants.JACK_DEFAULT_AUDIO_TYPE() and bufferSize set to
 0.
JackException
public JackLocalMidiPort addMidiPort(java.lang.String portName,
                                     java.util.Collection<JackPortFlag> flags)
                              throws JackException
 Calls addPort(String, Collection, String, int) with portType set
 to JackConstants.JACK_DEFAULT_MIDI_TYPE() and bufferSize set to
 0.
JackExceptionpublic java.util.Set<java.lang.String> localPortNames()
The returned set will reflect changes (adding/removing ports), but cannot be modified with Set methods.
public JackLocalPort localPort(java.lang.String name)
Note that this method ignores aliases given to the ports.
public void removePort(java.lang.String portName)
                throws JackException
 The corresponding JackPort instance will be unusable after this
 call.
java.lang.IllegalArgumentException - if port with given name doesn't exist
JackException - if the port couldn't be unregistered
public JackPort portByName(java.lang.String name)
                    throws JackException
 Note that the returned instance is not of type
 JackLocalPort, even if the port belongs to this client. See
 localPort(String) method if you want to get JackLocalPort
 instance.
name - in the form 'client_name:form_name'
JackException
public JackPort portById(long id)
                  throws JackException
 It seems that the only place where this method is currently usable are
 some of the callbacks, namely
 portRegistrationCallback(long, boolean) and
 portConnectCallback(long, long, boolean).
 
 
 Note that the returned instance is not of type
 JackLocalPort, even if the port belongs to this client. See
 localPort(String) method if you want to get JackLocalPort
 instance.
id - unique ID of the port
JackException
public java.lang.String[] getPorts(java.lang.String portNamePattern,
                                   java.lang.String typeNamePattern,
                                   java.util.EnumSet<JackPortFlag> flagSet)
portNamePattern - regex used to select ports by name; this parameter is ignored
            if it's null or empty stringtypeNamePattern - regex used to select ports by type; this parameter is ignored
            if it's null or empty stringflagSet - required port flags; this parameter is ignored if it's null
public java.lang.String[] getPorts(java.lang.String portNamePattern,
                                   java.lang.String typeNamePattern,
                                   long flags)
portNamePattern - regex used to select ports by name; this parameter is ignored
            if it's null or empty stringtypeNamePattern - regex used to select ports by type; this parameter is ignored
            if it's null or empty stringflags - required port flags; this parameter is ignored if it's zero
public boolean connect(java.lang.String sourcePortName,
                       java.lang.String destinationPortName)
                throws JackException
The port types must be identical, the source port must be an output port, and the destination port must be an input port.
The ports need not to belong to this client.
sourcePortName - long name of source portdestinationPortName - long name of destination port
JackException - if the connection can't be established
public void disconnect(java.lang.String sourcePortName,
                       java.lang.String destinationPortName)
                throws JackException
The port types must be identical, the source port must be an output port, and the destination port must be an input port.
The ports need not to belong to this client.
sourcePortName - long name of source portdestinationPortName - long name of destination port
JackException - if the connection can't be established
public java.lang.String[] getAllPortConnections(JackPort port)
                                         throws JackException
JackLocalPort.getConnections() in two important
 respects:
 
JackException
public boolean isMine(JackPort port)
               throws JackException
JackException
public void recomputeTotalLatencies()
                             throws JackException
JackException
public void recomputeTotalPortLatency(JackPort port)
                               throws JackException
JackException
public int getTotalPortLatency(JackPort port)
                        throws JackException
JackException
public void requestPortMonitorByName(java.lang.String portName,
                                     boolean on)
                              throws JackException
JackExceptionpublic int framesSinceCycleStart()
public int frameTime()
public int lastFrameTime()
 This method should only be called from process(int) callback.
public int timeToFrames(long microseconds)
public long framesToTime(int frameTime)
public long time()
public float cpuLoad()
public Statistics getStatistics()
Statistics object associated with this client.
public JackClientThread getClientThread()
Returns null if the thread wasn't created yet.
 The setDefaultThreadInitCallback() must be used, otherwise this
 method always returns null.
public JackInternalClient loadInternalClient(java.lang.String clientName,
                                             boolean useExactName,
                                             java.lang.String sharedObjectName,
                                             java.lang.String initValue)
                                      throws JackException
clientName - name of internal clientuseExactName - if set to true, request that the client have exact clientName;
            otherwise, Jack server may generate unique namesharedObjectName - if not null, specifies name of shared library; otherwise,
            clientName is usedinitValue - if not null, this string will be passed to internal client's
            jack_initialize function
JackException
public JackInternalClient internalClientByName(java.lang.String clientName)
                                        throws JackException
JackException - if the client doesn't exist or if other error occurred
public abstract int process(int bufferSize)
                     throws java.lang.Exception
Must return zero on success, non-zero on error. If this method throws an exception, status -1 is returned to the server.
 Normally, this method is not called as synchronized; see
 setProcessMethodSynchronized(boolean).
java.lang.Exception
public abstract void threadInitCallback()
                                 throws java.lang.Exception
Exceptions thrown by this callback are ignored.
java.lang.Exception
public abstract void freewheelCallback(boolean onoff)
                                throws java.lang.Exception
Exceptions thrown by this callback are ignored.
java.lang.Exception
public abstract int bufferSizeCallback(int newBufferSize)
                                throws java.lang.Exception
Must return zero on success, non-zero on error. If this method throws an exception, status -1 is returned to the server.
java.lang.Exception
public abstract int sampleRateCallback(int newSampleRate)
                                throws java.lang.Exception
Must return zero on success, non-zero on error. If this method throws an exception, status -1 is returned to the server.
java.lang.Exception
public abstract void clientRegistrationCallback(java.lang.String clientName,
                                                boolean registered)
                                         throws java.lang.Exception
Exceptions thrown by this callback are ignored.
clientName - name of the other clientregistered - true if the client is registered, false if it's unregistered
java.lang.Exception
public abstract void portRegistrationCallback(long portId,
                                              boolean registered)
                                       throws java.lang.Exception
Exceptions thrown by this callback are ignored.
portId - unique port ID (see portById(long))registered - true if the port is registered, false if it's unregistered
java.lang.Exception
public abstract void portConnectCallback(long portAId,
                                         long portBId,
                                         boolean connected)
                                  throws java.lang.Exception
Exceptions thrown by this callback are ignored.
The Jack API documentation doesn't specify which port is source and which is destination.
portAId - unique ID of one of two ports connected or disconnectedportBId - unique ID of one of two ports connected or disconnectedconnected - true if the connection is established, false if it's removed
java.lang.ExceptionportById(long)
public abstract int graphOrderCallback()
                                throws java.lang.Exception
Must return zero on success, non-zero on error. If this method throws an exception, status -1 is returned to the server.
java.lang.Exception
public abstract int xRunCallback()
                          throws java.lang.Exception
Must return zero on success, non-zero on error. If this method throws an exception, status -1 is returned to the server.
java.lang.Exception
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||