git aware version script
[a2jmidid.git] / structs.h
blob96ae61a4b28586245a1026b9ca441197aead14b4
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * ALSA SEQ < - > JACK MIDI bridge
5 * Copyright (c) 2006,2007 Dmitry S. Baikov <c0ff@konstruktiv.org>
6 * Copyright (c) 2007,2008 Nedko Arnaudov <nedko@arnaudov.name>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef STRUCTS_H__FD2CC895_411F_4ADE_9200_50FE395EDB72__INCLUDED
23 #define STRUCTS_H__FD2CC895_411F_4ADE_9200_50FE395EDB72__INCLUDED
25 #define JACK_INVALID_PORT NULL
27 #define MAX_PORTS 64
28 #define MAX_EVENT_SIZE 1024
30 #define PORT_HASH_BITS 4
31 #define PORT_HASH_SIZE (1 << PORT_HASH_BITS)
33 typedef struct a2j_port * a2j_port_hash_t[PORT_HASH_SIZE];
35 struct a2j;
37 struct a2j_port
39 struct a2j_port * next; /* hash - jack */
40 struct list_head siblings; /* list - main loop */
41 struct a2j * a2j_ptr;
42 bool is_dead;
43 char name[64];
44 snd_seq_addr_t remote;
45 jack_port_t * jack_port;
47 jack_ringbuffer_t * early_events; // alsa_midi_event_t + data
48 int64_t last_out_time;
50 void * jack_buf;
53 struct a2j_stream
55 snd_midi_event_t *codec;
57 jack_ringbuffer_t *new_ports;
59 a2j_port_hash_t port_hash;
60 struct list_head list;
63 struct a2j
65 jack_client_t * jack_client;
67 snd_seq_t *seq;
68 int client_id;
69 int port_id;
70 int queue;
72 jack_ringbuffer_t *port_add; // snd_seq_addr_t
73 jack_ringbuffer_t *port_del; // struct a2j_port*
75 struct a2j_stream stream[2];
78 #define NSEC_PER_SEC ((int64_t)1000*1000*1000)
80 struct a2j_process_info
82 int dir;
83 jack_nframes_t nframes;
84 jack_nframes_t period_start;
85 jack_nframes_t sample_rate;
86 jack_nframes_t cur_frames;
87 int64_t alsa_time;
90 struct a2j_alsa_midi_event
92 int64_t time;
93 int size;
96 /* Beside enum use, these are indeces for (struct a2j).stream array */
97 #define A2J_PORT_CAPTURE 0 // ALSA playback port -> JACK capture port
98 #define A2J_PORT_PLAYBACK 1 // JACK playback port -> ALSA capture port
100 extern struct a2j * g_a2j;
102 #endif /* #ifndef STRUCTS_H__FD2CC895_411F_4ADE_9200_50FE395EDB72__INCLUDED */