Jack2 1.9.12

alsa_midi_jackmp.cpp
1 /*
2 * Copyright (c) 2006,2007 Dmitry S. Baikov <c0ff@konstruktiv.org>
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 2 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, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 #include "JackAlsaDriver.h"
20 #include "JackPort.h"
21 #include "alsa_midi_impl.h"
22
23 using Jack::JackAlsaDriver;
24
25 struct fake_port_t
26 {
27 JackAlsaDriver* driver;
28 int port_id;
29 fake_port_t(JackAlsaDriver *d, int i) : driver(d), port_id(i)
30 {}
31 };
32
33 int JACK_is_realtime(jack_client_t* client)
34 {
35 return ((JackAlsaDriver*)client)->is_realtime();
36 }
37
38 int JACK_client_create_thread(jack_client_t* client, pthread_t *thread, int priority, int realtime, void *(*start_routine)(void*), void *arg)
39 {
40 return ((JackAlsaDriver*)client)->create_thread(thread, priority, realtime, start_routine, arg);
41 }
42
43 jack_port_t* JACK_port_register(jack_client_t *client, const char *port_name, const char *port_type, unsigned long flags, unsigned long buffer_size)
44 {
45 JackAlsaDriver *driver = (JackAlsaDriver*)client;
46 int port_id = driver->port_register(port_name, port_type, flags, buffer_size);
47 if (port_id == NO_PORT) {
48 return 0;
49 } else {
50 return (jack_port_t*) new fake_port_t(driver, port_id);
51 }
52 }
53
54 int JACK_port_unregister(jack_client_t *client, jack_port_t *port)
55 {
56 fake_port_t* real = (fake_port_t*)port;
57 int res = real->driver->port_unregister(real->port_id);
58 delete real;
59 return res;
60 }
61
62 void* JACK_port_get_buffer(jack_port_t *port, jack_nframes_t nframes)
63 {
64 fake_port_t* real = (fake_port_t*)port;
65 return real->driver->port_get_buffer(real->port_id, nframes);
66 }
67
68 int JACK_port_set_alias(jack_port_t *port, const char* name)
69 {
70 fake_port_t* real = (fake_port_t*)port;
71 return real->driver->port_set_alias(real->port_id, name);
72 }
73
74 jack_nframes_t JACK_get_sample_rate(jack_client_t *client)
75 {
76 return ((JackAlsaDriver*)client)->get_sample_rate();
77 }
78
79 jack_nframes_t JACK_frame_time(jack_client_t *client)
80 {
81 return ((JackAlsaDriver*)client)->frame_time();
82 }
83
84 jack_nframes_t JACK_last_frame_time(jack_client_t *client)
85 {
86 return ((JackAlsaDriver*)client)->last_frame_time();
87 }
Jack::JackAlsaDriver
The ALSA driver.
Definition: JackAlsaDriver.h:36
fake_port_t
Definition: alsa_midi_jackmp.cpp:25