1 /* -*- Mode: C ; c-basic-offset: 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 #include <semaphore.h>
26 #include <jack/midiport.h>
28 #define JACK_INVALID_PORT NULL
31 #define MAX_EVENT_SIZE 1024
33 #define PORT_HASH_BITS 4
34 #define PORT_HASH_SIZE (1 << PORT_HASH_BITS)
36 typedef struct a2j_port
* a2j_port_hash_t
[PORT_HASH_SIZE
];
42 struct a2j_port
* next
; /* hash - jack */
43 struct list_head siblings
; /* list - main loop */
47 snd_seq_addr_t remote
;
48 jack_port_t
* jack_port
;
50 jack_ringbuffer_t
* inbound_events
; // alsa_midi_event_t + data
51 int64_t last_out_time
;
58 snd_midi_event_t
*codec
;
60 jack_ringbuffer_t
*new_ports
;
62 a2j_port_hash_t port_hash
;
63 struct list_head list
;
68 jack_client_t
* jack_client
;
71 pthread_t alsa_input_thread
;
72 pthread_t alsa_output_thread
;
77 jack_ringbuffer_t
*port_add
; // snd_seq_addr_t
78 jack_ringbuffer_t
*port_del
; // struct a2j_port*
79 jack_ringbuffer_t
* outbound_events
; // struct a2j_delivery_event
80 jack_nframes_t cycle_start
;
84 struct a2j_stream stream
[2];
87 #define NSEC_PER_SEC ((int64_t)1000*1000*1000)
89 struct a2j_process_info
92 jack_nframes_t nframes
;
93 jack_nframes_t period_start
;
94 jack_nframes_t sample_rate
;
95 jack_nframes_t cur_frames
;
99 struct a2j_alsa_midi_event
105 struct a2j_delivery_event
107 /* a jack MIDI event, plus the port its destined for: everything
108 the ALSA output thread needs to deliver the event. time is
109 part of the jack_event.
111 jack_midi_event_t jack_event
;
112 jack_nframes_t time
; /* realtime, not offset time */
113 struct a2j_port
* port
;
116 /* Beside enum use, these are indeces for (struct a2j).stream array */
117 #define A2J_PORT_CAPTURE 0 // ALSA playback port -> JACK capture port
118 #define A2J_PORT_PLAYBACK 1 // JACK playback port -> ALSA capture port
120 extern struct a2j
* g_a2j
;
122 #endif /* #ifndef STRUCTS_H__FD2CC895_411F_4ADE_9200_50FE395EDB72__INCLUDED */