Assorted spelling and case fixes.
[wine/hacks.git] / dlls / winmm / wineoss / mmaux.c
blob44066346790096525571c1a4d641c9445f250e87
1 /*
2 * Sample AUXILIARY Wine Driver
4 * Copyright 1994 Martin Ayotte
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <stdarg.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #ifdef HAVE_UNISTD_H
28 # include <unistd.h>
29 #endif
30 #include <fcntl.h>
31 #ifdef HAVE_SYS_IOCTL_H
32 # include <sys/ioctl.h>
33 #endif
35 #include "windef.h"
36 #include "winbase.h"
37 #include "mmddk.h"
38 #include "oss.h"
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(mmaux);
44 #ifdef HAVE_OSS
46 #define MIXER_DEV "/dev/mixer"
48 static int NumDev = 6;
50 /*-----------------------------------------------------------------------*/
52 static int AUXDRV_Init(void)
54 int mixer;
56 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
57 WARN("mixer device not available !\n");
58 NumDev = 0;
59 } else {
60 close(mixer);
61 NumDev = 6;
63 return NumDev;
66 /**************************************************************************
67 * AUX_GetDevCaps [internal]
69 static DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPSW lpCaps, DWORD dwSize)
71 int mixer, volume;
72 static const WCHAR ini[] = {'O','S','S',' ','A','u','x',0};
74 TRACE("(%04X, %p, %lu);\n", wDevID, lpCaps, dwSize);
75 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
76 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
77 WARN("mixer device not available !\n");
78 return MMSYSERR_NOTENABLED;
80 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
81 close(mixer);
82 WARN("unable to read mixer !\n");
83 return MMSYSERR_NOTENABLED;
85 close(mixer);
86 lpCaps->wMid = 0xAA;
87 lpCaps->wPid = 0x55;
88 lpCaps->vDriverVersion = 0x0100;
89 strcpyW(lpCaps->szPname, ini);
90 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
91 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
93 return MMSYSERR_NOERROR;
97 /**************************************************************************
98 * AUX_GetVolume [internal]
100 static DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol)
102 int mixer, volume, left, right, cmd;
104 TRACE("(%04X, %p);\n", wDevID, lpdwVol);
105 if (lpdwVol == NULL) return MMSYSERR_NOTENABLED;
106 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
107 WARN("mixer device not available !\n");
108 return MMSYSERR_NOTENABLED;
110 switch(wDevID) {
111 case 0:
112 TRACE("SOUND_MIXER_READ_PCM !\n");
113 cmd = SOUND_MIXER_READ_PCM;
114 break;
115 case 1:
116 TRACE("SOUND_MIXER_READ_SYNTH !\n");
117 cmd = SOUND_MIXER_READ_SYNTH;
118 break;
119 case 2:
120 TRACE("SOUND_MIXER_READ_CD !\n");
121 cmd = SOUND_MIXER_READ_CD;
122 break;
123 case 3:
124 TRACE("SOUND_MIXER_READ_LINE !\n");
125 cmd = SOUND_MIXER_READ_LINE;
126 break;
127 case 4:
128 TRACE("SOUND_MIXER_READ_MIC !\n");
129 cmd = SOUND_MIXER_READ_MIC;
130 break;
131 case 5:
132 TRACE("SOUND_MIXER_READ_VOLUME !\n");
133 cmd = SOUND_MIXER_READ_VOLUME;
134 break;
135 default:
136 WARN("invalid device id=%04X !\n", wDevID);
137 return MMSYSERR_NOTENABLED;
139 if (ioctl(mixer, cmd, &volume) == -1) {
140 WARN("unable to read mixer !\n");
141 return MMSYSERR_NOTENABLED;
143 close(mixer);
144 left = LOBYTE(LOWORD(volume));
145 right = HIBYTE(LOWORD(volume));
146 TRACE("left=%d right=%d !\n", left, right);
147 *lpdwVol = MAKELONG((left * 0xFFFFL) / 100, (right * 0xFFFFL) / 100);
148 return MMSYSERR_NOERROR;
151 /**************************************************************************
152 * AUX_SetVolume [internal]
154 static DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
156 int mixer;
157 int volume, left, right;
158 int cmd;
160 TRACE("(%04X, %08lX);\n", wDevID, dwParam);
162 left = (LOWORD(dwParam) * 100) >> 16;
163 right = (HIWORD(dwParam) * 100) >> 16;
164 volume = (right << 8) | left;
166 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
167 WARN("mixer device not available !\n");
168 return MMSYSERR_NOTENABLED;
171 switch(wDevID) {
172 case 0:
173 TRACE("SOUND_MIXER_WRITE_PCM !\n");
174 cmd = SOUND_MIXER_WRITE_PCM;
175 break;
176 case 1:
177 TRACE("SOUND_MIXER_WRITE_SYNTH !\n");
178 cmd = SOUND_MIXER_WRITE_SYNTH;
179 break;
180 case 2:
181 TRACE("SOUND_MIXER_WRITE_CD !\n");
182 cmd = SOUND_MIXER_WRITE_CD;
183 break;
184 case 3:
185 TRACE("SOUND_MIXER_WRITE_LINE !\n");
186 cmd = SOUND_MIXER_WRITE_LINE;
187 break;
188 case 4:
189 TRACE("SOUND_MIXER_WRITE_MIC !\n");
190 cmd = SOUND_MIXER_WRITE_MIC;
191 break;
192 case 5:
193 TRACE("SOUND_MIXER_WRITE_VOLUME !\n");
194 cmd = SOUND_MIXER_WRITE_VOLUME;
195 break;
196 default:
197 WARN("invalid device id=%04X !\n", wDevID);
198 return MMSYSERR_NOTENABLED;
200 if (ioctl(mixer, cmd, &volume) == -1) {
201 WARN("unable to set mixer !\n");
202 return MMSYSERR_NOTENABLED;
204 close(mixer);
205 return MMSYSERR_NOERROR;
208 #endif
210 /**************************************************************************
211 * auxMessage (WINEOSS.2)
213 DWORD WINAPI OSS_auxMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
214 DWORD dwParam1, DWORD dwParam2)
216 TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
217 wDevID, wMsg, dwUser, dwParam1, dwParam2);
219 #ifdef HAVE_OSS
220 switch (wMsg) {
221 case DRVM_INIT:
222 AUXDRV_Init();
223 /* fall through */
224 case DRVM_EXIT:
225 case DRVM_ENABLE:
226 case DRVM_DISABLE:
227 /* FIXME: Pretend this is supported */
228 return 0;
229 case AUXDM_GETDEVCAPS:
230 return AUX_GetDevCaps(wDevID, (LPAUXCAPSW)dwParam1, dwParam2);
231 case AUXDM_GETNUMDEVS:
232 TRACE("return %d;\n", NumDev);
233 return NumDev;
234 case AUXDM_GETVOLUME:
235 return AUX_GetVolume(wDevID, (LPDWORD)dwParam1);
236 case AUXDM_SETVOLUME:
237 return AUX_SetVolume(wDevID, dwParam1);
238 default:
239 WARN("unknown message !\n");
241 return MMSYSERR_NOTSUPPORTED;
242 #else
243 return MMSYSERR_NOTENABLED;
244 #endif