mshtml: Update French translation.
[wine.git] / dlls / wineoss.drv / mmaux.c
blobe48df5dd3fa664016de2c0fff02f22074192fac5
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 LRESULT OSS_AuxInit(void)
54 int mixer;
55 TRACE("()\n");
57 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
58 WARN("mixer device not available !\n");
59 NumDev = 0;
60 } else {
61 close(mixer);
62 NumDev = 6;
64 return 0;
67 /*-----------------------------------------------------------------------*/
69 static LRESULT OSS_AuxExit(void)
71 TRACE("()\n");
72 return 0;
75 /**************************************************************************
76 * AUX_GetDevCaps [internal]
78 static DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPSW lpCaps, DWORD dwSize)
80 int mixer, volume;
81 static const WCHAR ini[] = {'O','S','S',' ','A','u','x',' ','#','0',0};
83 TRACE("(%04X, %p, %u);\n", wDevID, lpCaps, dwSize);
84 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
85 if (wDevID >= NumDev) return MMSYSERR_BADDEVICEID;
86 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
87 WARN("mixer device not available !\n");
88 return MMSYSERR_NOTENABLED;
90 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
91 close(mixer);
92 WARN("unable to read mixer !\n");
93 return MMSYSERR_NOTENABLED;
95 close(mixer);
96 lpCaps->wMid = 0xAA;
97 lpCaps->wPid = 0x55 + wDevID;
98 lpCaps->vDriverVersion = 0x0100;
99 strcpyW(lpCaps->szPname, ini);
100 lpCaps->szPname[9] = '0' + wDevID; /* 6 at max */
101 lpCaps->wTechnology = wDevID == 2 ? AUXCAPS_CDAUDIO : AUXCAPS_AUXIN;
102 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
104 return MMSYSERR_NOERROR;
108 /**************************************************************************
109 * AUX_GetVolume [internal]
111 static DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol)
113 int mixer, volume, left, right, cmd;
115 TRACE("(%04X, %p);\n", wDevID, lpdwVol);
116 if (lpdwVol == NULL) return MMSYSERR_NOTENABLED;
117 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
118 WARN("mixer device not available !\n");
119 return MMSYSERR_NOTENABLED;
121 switch(wDevID) {
122 case 0:
123 TRACE("SOUND_MIXER_READ_PCM !\n");
124 cmd = SOUND_MIXER_READ_PCM;
125 break;
126 case 1:
127 TRACE("SOUND_MIXER_READ_SYNTH !\n");
128 cmd = SOUND_MIXER_READ_SYNTH;
129 break;
130 case 2:
131 TRACE("SOUND_MIXER_READ_CD !\n");
132 cmd = SOUND_MIXER_READ_CD;
133 break;
134 case 3:
135 TRACE("SOUND_MIXER_READ_LINE !\n");
136 cmd = SOUND_MIXER_READ_LINE;
137 break;
138 case 4:
139 TRACE("SOUND_MIXER_READ_MIC !\n");
140 cmd = SOUND_MIXER_READ_MIC;
141 break;
142 case 5:
143 TRACE("SOUND_MIXER_READ_VOLUME !\n");
144 cmd = SOUND_MIXER_READ_VOLUME;
145 break;
146 default:
147 WARN("invalid device id=%04X !\n", wDevID);
148 close(mixer);
149 return MMSYSERR_NOTENABLED;
151 if (ioctl(mixer, cmd, &volume) == -1) {
152 WARN("unable to read mixer !\n");
153 close(mixer);
154 return MMSYSERR_NOTENABLED;
156 close(mixer);
157 left = LOBYTE(LOWORD(volume));
158 right = HIBYTE(LOWORD(volume));
159 TRACE("left=%d right=%d !\n", left, right);
160 *lpdwVol = MAKELONG((left * 0xFFFFL) / 100, (right * 0xFFFFL) / 100);
161 return MMSYSERR_NOERROR;
164 /**************************************************************************
165 * AUX_SetVolume [internal]
167 static DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
169 int mixer;
170 int volume, left, right;
171 int cmd;
173 TRACE("(%04X, %08X);\n", wDevID, dwParam);
175 left = (LOWORD(dwParam) * 100) >> 16;
176 right = (HIWORD(dwParam) * 100) >> 16;
177 volume = (right << 8) | left;
179 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
180 WARN("mixer device not available !\n");
181 return MMSYSERR_NOTENABLED;
184 switch(wDevID) {
185 case 0:
186 TRACE("SOUND_MIXER_WRITE_PCM !\n");
187 cmd = SOUND_MIXER_WRITE_PCM;
188 break;
189 case 1:
190 TRACE("SOUND_MIXER_WRITE_SYNTH !\n");
191 cmd = SOUND_MIXER_WRITE_SYNTH;
192 break;
193 case 2:
194 TRACE("SOUND_MIXER_WRITE_CD !\n");
195 cmd = SOUND_MIXER_WRITE_CD;
196 break;
197 case 3:
198 TRACE("SOUND_MIXER_WRITE_LINE !\n");
199 cmd = SOUND_MIXER_WRITE_LINE;
200 break;
201 case 4:
202 TRACE("SOUND_MIXER_WRITE_MIC !\n");
203 cmd = SOUND_MIXER_WRITE_MIC;
204 break;
205 case 5:
206 TRACE("SOUND_MIXER_WRITE_VOLUME !\n");
207 cmd = SOUND_MIXER_WRITE_VOLUME;
208 break;
209 default:
210 WARN("invalid device id=%04X !\n", wDevID);
211 close(mixer);
212 return MMSYSERR_NOTENABLED;
214 if (ioctl(mixer, cmd, &volume) == -1) {
215 WARN("unable to set mixer !\n");
216 close(mixer);
217 return MMSYSERR_NOTENABLED;
219 close(mixer);
220 return MMSYSERR_NOERROR;
223 #endif
225 /**************************************************************************
226 * auxMessage (WINEOSS.2)
228 DWORD WINAPI OSS_auxMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
229 DWORD_PTR dwParam1, DWORD_PTR dwParam2)
231 TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
232 wDevID, wMsg, dwUser, dwParam1, dwParam2);
234 #ifdef HAVE_OSS
235 switch (wMsg) {
236 case DRVM_INIT:
237 return OSS_AuxInit();
238 case DRVM_EXIT:
239 return OSS_AuxExit();
240 case DRVM_ENABLE:
241 case DRVM_DISABLE:
242 /* FIXME: Pretend this is supported */
243 return 0;
244 case AUXDM_GETDEVCAPS:
245 return AUX_GetDevCaps(wDevID, (LPAUXCAPSW)dwParam1, dwParam2);
246 case AUXDM_GETNUMDEVS:
247 TRACE("return %d;\n", NumDev);
248 return NumDev;
249 case AUXDM_GETVOLUME:
250 return AUX_GetVolume(wDevID, (LPDWORD)dwParam1);
251 case AUXDM_SETVOLUME:
252 return AUX_SetVolume(wDevID, dwParam1);
253 default:
254 WARN("unknown message !\n");
256 return MMSYSERR_NOTSUPPORTED;
257 #else
258 return MMSYSERR_NOTENABLED;
259 #endif