1 package net.sf.jack4j;
2
3 /*
4 Copyright (C) 2008 Ondrej Par
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 */
21
22 import java.util.EnumSet;
23
24 /**
25 * Jack port.
26 *
27 * @author repa
28 *
29 */
30 public class JackPort {
31
32 static {
33 JackBridge.initializeJackBridge();
34 }
35
36 private volatile long portHandle = 0;
37
38 JackPort(long portHandle) {
39 this.portHandle = portHandle;
40 }
41
42 /**
43 * Returns the short name (not including 'client_name:' prefix) of this
44 * port.
45 */
46 public native String getPortShortName() throws JackException;
47
48 /**
49 * Returns the full name (including 'client_name:' prefix) of this port.
50 */
51 public native String getPortName() throws JackException;
52
53 /**
54 * Returns port type.
55 */
56 public native String getPortType() throws JackException;
57
58 /**
59 * Returns true if this is an input port.
60 */
61 public boolean isInput() throws JackException {
62 return (getPortFlags() & JackPortFlag.IS_INPUT.intValue()) != 0;
63 }
64
65 /**
66 * Returns true if this is an output port.
67 */
68 public boolean isOutput() throws JackException {
69 return (getPortFlags() & JackPortFlag.IS_OUTPUT.intValue()) != 0;
70 }
71
72 /**
73 * Returns true if this port is physical.
74 */
75 public boolean isPhysical() throws JackException {
76 return (getPortFlags() & JackPortFlag.IS_PHYSICAL.intValue()) != 0;
77 }
78
79 /**
80 * Returns true if this port can be monitored.
81 */
82 public boolean isMonitorable() throws JackException {
83 return (getPortFlags() & JackPortFlag.CAN_MONITOR.intValue()) != 0;
84 }
85
86 /**
87 * Returns true if this port is terminal.
88 */
89 public boolean isTerminal() throws JackException {
90 return (getPortFlags() & JackPortFlag.IS_TERMINAL.intValue()) != 0;
91 }
92
93 /**
94 * Returns the pointer to C <code>jack_port_t</code> structure,
95 * represented as <code>long</code>.
96 */
97 public long getPortHandle() {
98 return portHandle;
99 }
100
101 /**
102 * Returns current port flags, as reported by Jack API.
103 */
104 public EnumSet<JackPortFlag> getPortFlagSet() throws JackException {
105 return JackPortFlag.decode(getPortFlags());
106 }
107
108 /**
109 * Returns current port flags, packed as int.
110 */
111 public native int getPortFlags() throws JackException;
112
113 /**
114 * Returns port latency.
115 */
116 public native int getLatency() throws JackException;
117
118 /**
119 * Sets port latency.
120 */
121 public native void setLatency(int latency) throws JackException;
122
123 /**
124 * If the port can be monitored, sets monitoring on or off.
125 */
126 public native void requestMonitor(boolean on) throws JackException;
127
128 /**
129 * If the port can be monitored, this method, turns on input monitoring if
130 * it was off, and turns it off if only one request has been made to turn it
131 * on; otherwise, it does nothing.
132 */
133 public native void ensureMonitor(boolean on) throws JackException;
134
135 /**
136 * Returns true if input monitoring was requested for this port.
137 */
138 public native boolean monitoringInput() throws JackException;
139 }