jack-ffi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/GPL3-LICENSE +16 -0
- data/Rakefile +23 -0
- data/VERSION +1 -0
- data/lib/jack.rb +55 -0
- data/lib/jack/client.rb +374 -0
- data/lib/jack/errors.rb +26 -0
- data/lib/jack/port.rb +167 -0
- metadata +86 -0
data/GPL3-LICENSE
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
libjack-ffi-ruby - JACK bindings for ruby via FFI interface
|
2
|
+
|
3
|
+
This program is free software: you can redistribute it and/or modify
|
4
|
+
it under the terms of the GNU General Public License as published by
|
5
|
+
the Free Software Foundation, either version 3 of the License, or
|
6
|
+
(at your option) any later version.
|
7
|
+
|
8
|
+
This program is distributed in the hope that it will be useful,
|
9
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
GNU General Public License for more details.
|
12
|
+
|
13
|
+
You should have received a copy of the GNU General Public License
|
14
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
Author: Marcin Lewandowski <marcin at saepia dot net>
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gemspec|
|
7
|
+
gemspec.name = "jack-ffi"
|
8
|
+
gemspec.summary = "JACK bindings via FFI"
|
9
|
+
gemspec.description = "Jack Audio Connection Kit Bindings via FFI interface"
|
10
|
+
gemspec.email = "marcin@saepia.net"
|
11
|
+
gemspec.homepage = "http://jack-ffi.saepia.net"
|
12
|
+
gemspec.authors = ["Marcin Lewandowski"]
|
13
|
+
|
14
|
+
gemspec.files = FileList['lib/**/*.rb', 'GPL3-LICENSE', 'Rakefile', 'VERSION']
|
15
|
+
gemspec.add_dependency "ffi"
|
16
|
+
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
end
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/lib/jack.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
=begin
|
2
|
+
libjack-ffi-ruby - JACK bindings for ruby via FFI interface
|
3
|
+
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
5
|
+
it under the terms of the GNU General Public License as published by
|
6
|
+
the Free Software Foundation, either version 3 of the License, or
|
7
|
+
(at your option) any later version.
|
8
|
+
|
9
|
+
This program is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
Author: Marcin Lewandowski <marcin at saepia dot net>
|
18
|
+
=end
|
19
|
+
|
20
|
+
require 'ffi'
|
21
|
+
|
22
|
+
module FFI
|
23
|
+
class Pointer
|
24
|
+
def read_array_of_type_until_end(type, reader)
|
25
|
+
ary = []
|
26
|
+
size = FFI.type_size(type)
|
27
|
+
tmp = self
|
28
|
+
loop do
|
29
|
+
last = tmp.send(reader)
|
30
|
+
break if last.null?
|
31
|
+
ary << last
|
32
|
+
tmp += size
|
33
|
+
end
|
34
|
+
ary
|
35
|
+
end
|
36
|
+
|
37
|
+
def read_array_of_pointer_until_end
|
38
|
+
read_array_of_type_until_end :pointer, :read_pointer
|
39
|
+
end
|
40
|
+
|
41
|
+
def read_array_of_string_until_end
|
42
|
+
read_array_of_pointer_until_end.collect { |p| p.read_string }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
module JACK
|
48
|
+
LIB = [ "libjack.so.0.0.28", "libjack.so.0", "libjack.so", "libjack" ]
|
49
|
+
VERSION = "0.0.1"
|
50
|
+
end
|
51
|
+
|
52
|
+
require 'jack/errors'
|
53
|
+
require 'jack/client'
|
54
|
+
require 'jack/port'
|
55
|
+
|
data/lib/jack/client.rb
ADDED
@@ -0,0 +1,374 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of libjack-ffi-ruby.
|
3
|
+
|
4
|
+
libjack-ffi-ruby is free software: you can redistribute it and/or modify
|
5
|
+
it under the terms of the GNU General Public License as published by
|
6
|
+
the Free Software Foundation, either version 3 of the License, or
|
7
|
+
(at your option) any later version.
|
8
|
+
|
9
|
+
libjack-ffi-ruby is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with libjack-ffi-ruby. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
=end
|
17
|
+
|
18
|
+
module JACK
|
19
|
+
class Client
|
20
|
+
extend FFI::Library
|
21
|
+
ffi_lib LIB
|
22
|
+
|
23
|
+
attr_reader :pointer
|
24
|
+
|
25
|
+
def initialize(name, options = 0x00, &b)
|
26
|
+
@name = name
|
27
|
+
@options = options
|
28
|
+
|
29
|
+
status = FFI::MemoryPointer.new :pointer
|
30
|
+
|
31
|
+
@server = jack_client_open name, options, status
|
32
|
+
# TODO return status handling
|
33
|
+
|
34
|
+
if block_given?
|
35
|
+
yield self
|
36
|
+
close
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def close
|
42
|
+
jack_client_close @server
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_ports
|
46
|
+
# TODO checking if i am connected
|
47
|
+
# TODO parameters
|
48
|
+
jack_get_ports(@server, nil, nil, 0).read_array_of_string_until_end
|
49
|
+
end
|
50
|
+
|
51
|
+
def port_by_name(name)
|
52
|
+
port = jack_port_by_name(@server, name)
|
53
|
+
|
54
|
+
raise Errors::NoSuchPortError, "There no such port as #{name}" if port.null?
|
55
|
+
|
56
|
+
Port.new(port, self)
|
57
|
+
end
|
58
|
+
|
59
|
+
def connect(source, destination)
|
60
|
+
change_graph(:connect, source, destination) == 0
|
61
|
+
end
|
62
|
+
|
63
|
+
def disconnect(source, destination)
|
64
|
+
change_graph(:disconnect, source, destination) == 0
|
65
|
+
end
|
66
|
+
|
67
|
+
def change_graph(method, source, destination)
|
68
|
+
raise ArgumentError, "You must pass JACK::Port or String to JACK::Client.port_connect" if not source.is_a? Port and not source.is_a? String and not destination.is_a? Port and not destination.is_a? String
|
69
|
+
|
70
|
+
source = port_by_name(source) if source.is_a? String
|
71
|
+
destination = port_by_name(destination) if destination.is_a? String
|
72
|
+
|
73
|
+
if source.is_input? and destination.is_output?
|
74
|
+
source = destination
|
75
|
+
destination = source
|
76
|
+
elsif source.is_output? and destination.is_input?
|
77
|
+
# Direction ok
|
78
|
+
else
|
79
|
+
raise Errors::InvalidPortsChosenToConnect, "Cannot connect ports #{source} and #{destination} - both are input or output ports"
|
80
|
+
end
|
81
|
+
|
82
|
+
# TODO checking result
|
83
|
+
send("jack_#{method}", @server, source.name, destination.name)
|
84
|
+
end
|
85
|
+
|
86
|
+
protected
|
87
|
+
|
88
|
+
=begin
|
89
|
+
enum JackOptions {
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Null value to use when no option bits are needed.
|
93
|
+
*/
|
94
|
+
JackNullOption = 0x00,
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Do not automatically start the JACK server when it is not
|
98
|
+
* already running. This option is always selected if
|
99
|
+
* \$JACK_NO_START_SERVER is defined in the calling process
|
100
|
+
* environment.
|
101
|
+
*/
|
102
|
+
JackNoStartServer = 0x01,
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Use the exact client name requested. Otherwise, JACK
|
106
|
+
* automatically generates a unique one, if needed.
|
107
|
+
*/
|
108
|
+
JackUseExactName = 0x02,
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Open with optional <em>(char *) server_name</em> parameter.
|
112
|
+
*/
|
113
|
+
JackServerName = 0x04,
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Load internal client from optional <em>(char *)
|
117
|
+
* load_name</em>. Otherwise use the @a client_name.
|
118
|
+
*/
|
119
|
+
JackLoadName = 0x08,
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Pass optional <em>(char *) load_init</em> string to the
|
123
|
+
* jack_initialize() entry point of an internal client.
|
124
|
+
*/
|
125
|
+
JackLoadInit = 0x10
|
126
|
+
};
|
127
|
+
=end
|
128
|
+
enum :options, [ :null_option, 0x00,
|
129
|
+
:no_start_server, 0x01,
|
130
|
+
:use_exact_name, 0x02,
|
131
|
+
:server_name, 0x04,
|
132
|
+
:load_name, 0x08,
|
133
|
+
:load_init, 0x10 ]
|
134
|
+
|
135
|
+
=begin
|
136
|
+
enum JackStatus {
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Overall operation failed.
|
140
|
+
*/
|
141
|
+
JackFailure = 0x01,
|
142
|
+
|
143
|
+
/**
|
144
|
+
* The operation contained an invalid or unsupported option.
|
145
|
+
*/
|
146
|
+
JackInvalidOption = 0x02,
|
147
|
+
|
148
|
+
/**
|
149
|
+
* The desired client name was not unique. With the @ref
|
150
|
+
* JackUseExactName option this situation is fatal. Otherwise,
|
151
|
+
* the name was modified by appending a dash and a two-digit
|
152
|
+
* number in the range "-01" to "-99". The
|
153
|
+
* jack_get_client_name() function will return the exact string
|
154
|
+
* that was used. If the specified @a client_name plus these
|
155
|
+
* extra characters would be too long, the open fails instead.
|
156
|
+
*/
|
157
|
+
JackNameNotUnique = 0x04,
|
158
|
+
|
159
|
+
/**
|
160
|
+
* The JACK server was started as a result of this operation.
|
161
|
+
* Otherwise, it was running already. In either case the caller
|
162
|
+
* is now connected to jackd, so there is no race condition.
|
163
|
+
* When the server shuts down, the client will find out.
|
164
|
+
*/
|
165
|
+
JackServerStarted = 0x08,
|
166
|
+
|
167
|
+
/**
|
168
|
+
* Unable to connect to the JACK server.
|
169
|
+
*/
|
170
|
+
JackServerFailed = 0x10,
|
171
|
+
|
172
|
+
/**
|
173
|
+
* Communication error with the JACK server.
|
174
|
+
*/
|
175
|
+
JackServerError = 0x20,
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Requested client does not exist.
|
179
|
+
*/
|
180
|
+
JackNoSuchClient = 0x40,
|
181
|
+
|
182
|
+
/**
|
183
|
+
* Unable to load internal client
|
184
|
+
*/
|
185
|
+
JackLoadFailure = 0x80,
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Unable to initialize client
|
189
|
+
*/
|
190
|
+
JackInitFailure = 0x100,
|
191
|
+
|
192
|
+
/**
|
193
|
+
* Unable to access shared memory
|
194
|
+
*/
|
195
|
+
JackShmFailure = 0x200,
|
196
|
+
|
197
|
+
/**
|
198
|
+
* Client's protocol version does not match
|
199
|
+
*/
|
200
|
+
JackVersionError = 0x400,
|
201
|
+
|
202
|
+
/*
|
203
|
+
* BackendError
|
204
|
+
*/
|
205
|
+
JackBackendError = 0x800,
|
206
|
+
|
207
|
+
/*
|
208
|
+
* Client is being shutdown against its will
|
209
|
+
*/
|
210
|
+
JackClientZombie = 0x1000
|
211
|
+
};
|
212
|
+
=end
|
213
|
+
|
214
|
+
enum :status, [ :failure, 0x01,
|
215
|
+
:invalid_option, 0x02,
|
216
|
+
:name_not_unique, 0x04,
|
217
|
+
:server_started, 0x08,
|
218
|
+
:server_failed, 0x10,
|
219
|
+
:server_error, 0x20,
|
220
|
+
:no_such_client, 0x40,
|
221
|
+
:load_failure, 0x80,
|
222
|
+
:init_failure, 0x100,
|
223
|
+
:shm_failure, 0x200,
|
224
|
+
:version_error, 0x400,
|
225
|
+
:backend_error, 0x800,
|
226
|
+
:client_zombie, 0x1000 ]
|
227
|
+
=begin
|
228
|
+
/**
|
229
|
+
* Open an external client session with a JACK server. This interface
|
230
|
+
* is more complex but more powerful than jack_client_new(). With it,
|
231
|
+
* clients may choose which of several servers to connect, and control
|
232
|
+
* whether and how to start the server automatically, if it was not
|
233
|
+
* already running. There is also an option for JACK to generate a
|
234
|
+
* unique client name, when necessary.
|
235
|
+
*
|
236
|
+
* @param client_name of at most jack_client_name_size() characters.
|
237
|
+
* The name scope is local to each server. Unless forbidden by the
|
238
|
+
* @ref JackUseExactName option, the server will modify this name to
|
239
|
+
* create a unique variant, if needed.
|
240
|
+
*
|
241
|
+
* @param options formed by OR-ing together @ref JackOptions bits.
|
242
|
+
* Only the @ref JackOpenOptions bits are allowed.
|
243
|
+
*
|
244
|
+
* @param status (if non-NULL) an address for JACK to return
|
245
|
+
* information from the open operation. This status word is formed by
|
246
|
+
* OR-ing together the relevant @ref JackStatus bits.
|
247
|
+
*
|
248
|
+
*
|
249
|
+
* <b>Optional parameters:</b> depending on corresponding [@a options
|
250
|
+
* bits] additional parameters may follow @a status (in this order).
|
251
|
+
*
|
252
|
+
* @arg [@ref JackServerName] <em>(char *) server_name</em> selects
|
253
|
+
* from among several possible concurrent server instances. Server
|
254
|
+
* names are unique to each user. If unspecified, use "default"
|
255
|
+
* unless \$JACK_DEFAULT_SERVER is defined in the process environment.
|
256
|
+
*
|
257
|
+
* @return Opaque client handle if successful. If this is NULL, the
|
258
|
+
* open operation failed, @a *status includes @ref JackFailure and the
|
259
|
+
* caller is not a JACK client.
|
260
|
+
*/
|
261
|
+
jack_client_t *jack_client_open (const char *client_name,
|
262
|
+
jack_options_t options,
|
263
|
+
jack_status_t *status, ...);
|
264
|
+
|
265
|
+
=end
|
266
|
+
attach_function :jack_client_open, [:string, :options, :pointer], :pointer
|
267
|
+
|
268
|
+
|
269
|
+
=begin
|
270
|
+
/**
|
271
|
+
* Disconnects an external client from a JACK server.
|
272
|
+
*
|
273
|
+
* @return 0 on success, otherwise a non-zero error code
|
274
|
+
*/
|
275
|
+
int jack_client_close (jack_client_t *client);
|
276
|
+
=end
|
277
|
+
attach_function :jack_client_close, [:pointer], :int
|
278
|
+
|
279
|
+
=begin
|
280
|
+
/**
|
281
|
+
* @param port_name_pattern A regular expression used to select
|
282
|
+
* ports by name. If NULL or of zero length, no selection based
|
283
|
+
* on name will be carried out.
|
284
|
+
* @param type_name_pattern A regular expression used to select
|
285
|
+
* ports by type. If NULL or of zero length, no selection based
|
286
|
+
* on type will be carried out.
|
287
|
+
* @param flags A value used to select ports by their flags.
|
288
|
+
* If zero, no selection based on flags will be carried out.
|
289
|
+
*
|
290
|
+
* @return a NULL-terminated array of ports that match the specified
|
291
|
+
* arguments. The caller is responsible for calling free(3) any
|
292
|
+
* non-NULL returned value.
|
293
|
+
*
|
294
|
+
* @see jack_port_name_size(), jack_port_type_size()
|
295
|
+
*/
|
296
|
+
const char **jack_get_ports (jack_client_t *,
|
297
|
+
const char *port_name_pattern,
|
298
|
+
const char *type_name_pattern,
|
299
|
+
unsigned long flags);
|
300
|
+
|
301
|
+
=end
|
302
|
+
attach_function :jack_get_ports, [:pointer, :string, :string, :ulong], :pointer
|
303
|
+
|
304
|
+
|
305
|
+
=begin
|
306
|
+
/**
|
307
|
+
* @return address of the jack_port_t named @a port_name.
|
308
|
+
*
|
309
|
+
* @see jack_port_name_size()
|
310
|
+
*/
|
311
|
+
jack_port_t *jack_port_by_name (jack_client_t *, const char *port_name);
|
312
|
+
=end
|
313
|
+
attach_function :jack_port_by_name, [:pointer, :string], :pointer
|
314
|
+
|
315
|
+
=begin
|
316
|
+
/**
|
317
|
+
* Establish a connection between two ports.
|
318
|
+
*
|
319
|
+
* When a connection exists, data written to the source port will
|
320
|
+
* be available to be read at the destination port.
|
321
|
+
*
|
322
|
+
* @pre The port types must be identical.
|
323
|
+
*
|
324
|
+
* @pre The @ref JackPortFlags of the @a source_port must include @ref
|
325
|
+
* JackPortIsOutput.
|
326
|
+
*
|
327
|
+
* @pre The @ref JackPortFlags of the @a destination_port must include
|
328
|
+
* @ref JackPortIsInput.
|
329
|
+
*
|
330
|
+
* @return 0 on success, EEXIST if the connection is already made,
|
331
|
+
* otherwise a non-zero error code
|
332
|
+
*/
|
333
|
+
int jack_connect (jack_client_t *,
|
334
|
+
const char *source_port,
|
335
|
+
const char *destination_port);
|
336
|
+
=end
|
337
|
+
attach_function :jack_connect, [:pointer, :string, :string], :int
|
338
|
+
|
339
|
+
=begin
|
340
|
+
/**
|
341
|
+
* Remove a connection between two ports.
|
342
|
+
*
|
343
|
+
* @pre The port types must be identical.
|
344
|
+
*
|
345
|
+
* @pre The @ref JackPortFlags of the @a source_port must include @ref
|
346
|
+
* JackPortIsOutput.
|
347
|
+
*
|
348
|
+
* @pre The @ref JackPortFlags of the @a destination_port must include
|
349
|
+
* @ref JackPortIsInput.
|
350
|
+
*
|
351
|
+
* @return 0 on success, otherwise a non-zero error code
|
352
|
+
*/
|
353
|
+
int jack_disconnect (jack_client_t *,
|
354
|
+
const char *source_port,
|
355
|
+
const char *destination_port);
|
356
|
+
=end
|
357
|
+
attach_function :jack_disconnect, [:pointer, :string, :string], :int
|
358
|
+
|
359
|
+
=begin
|
360
|
+
/**
|
361
|
+
* Perform the same function as jack_disconnect() using port handles
|
362
|
+
* rather than names. This avoids the name lookup inherent in the
|
363
|
+
* name-based version.
|
364
|
+
*
|
365
|
+
* Clients connecting their own ports are likely to use this function,
|
366
|
+
* while generic connection clients (e.g. patchbays) would use
|
367
|
+
* jack_disconnect().
|
368
|
+
*/
|
369
|
+
int jack_port_disconnect (jack_client_t *, jack_port_t *);
|
370
|
+
=end
|
371
|
+
attach_function :jack_port_disconnect, [:pointer, :pointer], :int
|
372
|
+
|
373
|
+
end
|
374
|
+
end
|
data/lib/jack/errors.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of libjack-ffi-ruby.
|
3
|
+
|
4
|
+
libjack-ffi-ruby is free software: you can redistribute it and/or modify
|
5
|
+
it under the terms of the GNU General Public License as published by
|
6
|
+
the Free Software Foundation, either version 3 of the License, or
|
7
|
+
(at your option) any later version.
|
8
|
+
|
9
|
+
libjack-ffi-ruby is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with libjack-ffi-ruby. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
=end
|
17
|
+
|
18
|
+
module JACK
|
19
|
+
class Errors
|
20
|
+
class NoSuchPortError < Exception
|
21
|
+
end
|
22
|
+
|
23
|
+
class InvalidPortsChosenToConnect < Exception
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/jack/port.rb
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of libjack-ffi-ruby.
|
3
|
+
|
4
|
+
libjack-ffi-ruby is free software: you can redistribute it and/or modify
|
5
|
+
it under the terms of the GNU General Public License as published by
|
6
|
+
the Free Software Foundation, either version 3 of the License, or
|
7
|
+
(at your option) any later version.
|
8
|
+
|
9
|
+
libjack-ffi-ruby is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with libjack-ffi-ruby. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
=end
|
17
|
+
|
18
|
+
module JACK
|
19
|
+
class Port
|
20
|
+
extend FFI::Library
|
21
|
+
ffi_lib LIB
|
22
|
+
|
23
|
+
attr_reader :pointer, :client
|
24
|
+
|
25
|
+
FLAGS_IS_INPUT = 0x1
|
26
|
+
FLAGS_IS_OUTPUT = 0x2
|
27
|
+
FLAGS_IS_PHYSICAL = 0x4
|
28
|
+
FLAGS_CAN_MONITOR = 0x8
|
29
|
+
FLAGS_IS_TERMINAL = 0x10
|
30
|
+
|
31
|
+
def initialize(pointer, client)
|
32
|
+
@pointer, @client = pointer, client
|
33
|
+
end
|
34
|
+
|
35
|
+
def name
|
36
|
+
jack_port_name @pointer
|
37
|
+
end
|
38
|
+
|
39
|
+
def flags
|
40
|
+
jack_port_flags @pointer
|
41
|
+
end
|
42
|
+
|
43
|
+
def connect(destination)
|
44
|
+
raise ArgumentError, "You must pass JACK::Port or String to JACK::Port.connect" if not destination.is_a? Port and not destination.is_a? String
|
45
|
+
destination = client.port_by_name(destination) if destination.is_a? String
|
46
|
+
|
47
|
+
client.connect self, destination
|
48
|
+
end
|
49
|
+
|
50
|
+
def disconnect(destination)
|
51
|
+
raise ArgumentError, "You must pass JACK::Port or String to JACK::Port.disconnect" if not destination.is_a? Port and not destination.is_a? String
|
52
|
+
destination = client.port_by_name(destination) if destination.is_a? String
|
53
|
+
|
54
|
+
client.disconnect self, destination
|
55
|
+
end
|
56
|
+
|
57
|
+
def is_input?
|
58
|
+
flags & FLAGS_IS_INPUT != 0
|
59
|
+
end
|
60
|
+
|
61
|
+
def is_output?
|
62
|
+
flags & FLAGS_IS_OUTPUT != 0
|
63
|
+
end
|
64
|
+
|
65
|
+
def is_physical?
|
66
|
+
flags & FLAGS_IS_PHYSICAL != 0
|
67
|
+
end
|
68
|
+
|
69
|
+
def can_monitor?
|
70
|
+
flags & FLAGS_CAN_MONITOR != 0
|
71
|
+
end
|
72
|
+
|
73
|
+
def is_terminal?
|
74
|
+
flags & FLAGS_IS_TERMINAL != 0
|
75
|
+
end
|
76
|
+
|
77
|
+
def to_s
|
78
|
+
name
|
79
|
+
end
|
80
|
+
|
81
|
+
def inspect
|
82
|
+
"#<#{self.class} name=#{name}>"
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
protected
|
87
|
+
|
88
|
+
=begin
|
89
|
+
enum JackPortFlags {
|
90
|
+
|
91
|
+
/**
|
92
|
+
* if JackPortIsInput is set, then the port can receive
|
93
|
+
* data.
|
94
|
+
*/
|
95
|
+
JackPortIsInput = 0x1,
|
96
|
+
|
97
|
+
/**
|
98
|
+
* if JackPortIsOutput is set, then data can be read from
|
99
|
+
* the port.
|
100
|
+
*/
|
101
|
+
JackPortIsOutput = 0x2,
|
102
|
+
|
103
|
+
/**
|
104
|
+
* if JackPortIsPhysical is set, then the port corresponds
|
105
|
+
* to some kind of physical I/O connector.
|
106
|
+
*/
|
107
|
+
JackPortIsPhysical = 0x4,
|
108
|
+
|
109
|
+
/**
|
110
|
+
* if JackPortCanMonitor is set, then a call to
|
111
|
+
* jack_port_request_monitor() makes sense.
|
112
|
+
*
|
113
|
+
* Precisely what this means is dependent on the client. A typical
|
114
|
+
* result of it being called with TRUE as the second argument is
|
115
|
+
* that data that would be available from an output port (with
|
116
|
+
* JackPortIsPhysical set) is sent to a physical output connector
|
117
|
+
* as well, so that it can be heard/seen/whatever.
|
118
|
+
*
|
119
|
+
* Clients that do not control physical interfaces
|
120
|
+
* should never create ports with this bit set.
|
121
|
+
*/
|
122
|
+
JackPortCanMonitor = 0x8,
|
123
|
+
|
124
|
+
/**
|
125
|
+
* JackPortIsTerminal means:
|
126
|
+
*
|
127
|
+
* for an input port: the data received by the port
|
128
|
+
* will not be passed on or made
|
129
|
+
* available at any other port
|
130
|
+
*
|
131
|
+
* for an output port: the data available at the port
|
132
|
+
* does not originate from any other port
|
133
|
+
*
|
134
|
+
* Audio synthesizers, I/O hardware interface clients, HDR
|
135
|
+
* systems are examples of clients that would set this flag for
|
136
|
+
* their ports.
|
137
|
+
*/
|
138
|
+
JackPortIsTerminal = 0x10
|
139
|
+
};
|
140
|
+
=end
|
141
|
+
enum :flags, [ :is_input, 0x1,
|
142
|
+
:is_output, 0x2,
|
143
|
+
:is_physical, 0x4,
|
144
|
+
:can_monitor, 0x8,
|
145
|
+
:is_terminal, 0x10 ]
|
146
|
+
=begin
|
147
|
+
/**
|
148
|
+
* @return the @ref JackPortFlags of the jack_port_t.
|
149
|
+
*/
|
150
|
+
int jack_port_flags (const jack_port_t *port);
|
151
|
+
=end
|
152
|
+
|
153
|
+
attach_function :jack_port_flags, [:pointer], :int
|
154
|
+
|
155
|
+
=begin
|
156
|
+
/**
|
157
|
+
* @return the full name of the jack_port_t (including the @a
|
158
|
+
* "client_name:" prefix).
|
159
|
+
*
|
160
|
+
* @see jack_port_name_size().
|
161
|
+
*/
|
162
|
+
const char *jack_port_name (const jack_port_t *port);
|
163
|
+
=end
|
164
|
+
attach_function :jack_port_name, [:pointer], :string
|
165
|
+
|
166
|
+
end
|
167
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jack-ffi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Marcin Lewandowski
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-06 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: ffi
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Jack Audio Connection Kit Bindings via FFI interface
|
36
|
+
email: marcin@saepia.net
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- GPL3-LICENSE
|
45
|
+
- Rakefile
|
46
|
+
- VERSION
|
47
|
+
- lib/jack.rb
|
48
|
+
- lib/jack/client.rb
|
49
|
+
- lib/jack/errors.rb
|
50
|
+
- lib/jack/port.rb
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: http://jack-ffi.saepia.net
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options:
|
57
|
+
- --charset=UTF-8
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 3
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.3.7
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: JACK bindings via FFI
|
85
|
+
test_files: []
|
86
|
+
|