Jack2 1.9.6

alsa_midi_jackmp.cpp

00001 /*
00002  * Copyright (c) 2006,2007 Dmitry S. Baikov <c0ff@konstruktiv.org>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00017  */
00018 
00019 #include "JackAlsaDriver.h"
00020 #include "JackPort.h"
00021 #include "alsa_midi_impl.h"
00022 
00023 using Jack::JackAlsaDriver;
00024 
00025 struct fake_port_t
00026 {
00027     JackAlsaDriver* driver;
00028     int port_id;
00029     fake_port_t(JackAlsaDriver *d, int i) : driver(d), port_id(i)
00030     {}
00031 };
00032 
00033 int JACK_is_realtime(jack_client_t* client)
00034 {
00035     return ((JackAlsaDriver*)client)->is_realtime();
00036 }
00037 
00038 int JACK_client_create_thread(jack_client_t* client, pthread_t *thread, int priority, int realtime, void *(*start_routine)(void*), void *arg)
00039 {
00040     return ((JackAlsaDriver*)client)->create_thread(thread, priority, realtime, start_routine, arg);
00041 }
00042 
00043 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)
00044 {
00045     JackAlsaDriver *driver = (JackAlsaDriver*)client;
00046     int port_id = driver->port_register(port_name, port_type, flags, buffer_size);
00047     if (port_id == NO_PORT) {
00048         return 0;
00049     } else {
00050         return (jack_port_t*) new fake_port_t(driver, port_id);
00051     }
00052 }
00053 
00054 int JACK_port_unregister(jack_client_t *client, jack_port_t *port)
00055 {
00056     fake_port_t* real = (fake_port_t*)port;
00057     int res = real->driver->port_unregister(real->port_id);
00058     delete real;
00059     return res;
00060 }
00061 
00062 void* JACK_port_get_buffer(jack_port_t *port, jack_nframes_t nframes)
00063 {
00064     fake_port_t* real = (fake_port_t*)port;
00065     return real->driver->port_get_buffer(real->port_id, nframes);
00066 }
00067 
00068 int JACK_port_set_alias(jack_port_t *port, const char* name)
00069 {
00070     fake_port_t* real = (fake_port_t*)port;
00071     return real->driver->port_set_alias(real->port_id, name);
00072 }
00073 
00074 jack_nframes_t JACK_get_sample_rate(jack_client_t *client)
00075 {
00076     return ((JackAlsaDriver*)client)->get_sample_rate();
00077 }
00078 
00079 jack_nframes_t JACK_frame_time(jack_client_t *client)
00080 {
00081     return ((JackAlsaDriver*)client)->frame_time();
00082 }
00083 
00084 jack_nframes_t JACK_last_frame_time(jack_client_t *client)
00085 {
00086     return ((JackAlsaDriver*)client)->last_frame_time();
00087 }