1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
4 * Initialization procedures for multimedia
6 * Copyright 1998 Luiz Otavio L. Zorzella
11 #include <sys/ioctl.h>
13 #include "multimedia.h"
20 extern int MODM_NUMDEVS
;
21 extern int MODM_NUMFMSYNTHDEVS
;
22 extern int MODM_NUMMIDIDEVS
;
23 extern LPMIDIOUTCAPS16 midiOutDevices
[MAX_MIDIOUTDRV
];
25 extern int MIDM_NUMDEVS
;
26 extern LPMIDIINCAPS16 midiInDevices
[MAX_MIDIINDRV
];
30 /**************************************************************************
31 * unixToWindowsDeviceType [internal]
33 * return the Windows equivalent to a Unix Device Type
37 int unixToWindowsDeviceType(int type
)
39 /* MOD_MIDIPORT output port
40 * MOD_SYNTH generic internal synth
41 * MOD_SQSYNTH square wave internal synth
42 * MOD_FMSYNTH FM internal synth
43 * MOD_MAPPER MIDI mapper
46 /* FIXME Is this really the correct equivalence from UNIX to
50 case SYNTH_TYPE_FM
: return MOD_FMSYNTH
;
51 case SYNTH_TYPE_SAMPLE
: return MOD_SYNTH
;
52 case SYNTH_TYPE_MIDI
: return MOD_MIDIPORT
;
54 ERR(midi
, "Cannot determine the type of this midi device. "
55 "Assuming FM Synth\n");
61 /**************************************************************************
62 * MULTIMEDIA_MidiInit [internal]
64 * Initializes the MIDI devices information variables
67 BOOL32
MULTIMEDIA_MidiInit(void)
70 int i
, status
, numsynthdevs
= 255, nummididevs
= 255;
71 struct synth_info sinfo
;
72 struct midi_info minfo
;
73 int fd
; /* file descriptor for MIDI_SEQ */
75 TRACE(midi
, "Initializing the MIDI variables.\n");
77 /* try to open device */
78 /* FIXME: should use function midiOpenSeq() in midi.c */
79 fd
= open(MIDI_SEQ
, O_WRONLY
);
81 TRACE(midi
, "No sequencer found: unable to open `%s'.\n", MIDI_SEQ
);
85 /* find how many Synth devices are there in the system */
86 status
= ioctl(fd
, SNDCTL_SEQ_NRSYNTHS
, &numsynthdevs
);
89 ERR(midi
, "ioctl for nr synth failed.\n");
94 if (numsynthdevs
> MAX_MIDIOUTDRV
) {
95 ERR(midi
, "MAX_MIDIOUTDRV (%d) was enough for the number of devices (%d). "
96 "Some FM devices will not be available.\n",MAX_MIDIOUTDRV
,numsynthdevs
);
97 numsynthdevs
= MAX_MIDIOUTDRV
;
100 for (i
= 0; i
< numsynthdevs
; i
++) {
101 LPMIDIOUTCAPS16 tmplpCaps
;
104 status
= ioctl(fd
, SNDCTL_SYNTH_INFO
, &sinfo
);
106 ERR(midi
, "ioctl for synth info failed.\n");
111 tmplpCaps
= xmalloc(sizeof(MIDIOUTCAPS16
));
112 /* We also have the information sinfo.synth_subtype, not used here
115 /* Manufac ID. We do not have access to this with soundcard.h
116 * Does not seem to be a problem, because in mmsystem.h only
117 * Microsoft's ID is listed.
119 tmplpCaps
->wMid
= 0x00FF;
120 tmplpCaps
->wPid
= 0x0001; /* FIXME Product ID */
121 /* Product Version. We simply say "1" */
122 tmplpCaps
->vDriverVersion
= 0x001;
123 strcpy(tmplpCaps
->szPname
, sinfo
.name
);
125 tmplpCaps
->wTechnology
= unixToWindowsDeviceType(sinfo
.synth_type
);
126 tmplpCaps
->wVoices
= sinfo
.nr_voices
;
128 /* FIXME Is it possible to know the maximum
129 * number of simultaneous notes of a soundcard ?
130 * I believe we don't have this information, but
131 * it's probably equal or more than wVoices
133 tmplpCaps
->wNotes
= sinfo
.nr_voices
;
135 /* FIXME Do we have this information?
136 * Assuming the soundcards can handle
137 * MIDICAPS_VOLUME and MIDICAPS_LRVOLUME but
138 * not MIDICAPS_CACHE.
140 tmplpCaps
->dwSupport
= MIDICAPS_VOLUME
|MIDICAPS_LRVOLUME
;
142 midiOutDevices
[i
] = tmplpCaps
;
144 if (sinfo
.capabilities
& SYNTH_CAP_INPUT
) {
145 FIXME(midi
, "Synthetizer support MIDI in. Not supported yet (please report)\n");
148 TRACE(midi
, "name='%s', techn=%d voices=%d notes=%d support=%ld\n",
149 tmplpCaps
->szPname
, tmplpCaps
->wTechnology
,
150 tmplpCaps
->wVoices
, tmplpCaps
->wNotes
, tmplpCaps
->dwSupport
);
151 TRACE(midi
,"OSS info: synth subtype=%d capa=%Xh\n",
152 sinfo
.synth_subtype
, sinfo
.capabilities
);
155 /* find how many MIDI devices are there in the system */
156 status
= ioctl(fd
, SNDCTL_SEQ_NRMIDIS
, &nummididevs
);
158 ERR(midi
, "ioctl on nr midi failed.\n");
162 /* FIXME: the two restrictions below could be loosen in some cases */
163 if (numsynthdevs
+ nummididevs
> MAX_MIDIOUTDRV
) {
164 ERR(midi
, "MAX_MIDIOUTDRV was not enough for the number of devices. "
165 "Some MIDI devices will not be available.\n");
166 nummididevs
= MAX_MIDIOUTDRV
- numsynthdevs
;
169 if (nummididevs
> MAX_MIDIINDRV
) {
170 ERR(midi
, "MAX_MIDIINDRV (%d) was not enough for the number of devices (%d). "
171 "Some MIDI devices will not be available.\n",MAX_MIDIINDRV
,nummididevs
);
172 nummididevs
= MAX_MIDIINDRV
;
175 for (i
= 0; i
< nummididevs
; i
++) {
176 LPMIDIOUTCAPS16 tmplpOutCaps
;
177 LPMIDIINCAPS16 tmplpInCaps
;
180 status
= ioctl(fd
, SNDCTL_MIDI_INFO
, &minfo
);
182 ERR(midi
, "ioctl on midi info failed.\n");
187 tmplpOutCaps
= xmalloc(sizeof(MIDIOUTCAPS16
));
188 /* This whole part is somewhat obscure to me. I'll keep trying to dig
189 info about it. If you happen to know, please tell us. The very
190 descritive minfo.dev_type was not used here.
192 /* Manufac ID. We do not have access to this with soundcard.h
193 Does not seem to be a problem, because in mmsystem.h only
194 Microsoft's ID is listed */
195 tmplpOutCaps
->wMid
= 0x00FF;
196 tmplpOutCaps
->wPid
= 0x0001; /* FIXME Product ID */
197 /* Product Version. We simply say "1" */
198 tmplpOutCaps
->vDriverVersion
= 0x001;
199 strcpy(tmplpOutCaps
->szPname
, minfo
.name
);
201 tmplpOutCaps
->wTechnology
= MOD_MIDIPORT
; /* FIXME Is this right? */
202 /* Does it make any difference? */
203 tmplpOutCaps
->wVoices
= 16;
204 /* Does it make any difference? */
205 tmplpOutCaps
->wNotes
= 16;
206 /* FIXME Does it make any difference? */
207 tmplpOutCaps
->dwSupport
= MIDICAPS_VOLUME
|MIDICAPS_LRVOLUME
;
209 midiOutDevices
[numsynthdevs
+ i
] = tmplpOutCaps
;
211 tmplpInCaps
= xmalloc(sizeof(MIDIOUTCAPS16
));
212 /* This whole part is somewhat obscure to me. I'll keep trying to dig
213 info about it. If you happen to know, please tell us. The very
214 descritive minfo.dev_type was not used here.
216 /* Manufac ID. We do not have access to this with soundcard.h
217 Does not seem to be a problem, because in mmsystem.h only
218 Microsoft's ID is listed */
219 tmplpInCaps
->wMid
= 0x00FF;
220 tmplpInCaps
->wPid
= 0x0001; /* FIXME Product ID */
221 /* Product Version. We simply say "1" */
222 tmplpInCaps
->vDriverVersion
= 0x001;
223 strcpy(tmplpInCaps
->szPname
, minfo
.name
);
225 /* FIXME : could we get better information than that ? */
226 tmplpInCaps
->dwSupport
= MIDICAPS_VOLUME
|MIDICAPS_LRVOLUME
;
228 midiInDevices
[i
] = tmplpInCaps
;
230 TRACE(midi
,"name='%s' techn=%d voices=%d notes=%d support=%ld\n",
231 tmplpOutCaps
->szPname
, tmplpOutCaps
->wTechnology
, tmplpOutCaps
->wVoices
,
232 tmplpOutCaps
->wNotes
, tmplpOutCaps
->dwSupport
);
233 TRACE(midi
,"OSS info: midi dev-type=%d, capa=%d\n",
234 minfo
.dev_type
, minfo
.capabilities
);
237 /* windows does not seem to differentiate Synth from MIDI devices */
238 MODM_NUMFMSYNTHDEVS
= numsynthdevs
;
239 MODM_NUMMIDIDEVS
= nummididevs
;
240 MODM_NUMDEVS
= numsynthdevs
+ nummididevs
;
242 MIDM_NUMDEVS
= nummididevs
;
244 /* close file and exit */
246 #endif /* HAVE_OSS */
251 extern int mciInstalledCount
;
252 extern int mciInstalledListLen
;
253 extern LPSTR lpmciInstallNames
;
255 BOOL32
MULTIMEDIA_MciInit(void)
259 LPSTR SysFile
= "SYSTEM.INI";
261 mciInstalledCount
= 0;
262 mciInstalledListLen
= 0;
263 ptr
= lpmciInstallNames
= xmalloc(2048);
264 /* FIXME: should do also some registry diving here */
265 GetPrivateProfileString32A("mci", NULL
, "", lpmciInstallNames
, 2000, SysFile
);
266 while (strlen(ptr
) > 0) {
267 TRACE(mci
, "---> '%s' \n", ptr
);
268 len
= strlen(ptr
) + 1;
270 mciInstalledListLen
+= len
;
276 /**************************************************************************
277 * MULTIMEDIA_Init [internal]
279 * Initializes the multimedia information variables
282 BOOL32
MULTIMEDIA_Init(void)
284 return MULTIMEDIA_MidiInit() && MULTIMEDIA_MciInit();