1
2 /*
3 * Diverse Bristol midi routines.
4 * Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2012
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
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.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22 /*
23 * This code should open the midi device (working with ALSA raw midi only for
24 * the moment (9/11/01)), and read data from it. Not sure how it will be read,
25 * either buffers, events, or perhaps just raw data. At some point in the
26 * development this will become a separate thread in the synth code.
27 */
28
29 /*#define DEBUG */
30
31 #include <sys/types.h>
32 #include <sys/stat.h>
33 #include <fcntl.h>
34
35 #include "bristolmidi.h"
36
37 extern bristolMidiMain bmidi;
38
39 /*
40 * This is the OSS code.
41 */
42 int
bristolMidiOSSOpen(char * devname,int flags,int chan,int messages,int (* callback)(),void * param,int dev,int handle)43 bristolMidiOSSOpen(char *devname, int flags, int chan, int messages,
44 int (*callback)(), void *param, int dev, int handle)
45 {
46 #ifdef DEBUG
47 printf("bristolMidiOSSOpen(%i, %i)\n", dev, handle);
48 #endif
49
50 if ((bmidi.dev[dev].fd = open(devname, O_RDWR)) < 0)
51 {
52 printf("Could not open OSS midi interface\n");
53 return(BRISTOL_MIDI_DRIVER);
54 }
55
56 /*
57 * We use ALSA rawmidi flags to ensure we lock into the read algorithm.
58 * Since these are raw interfaces we use a single receiver and parser.
59 */
60 bmidi.dev[dev].flags = BRISTOL_CONN_OSSMIDI;
61
62 return(handle);
63 }
64
65 int
bristolMidiOSSClose(int handle)66 bristolMidiOSSClose(int handle)
67 {
68 #ifdef DEBUG
69 printf("bristolMidiOSSClose()\n");
70 #endif
71
72 close(bmidi.dev[bmidi.handle[handle].dev].fd);
73
74 return(BRISTOL_MIDI_OK);
75 }
76
77 int
bristolMidiOSSRead(void * buffer,int size)78 bristolMidiOSSRead(void *buffer, int size)
79 {
80 #ifdef DEBUG
81 printf("bristolMidiOSSRead()\n");
82 #endif
83
84 printf("libbristolmidi - should not be in OSS read routines\n");
85
86 return(-1);
87 }
88
89