Debian Codegraph @

src/gui/midi_oss.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2002-2010 The DOSBox Team
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 <fcntl.h>
20 #define SEQ_MIDIPUTC 5
21
22 class MidiHandler_oss: public MidiHandler {
23 private:
24 int device;
25 Bit8u device_num;
26 bool isOpen;
27 public:
28 MidiHandler_oss() : MidiHandler(),isOpen(false) {};
29 const char * GetName(void) { return "oss";};
30 bool Open(const char * conf) {
31 char devname[512];
32 if (conf && conf[0]) safe_strncpy(devname,conf,512);
33 else strcpy(devname,"/dev/sequencer");
34 char * devfind=(strrchr(devname,','));
35 if (devfind) {
36 *devfind++=0;
37 device_num=atoi(devfind);
38 } else device_num=0;
39 if (isOpen) return false;
40 device=open(devname, O_WRONLY, 0);
41 if (device<0) return false;
42 return true;
43 };
44 void Close(void) {
45 if (!isOpen) return;
46 if (device>0) close(device);
47 };
48 void PlayMsg(Bit8u * msg) {
49 Bit8u buf[128];Bitu pos=0;
50 Bitu len=MIDI_evt_len[*msg];
51 for (;len>0;len--) {
52 buf[pos++] = SEQ_MIDIPUTC;
53 buf[pos++] = *msg;
54 buf[pos++] = device_num;
55 buf[pos++] = 0;
56 msg++;
57 }
58 write(device,buf,pos);
59 };
60 void PlaySysex(Bit8u * sysex,Bitu len) {
61 Bit8u buf[SYSEX_SIZE*4];Bitu pos=0;
62 for (;len>0;len--) {
63 buf[pos++] = SEQ_MIDIPUTC;
64 buf[pos++] = *sysex++;
65 buf[pos++] = device_num;
66 buf[pos++] = 0;
67 }
68 write(device,buf,pos);
69 }
70 };
71
72 MidiHandler_oss Midi_oss;
73
74
75
76