1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
4 * Sample MIXER Wine Driver for Linux
6 * Copyright 1997 Marcus Meissner
7 * 1999,2001 Eric Pouech
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #ifdef HAVE_SYS_IOCTL_H
37 # include <sys/ioctl.h>
40 #define NONAMELESSUNION
41 #define NONAMELESSSTRUCT
46 #include "wine/debug.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(mixer);
52 #define MAX_MIXERDRV (6)
54 #define WINE_MIXER_MANUF_ID 0xAA
55 #define WINE_MIXER_PRODUCT_ID 0x55
56 #define WINE_MIXER_VERSION 0x0100
57 #define WINE_MIXER_NAME "WINE OSS Mixer"
59 #define WINE_CHN_MASK(_x) (1L << (_x))
60 #define WINE_CHN_SUPPORTS(_c, _x) ((_c) & WINE_CHN_MASK(_x))
61 /* Bass and Treble are no longer in the mask as Windows does not handle them */
62 #define WINE_MIXER_MASK_SPEAKER (WINE_CHN_MASK(SOUND_MIXER_SYNTH) | \
63 WINE_CHN_MASK(SOUND_MIXER_PCM) | \
64 WINE_CHN_MASK(SOUND_MIXER_LINE) | \
65 WINE_CHN_MASK(SOUND_MIXER_MIC) | \
66 WINE_CHN_MASK(SOUND_MIXER_CD) )
68 #define WINE_MIXER_MASK_RECORD (WINE_CHN_MASK(SOUND_MIXER_SYNTH) | \
69 WINE_CHN_MASK(SOUND_MIXER_LINE) | \
70 WINE_CHN_MASK(SOUND_MIXER_MIC) | \
71 WINE_CHN_MASK(SOUND_MIXER_IMIX) )
73 /* FIXME: the two following string arrays should be moved to a resource file in a string table */
74 /* if it's done, better use a struct to hold labels, name, and muted channel volume cache */
75 static const char* MIX_Labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
76 static const char* MIX_Names [SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
87 int volume[SOUND_MIXER_NRDEVICES];
91 BOOL singleRecChannel;
92 struct mixerCtrl* ctrl;
96 #define LINEID_DST 0xFFFF
97 #define LINEID_SPEAKER 0x0000
98 #define LINEID_RECORD 0x0001
100 static int MIX_NumMixers;
101 static struct mixer MIX_Mixers[MAX_MIXERDRV];
103 /**************************************************************************
106 static const char * getMessage(UINT uMsg)
109 #define MSG_TO_STR(x) case x: return #x;
111 MSG_TO_STR(DRVM_INIT);
112 MSG_TO_STR(DRVM_EXIT);
113 MSG_TO_STR(DRVM_ENABLE);
114 MSG_TO_STR(DRVM_DISABLE);
115 MSG_TO_STR(MXDM_GETDEVCAPS);
116 MSG_TO_STR(MXDM_GETLINEINFO);
117 MSG_TO_STR(MXDM_GETNUMDEVS);
118 MSG_TO_STR(MXDM_OPEN);
119 MSG_TO_STR(MXDM_CLOSE);
120 MSG_TO_STR(MXDM_GETLINECONTROLS);
121 MSG_TO_STR(MXDM_GETCONTROLDETAILS);
122 MSG_TO_STR(MXDM_SETCONTROLDETAILS);
125 sprintf(str, "UNKNOWN(%08x)", uMsg);
129 static const char * getIoctlCommand(int command)
132 #define IOCTL_TO_STR(x) case x: return #x;
134 IOCTL_TO_STR(SOUND_MIXER_NRDEVICES);
135 IOCTL_TO_STR(SOUND_MIXER_VOLUME);
136 IOCTL_TO_STR(SOUND_MIXER_BASS);
137 IOCTL_TO_STR(SOUND_MIXER_TREBLE);
138 IOCTL_TO_STR(SOUND_MIXER_SYNTH);
139 IOCTL_TO_STR(SOUND_MIXER_PCM);
140 IOCTL_TO_STR(SOUND_MIXER_SPEAKER);
141 IOCTL_TO_STR(SOUND_MIXER_LINE);
142 IOCTL_TO_STR(SOUND_MIXER_MIC);
143 IOCTL_TO_STR(SOUND_MIXER_CD);
144 IOCTL_TO_STR(SOUND_MIXER_IMIX);
145 IOCTL_TO_STR(SOUND_MIXER_ALTPCM);
146 IOCTL_TO_STR(SOUND_MIXER_RECLEV);
147 IOCTL_TO_STR(SOUND_MIXER_IGAIN);
148 IOCTL_TO_STR(SOUND_MIXER_OGAIN);
149 IOCTL_TO_STR(SOUND_MIXER_LINE1);
150 IOCTL_TO_STR(SOUND_MIXER_LINE2);
151 IOCTL_TO_STR(SOUND_MIXER_LINE3);
152 IOCTL_TO_STR(SOUND_MIXER_DIGITAL1);
153 IOCTL_TO_STR(SOUND_MIXER_DIGITAL2);
154 IOCTL_TO_STR(SOUND_MIXER_DIGITAL3);
155 IOCTL_TO_STR(SOUND_MIXER_PHONEIN);
156 IOCTL_TO_STR(SOUND_MIXER_PHONEOUT);
157 IOCTL_TO_STR(SOUND_MIXER_VIDEO);
158 IOCTL_TO_STR(SOUND_MIXER_RADIO);
159 IOCTL_TO_STR(SOUND_MIXER_MONITOR);
160 IOCTL_TO_STR(SOUND_ONOFF_MIN);
161 IOCTL_TO_STR(SOUND_ONOFF_MAX);
164 sprintf(str, "UNKNOWN(%08x)", command);
168 static const char * getControlType(DWORD dwControlType)
171 #define TYPE_TO_STR(x) case x: return #x;
172 switch (dwControlType) {
173 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_CUSTOM);
174 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_BOOLEANMETER);
175 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_SIGNEDMETER);
176 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_PEAKMETER);
177 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER);
178 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_BOOLEAN);
179 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_ONOFF);
180 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_MUTE);
181 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_MONO);
182 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_LOUDNESS);
183 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_STEREOENH);
184 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_BASS_BOOST);
185 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_BUTTON);
186 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_DECIBELS);
187 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_SIGNED);
188 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_UNSIGNED);
189 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_PERCENT);
190 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_SLIDER);
191 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_PAN);
192 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_QSOUNDPAN);
193 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_FADER);
194 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_VOLUME);
195 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_BASS);
196 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_TREBLE);
197 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_EQUALIZER);
198 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_SINGLESELECT);
199 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_MUX);
200 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT);
201 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_MIXER);
202 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_MICROTIME);
203 TYPE_TO_STR(MIXERCONTROL_CONTROLTYPE_MILLITIME);
206 sprintf(str, "UNKNOWN(%08lx)", dwControlType);
210 /**************************************************************************
211 * MIX_FillLineControls [internal]
213 static void MIX_FillLineControls(struct mixer* mix, int c, DWORD lineID,
216 struct mixerCtrl* mc = &mix->ctrl[c];
219 TRACE("(%p, %d, %08lx, %s)\n", mix, c, lineID, getControlType(dwType));
221 mc->dwLineID = lineID;
222 mc->ctrl.cbStruct = sizeof(MIXERCONTROLA);
223 mc->ctrl.dwControlID = c + 1;
224 mc->ctrl.dwControlType = dwType;
228 case MIXERCONTROL_CONTROLTYPE_VOLUME:
229 mc->ctrl.fdwControl = 0;
230 mc->ctrl.cMultipleItems = 0;
231 lstrcpynA(mc->ctrl.szShortName, "Vol", MIXER_SHORT_NAME_CHARS);
232 lstrcpynA(mc->ctrl.szName, "Volume", MIXER_LONG_NAME_CHARS);
233 memset(&mc->ctrl.Bounds, 0, sizeof(mc->ctrl.Bounds));
234 /* CONTROLTYPE_VOLUME uses the MIXER_CONTROLDETAILS_UNSIGNED struct,
235 * [0, 100] is the range supported by OSS
236 * whatever the min and max values are they must match
237 * conversions done in (Get|Set)ControlDetails to stay in [0, 100] range
239 mc->ctrl.Bounds.s1.dwMinimum = 0;
240 mc->ctrl.Bounds.s1.dwMaximum = 65535;
241 memset(&mc->ctrl.Metrics, 0, sizeof(mc->ctrl.Metrics));
242 mc->ctrl.Metrics.cSteps = 656;
244 case MIXERCONTROL_CONTROLTYPE_MUTE:
245 case MIXERCONTROL_CONTROLTYPE_ONOFF:
246 mc->ctrl.fdwControl = 0;
247 mc->ctrl.cMultipleItems = 0;
248 lstrcpynA(mc->ctrl.szShortName, "Mute", MIXER_SHORT_NAME_CHARS);
249 lstrcpynA(mc->ctrl.szName, "Mute", MIXER_LONG_NAME_CHARS);
250 memset(&mc->ctrl.Bounds, 0, sizeof(mc->ctrl.Bounds));
251 mc->ctrl.Bounds.s1.dwMinimum = 0;
252 mc->ctrl.Bounds.s1.dwMaximum = 1;
253 memset(&mc->ctrl.Metrics, 0, sizeof(mc->ctrl.Metrics));
255 case MIXERCONTROL_CONTROLTYPE_MUX:
256 case MIXERCONTROL_CONTROLTYPE_MIXER:
257 mc->ctrl.fdwControl = MIXERCONTROL_CONTROLF_MULTIPLE;
258 mc->ctrl.cMultipleItems = 0;
259 for (j = 0; j < SOUND_MIXER_NRDEVICES; j++)
260 if (WINE_CHN_SUPPORTS(mix->recMask, j))
261 mc->ctrl.cMultipleItems++;
262 lstrcpynA(mc->ctrl.szShortName, "Mixer", MIXER_SHORT_NAME_CHARS);
263 lstrcpynA(mc->ctrl.szName, "Mixer", MIXER_LONG_NAME_CHARS);
264 memset(&mc->ctrl.Bounds, 0, sizeof(mc->ctrl.Bounds));
265 memset(&mc->ctrl.Metrics, 0, sizeof(mc->ctrl.Metrics));
269 FIXME("Internal error: unknown type: %08lx\n", dwType);
271 TRACE("ctrl[%2d]: typ=%08lx lin=%08lx\n", c + 1, dwType, lineID);
274 /******************************************************************
279 static struct mixer* MIX_Get(WORD wDevID)
281 TRACE("(%04x)\n", wDevID);
283 if (wDevID >= MIX_NumMixers || MIX_Mixers[wDevID].name == NULL)
286 return &MIX_Mixers[wDevID];
289 /**************************************************************************
290 * MIX_Open [internal]
292 static DWORD MIX_Open(WORD wDevID, LPMIXEROPENDESC lpMod, DWORD flags)
297 DWORD ret = MMSYSERR_NOERROR;
299 TRACE("(%04X, %p, %lu);\n", wDevID, lpMod, flags);
301 /* as we partly init the mixer with MIX_Open, we can allow null open decs
302 * EPP if (lpMod == NULL) return MMSYSERR_INVALPARAM;
303 * anyway, it seems that WINMM/MMSYSTEM doesn't always open the mixer
304 * device before sending messages to it... it seems to be linked to all
305 * the equivalent of mixer identification
306 * (with a reference to a wave, midi.. handle
308 if (!(mix = MIX_Get(wDevID))) {
309 WARN("bad device ID\n");
310 return MMSYSERR_BADDEVICEID;
313 if ((mixer = open(mix->name, O_RDWR)) < 0)
315 ERR("open(%s, O_RDWR) failed (%s)\n",
316 mix->name, strerror(errno));
318 if (errno == ENODEV || errno == ENXIO)
320 /* no driver present */
322 return MMSYSERR_NODRIVER;
324 return MMSYSERR_ERROR;
327 if (ioctl(mixer, SOUND_MIXER_READ_DEVMASK, &mix->devMask) == -1)
329 ERR("ioctl(%s, SOUND_MIXER_DEVMASK) failed (%s)\n",
330 mix->name, strerror(errno));
331 ret = MMSYSERR_ERROR;
335 mix->devMask &= WINE_MIXER_MASK_SPEAKER;
336 if (mix->devMask == 0)
339 ret = MMSYSERR_NODRIVER;
343 if (ioctl(mixer, SOUND_MIXER_READ_STEREODEVS, &mix->stereoMask) == -1)
345 ERR("ioctl(%s, SOUND_MIXER_STEREODEVS) failed (%s)\n",
346 mix->name, strerror(errno));
347 ret = MMSYSERR_ERROR;
350 mix->stereoMask &= WINE_MIXER_MASK_SPEAKER;
352 if (ioctl(mixer, SOUND_MIXER_READ_RECMASK, &mix->recMask) == -1)
354 ERR("ioctl(%s, SOUND_MIXER_RECMASK) failed (%s)\n",
355 mix->name, strerror(errno));
356 ret = MMSYSERR_ERROR;
359 mix->recMask &= WINE_MIXER_MASK_RECORD;
360 /* FIXME: we may need to support both rec lev & igain */
361 if (!WINE_CHN_SUPPORTS(mix->recMask, SOUND_MIXER_RECLEV))
363 WARN("The sound card doesn't support rec level\n");
364 if (WINE_CHN_SUPPORTS(mix->recMask, SOUND_MIXER_IGAIN))
365 WARN("but it does support IGain, please report\n");
367 if (ioctl(mixer, SOUND_MIXER_READ_CAPS, &caps) == -1)
369 ERR("ioctl(%s, SOUND_MIXER_READ_CAPS) failed (%s)\n",
370 mix->name, strerror(errno));
371 ret = MMSYSERR_ERROR;
374 mix->singleRecChannel = caps & SOUND_CAP_EXCL_INPUT;
375 TRACE("dev=%04x rec=%04x stereo=%04x %s\n",
376 mix->devMask, mix->recMask, mix->stereoMask,
377 mix->singleRecChannel ? "single" : "multiple");
378 for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
382 mix->numCtrl = 4; /* dst lines... vol&mute on speakers, vol&onoff on rec */
383 /* FIXME: do we always have RECLEV on all cards ??? */
384 for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
386 if (WINE_CHN_SUPPORTS(mix->devMask, i))
387 mix->numCtrl += 2; /* volume & mute */
388 if (WINE_CHN_SUPPORTS(mix->recMask, i))
389 mix->numCtrl += 2; /* volume & onoff */
392 if (!(mix->ctrl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
393 sizeof(mix->ctrl[0]) * mix->numCtrl)))
395 ret = MMSYSERR_NOMEM;
400 MIX_FillLineControls(mix, j++, MAKELONG(0, LINEID_DST),
401 MIXERCONTROL_CONTROLTYPE_VOLUME);
402 MIX_FillLineControls(mix, j++, MAKELONG(0, LINEID_DST),
403 MIXERCONTROL_CONTROLTYPE_MUTE);
404 MIX_FillLineControls(mix, j++, MAKELONG(1, LINEID_DST),
405 mix->singleRecChannel ?
406 MIXERCONTROL_CONTROLTYPE_MUX :
407 MIXERCONTROL_CONTROLTYPE_MIXER);
408 MIX_FillLineControls(mix, j++, MAKELONG(1, LINEID_DST),
409 MIXERCONTROL_CONTROLTYPE_MUTE/*EPP*/);
410 for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
412 if (WINE_CHN_SUPPORTS(mix->devMask, i))
414 MIX_FillLineControls(mix, j++, MAKELONG(LINEID_SPEAKER, i),
415 MIXERCONTROL_CONTROLTYPE_VOLUME);
416 MIX_FillLineControls(mix, j++, MAKELONG(LINEID_SPEAKER, i),
417 MIXERCONTROL_CONTROLTYPE_MUTE);
420 for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
422 if (WINE_CHN_SUPPORTS(mix->recMask, i))
424 MIX_FillLineControls(mix, j++, MAKELONG(LINEID_RECORD, i),
425 MIXERCONTROL_CONTROLTYPE_VOLUME);
426 MIX_FillLineControls(mix, j++, MAKELONG(LINEID_RECORD, i),
427 MIXERCONTROL_CONTROLTYPE_MUTE/*EPP*/);
430 assert(j == mix->numCtrl);
436 /**************************************************************************
437 * MIX_GetVal [internal]
439 static BOOL MIX_GetVal(struct mixer* mix, int chn, int* val)
444 TRACE("(%p, %s, %p\n", mix, getIoctlCommand(chn), val);
446 if ((mixer = open(mix->name, O_RDWR)) < 0) {
447 /* FIXME: ENXIO => no mixer installed */
448 WARN("mixer device not available !\n");
450 if (ioctl(mixer, MIXER_READ(chn), val) >= 0) {
451 TRACE("Reading %04x for %s\n", *val, getIoctlCommand(chn));
454 ERR("ioctl(%s, MIXER_READ(%s)) failed (%s)\n",
455 mix->name, getIoctlCommand(chn), strerror(errno));
462 /**************************************************************************
463 * MIX_SetVal [internal]
465 static BOOL MIX_SetVal(struct mixer* mix, int chn, int val)
470 TRACE("(%p, %s, %x)\n", mix, getIoctlCommand(chn), val);
472 if ((mixer = open(mix->name, O_RDWR)) < 0) {
473 /* FIXME: ENXIO => no mixer installed */
474 WARN("mixer device not available !\n");
476 if (ioctl(mixer, MIXER_WRITE(chn), &val) >= 0) {
477 TRACE("Set %s to %04x\n", getIoctlCommand(chn), val);
480 ERR("ioctl(%s, MIXER_WRITE(%s)) failed (%s)\n",
481 mix->name, getIoctlCommand(chn), strerror(errno));
488 /******************************************************************
493 static BOOL MIX_GetRecSrc(struct mixer* mix, unsigned* mask)
498 TRACE("(%p, %p)\n", mix, mask);
500 if ((mixer = open(mix->name, O_RDWR)) >= 0) {
501 if (ioctl(mixer, SOUND_MIXER_READ_RECSRC, &mask) >= 0) {
504 ERR("ioctl(%s, SOUND_MIXER_READ_RECSRC) failed (%s)\n",
505 mix->name, strerror(errno));
512 /******************************************************************
517 static BOOL MIX_SetRecSrc(struct mixer* mix, unsigned mask)
522 TRACE("(%p, %08x)\n", mix, mask);
524 if ((mixer = open(mix->name, O_RDWR)) >= 0) {
525 if (ioctl(mixer, SOUND_MIXER_WRITE_RECSRC, &mask) >= 0) {
528 ERR("ioctl(%s, SOUND_MIXER_WRITE_RECSRC) failed (%s)\n",
529 mix->name, strerror(errno));
536 /**************************************************************************
537 * MIX_GetDevCaps [internal]
539 static DWORD MIX_GetDevCaps(WORD wDevID, LPMIXERCAPSA lpCaps, DWORD dwSize)
544 TRACE("(%04X, %p, %lu);\n", wDevID, lpCaps, dwSize);
546 if (lpCaps == NULL) {
547 WARN("invalid parameter: lpCaps == NULL\n");
548 return MMSYSERR_INVALPARAM;
551 if (!(mix = MIX_Get(wDevID))) {
552 WARN("bad device ID\n");
553 return MMSYSERR_BADDEVICEID;
556 capsA.wMid = WINE_MIXER_MANUF_ID;
557 capsA.wPid = WINE_MIXER_PRODUCT_ID;
558 capsA.vDriverVersion = WINE_MIXER_VERSION;
559 strcpy(capsA.szPname, WINE_MIXER_NAME);
561 capsA.cDestinations = 2; /* speakers & record */
562 capsA.fdwSupport = 0; /* No bits defined yet */
564 memcpy(lpCaps, &capsA, min(dwSize, sizeof(capsA)));
566 return MMSYSERR_NOERROR;
569 /**************************************************************************
570 * MIX_GetLineInfoDst [internal]
572 static DWORD MIX_GetLineInfoDst(struct mixer* mix, LPMIXERLINEA lpMl,
578 TRACE("(%p, %p, %08lx)\n", mix, lpMl, dst);
580 lpMl->dwDestination = dst;
584 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
586 j = SOUND_MIXER_VOLUME;
589 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
591 j = SOUND_MIXER_RECLEV;
594 FIXME("shouldn't happen\n");
595 return MMSYSERR_ERROR;
597 lpMl->dwSource = 0xFFFFFFFF;
598 lstrcpynA(lpMl->szShortName, MIX_Labels[j], MIXER_SHORT_NAME_CHARS);
599 lstrcpynA(lpMl->szName, MIX_Names[j], MIXER_LONG_NAME_CHARS);
601 /* we have all connections found in the MIX_DevMask */
602 lpMl->cConnections = 0;
603 for (j = 0; j < SOUND_MIXER_NRDEVICES; j++)
604 if (WINE_CHN_SUPPORTS(mask, j))
605 lpMl->cConnections++;
607 if (WINE_CHN_SUPPORTS(mix->stereoMask, lpMl->dwLineID))
609 lpMl->dwLineID = MAKELONG(dst, LINEID_DST);
611 for (j = 0; j < mix->numCtrl; j++)
612 if (mix->ctrl[j].dwLineID == lpMl->dwLineID)
615 return MMSYSERR_NOERROR;
618 /**************************************************************************
619 * MIX_GetLineInfoSrc [internal]
621 static DWORD MIX_GetLineInfoSrc(struct mixer* mix, LPMIXERLINEA lpMl,
622 DWORD idx, DWORD dst)
625 unsigned mask = (dst) ? mix->recMask : mix->devMask;
627 TRACE("(%p, %p, %ld, %08lx)\n", mix, lpMl, idx, dst);
629 strcpy(lpMl->szShortName, MIX_Labels[idx]);
630 strcpy(lpMl->szName, MIX_Names[idx]);
631 lpMl->dwLineID = MAKELONG(dst, idx);
632 lpMl->dwDestination = dst;
633 lpMl->cConnections = 1;
635 for (i = 0; i < mix->numCtrl; i++)
636 if (mix->ctrl[i].dwLineID == lpMl->dwLineID)
641 case SOUND_MIXER_SYNTH:
642 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER;
643 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
646 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC;
647 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
649 case SOUND_MIXER_LINE:
650 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_LINE;
651 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
653 case SOUND_MIXER_MIC:
654 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE;
655 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
657 case SOUND_MIXER_PCM:
658 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
659 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
661 case SOUND_MIXER_IMIX:
662 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED;
663 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
666 WARN("Index %ld not handled.\n", idx);
667 return MIXERR_INVALLINE;
670 if (dst == 0 && WINE_CHN_SUPPORTS(mix->stereoMask, idx))
672 for (i = j = 0; j < SOUND_MIXER_NRDEVICES; j++)
674 if (WINE_CHN_SUPPORTS(mask, j))
681 return MMSYSERR_NOERROR;
684 /******************************************************************
687 static BOOL MIX_CheckLine(DWORD lineID)
689 TRACE("(%08lx)\n",lineID);
691 return ((HIWORD(lineID) < SOUND_MIXER_NRDEVICES && LOWORD(lineID) < 2) ||
692 (HIWORD(lineID) == LINEID_DST &&
693 LOWORD(lineID) < SOUND_MIXER_NRDEVICES));
696 /**************************************************************************
697 * MIX_GetLineInfo [internal]
699 static DWORD MIX_GetLineInfo(WORD wDevID, LPMIXERLINEA lpMl, DWORD fdwInfo)
702 DWORD ret = MMSYSERR_NOERROR;
706 TRACE("(%04X, %p, %lu);\n", wDevID, lpMl, fdwInfo);
708 if (lpMl == NULL || lpMl->cbStruct != sizeof(*lpMl)) {
709 WARN("invalid parameter\n");
710 return MMSYSERR_INVALPARAM;
713 if ((mix = MIX_Get(wDevID)) == NULL) {
714 WARN("bad device ID\n");
715 return MMSYSERR_BADDEVICEID;
718 /* FIXME: set all the variables correctly... the lines below
721 lpMl->fdwLine = MIXERLINE_LINEF_ACTIVE;
724 switch (fdwInfo & MIXER_GETLINEINFOF_QUERYMASK)
726 case MIXER_GETLINEINFOF_DESTINATION:
727 TRACE("MIXER_GETLINEINFOF_DESTINATION (%08lx)\n", lpMl->dwDestination);
728 if (lpMl->dwDestination >= 2) {
729 WARN("invalid parameter\n");
730 return MMSYSERR_INVALPARAM;
732 ret = MIX_GetLineInfoDst(mix, lpMl, lpMl->dwDestination);
733 if (ret != MMSYSERR_NOERROR) {
738 case MIXER_GETLINEINFOF_SOURCE:
739 TRACE("MIXER_GETLINEINFOF_SOURCE (%08lx), dst=%08lx\n", lpMl->dwSource,
740 lpMl->dwDestination);
741 switch (lpMl->dwDestination)
743 case 0: mask = mix->devMask; break;
744 case 1: mask = mix->recMask; break;
746 WARN("invalid parameter\n");
747 return MMSYSERR_INVALPARAM;
750 for (j = 0; j < SOUND_MIXER_NRDEVICES; j++)
752 if (WINE_CHN_SUPPORTS(mask, j) && (i-- == 0))
755 if (j >= SOUND_MIXER_NRDEVICES) {
756 WARN("invalid line\n");
757 return MIXERR_INVALLINE;
759 ret = MIX_GetLineInfoSrc(mix, lpMl, j, lpMl->dwDestination);
760 if (ret != MMSYSERR_NOERROR) {
765 case MIXER_GETLINEINFOF_LINEID:
766 TRACE("MIXER_GETLINEINFOF_LINEID (%08lx)\n", lpMl->dwLineID);
768 if (!MIX_CheckLine(lpMl->dwLineID)) {
769 WARN("invalid line\n");
770 return MIXERR_INVALLINE;
772 if (HIWORD(lpMl->dwLineID) == LINEID_DST)
773 ret = MIX_GetLineInfoDst(mix, lpMl, LOWORD(lpMl->dwLineID));
775 ret = MIX_GetLineInfoSrc(mix, lpMl, HIWORD(lpMl->dwLineID),
776 LOWORD(lpMl->dwLineID));
777 if (ret != MMSYSERR_NOERROR) {
782 case MIXER_GETLINEINFOF_COMPONENTTYPE:
783 TRACE("MIXER_GETLINEINFOF_COMPONENTTYPE (%08lx)\n",
784 lpMl->dwComponentType);
785 switch (lpMl->dwComponentType)
787 case MIXERLINE_COMPONENTTYPE_DST_SPEAKERS:
788 ret = MIX_GetLineInfoDst(mix, lpMl, 0);
790 case MIXERLINE_COMPONENTTYPE_DST_WAVEIN:
791 ret = MIX_GetLineInfoDst(mix, lpMl, 1);
793 case MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER:
794 ret = MIX_GetLineInfoSrc(mix, lpMl, SOUND_MIXER_SYNTH, 0);
796 case MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC:
797 ret = MIX_GetLineInfoSrc(mix, lpMl, SOUND_MIXER_CD, 0);
799 case MIXERLINE_COMPONENTTYPE_SRC_LINE:
800 ret = MIX_GetLineInfoSrc(mix, lpMl, SOUND_MIXER_LINE, 0);
802 case MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE:
803 ret = MIX_GetLineInfoSrc(mix, lpMl, SOUND_MIXER_MIC, 1);
805 case MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT:
806 ret = MIX_GetLineInfoSrc(mix, lpMl, SOUND_MIXER_PCM, 0);
808 case MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED:
809 ret = MIX_GetLineInfoSrc(mix, lpMl, SOUND_MIXER_IMIX, 1);
812 FIXME("Unhandled component type (%08lx)\n", lpMl->dwComponentType);
813 return MMSYSERR_INVALPARAM;
816 case MIXER_GETLINEINFOF_TARGETTYPE:
817 FIXME("MIXER_GETLINEINFOF_TARGETTYPE not implemented yet.\n");
820 WARN("Unknown flag (%08lx)\n", fdwInfo & MIXER_GETLINEINFOF_QUERYMASK);
824 lpMl->Target.dwType = MIXERLINE_TARGETTYPE_AUX; /* FIXME */
825 lpMl->Target.dwDeviceID = 0xFFFFFFFF;
826 lpMl->Target.wMid = WINE_MIXER_MANUF_ID;
827 lpMl->Target.wPid = WINE_MIXER_PRODUCT_ID;
828 lpMl->Target.vDriverVersion = WINE_MIXER_VERSION;
829 strcpy(lpMl->Target.szPname, WINE_MIXER_NAME);
834 /******************************************************************
838 static BOOL MIX_CheckControl(struct mixer* mix, DWORD ctrlID)
840 TRACE("(%p, %08lx)\n", mix, ctrlID);
842 return (ctrlID >= 1 && ctrlID <= mix->numCtrl);
845 /**************************************************************************
846 * MIX_GetLineControls [internal]
848 static DWORD MIX_GetLineControls(WORD wDevID, LPMIXERLINECONTROLSA lpMlc,
851 DWORD dwRet = MMSYSERR_NOERROR;
854 TRACE("(%04X, %p, %lu);\n", wDevID, lpMlc, flags);
857 WARN("invalid parameter: lpMlc == NULL\n");
858 return MMSYSERR_INVALPARAM;
861 if (lpMlc->cbStruct < sizeof(*lpMlc) ||
862 lpMlc->cbmxctrl < sizeof(MIXERCONTROLA)) {
863 WARN("invalid parameter: lpMlc\n");
864 return MMSYSERR_INVALPARAM;
867 if ((mix = MIX_Get(wDevID)) == NULL) {
868 WARN("bad device id\n");
869 return MMSYSERR_BADDEVICEID;
872 switch (flags & MIXER_GETLINECONTROLSF_QUERYMASK)
874 case MIXER_GETLINECONTROLSF_ALL:
878 TRACE("line=%08lx MIXER_GETLINECONTROLSF_ALL (%ld)\n",
879 lpMlc->dwLineID, lpMlc->cControls);
881 for (i = j = 0; i < mix->numCtrl; i++)
883 if (mix->ctrl[i].dwLineID == lpMlc->dwLineID)
887 if (!j || lpMlc->cControls != j) {
888 WARN("invalid parameter\n");
889 dwRet = MMSYSERR_INVALPARAM;
890 } else if (!MIX_CheckLine(lpMlc->dwLineID)) {
891 WARN("invalid line\n");
892 dwRet = MIXERR_INVALLINE;
894 for (i = j = 0; i < mix->numCtrl; i++)
896 if (mix->ctrl[i].dwLineID == lpMlc->dwLineID)
898 TRACE("[%d] => [%2d]: typ=%08lx\n", j, i + 1,
899 mix->ctrl[i].ctrl.dwControlType);
900 lpMlc->pamxctrl[j++] = mix->ctrl[i].ctrl;
906 case MIXER_GETLINECONTROLSF_ONEBYID:
907 TRACE("line=%08lx MIXER_GETLINECONTROLSF_ONEBYID (%lx)\n",
908 lpMlc->dwLineID, lpMlc->u.dwControlID);
910 if (!MIX_CheckControl(mix, lpMlc->u.dwControlID) ||
911 mix->ctrl[lpMlc->u.dwControlID - 1].dwLineID != lpMlc->dwLineID) {
912 WARN("invalid parameter\n");
913 dwRet = MMSYSERR_INVALPARAM;
915 lpMlc->pamxctrl[0] = mix->ctrl[lpMlc->u.dwControlID - 1].ctrl;
917 case MIXER_GETLINECONTROLSF_ONEBYTYPE:
918 TRACE("line=%08lx MIXER_GETLINECONTROLSF_ONEBYTYPE (%s)\n",
919 lpMlc->dwLineID, getControlType(lpMlc->u.dwControlType));
920 if (!MIX_CheckLine(lpMlc->dwLineID)) {
921 WARN("invalid line\n");
922 dwRet = MIXERR_INVALLINE;
925 DWORD ct = lpMlc->u.dwControlType & MIXERCONTROL_CT_CLASS_MASK;
926 for (i = 0; i < mix->numCtrl; i++) {
927 if (mix->ctrl[i].dwLineID == lpMlc->dwLineID &&
928 ct == (mix->ctrl[i].ctrl.dwControlType &
929 MIXERCONTROL_CT_CLASS_MASK)) {
930 lpMlc->pamxctrl[0] = mix->ctrl[i].ctrl;
935 if (i == mix->numCtrl) {
936 WARN("invalid parameter: control not found\n");
937 dwRet = MMSYSERR_INVALPARAM;
942 ERR("Unknown flag %08lx\n", flags & MIXER_GETLINECONTROLSF_QUERYMASK);
943 dwRet = MMSYSERR_INVALPARAM;
949 /**************************************************************************
950 * MIX_GetControlDetails [internal]
952 static DWORD MIX_GetControlDetails(WORD wDevID, LPMIXERCONTROLDETAILS lpmcd,
955 DWORD ret = MMSYSERR_NOTSUPPORTED;
959 TRACE("(%04X, %p, %lu);\n", wDevID, lpmcd, fdwDetails);
962 WARN("invalid parameter: lpmcd == NULL\n");
963 return MMSYSERR_INVALPARAM;
966 if ((mix = MIX_Get(wDevID)) == NULL) {
967 WARN("bad device ID\n");
968 return MMSYSERR_BADDEVICEID;
971 switch (fdwDetails & MIXER_GETCONTROLDETAILSF_QUERYMASK)
973 case MIXER_GETCONTROLDETAILSF_VALUE:
974 TRACE("MIXER_GETCONTROLDETAILSF_VALUE (%08lx)\n", lpmcd->dwControlID);
975 if (MIX_CheckControl(mix, lpmcd->dwControlID))
977 c = lpmcd->dwControlID - 1;
978 chnl = HIWORD(mix->ctrl[c].dwLineID);
979 if (chnl == LINEID_DST)
980 chnl = LOWORD(mix->ctrl[c].dwLineID) ? SOUND_MIXER_RECLEV :
982 switch (mix->ctrl[c].ctrl.dwControlType)
984 case MIXERCONTROL_CONTROLTYPE_VOLUME:
986 LPMIXERCONTROLDETAILS_UNSIGNED mcdu;
989 if (lpmcd->cbDetails !=
990 sizeof(MIXERCONTROLDETAILS_UNSIGNED)) {
991 WARN("invalid parameter: cbDetails != %d\n",
992 sizeof(MIXERCONTROLDETAILS_UNSIGNED));
993 return MMSYSERR_INVALPARAM;
996 TRACE("%s MIXERCONTROLDETAILS_UNSIGNED[%lu]\n",
997 getControlType(mix->ctrl[c].ctrl.dwControlType),
1000 mcdu = (LPMIXERCONTROLDETAILS_UNSIGNED)lpmcd->paDetails;
1002 /* return value is 00RL (4 bytes)... */
1003 if ((val = mix->volume[chnl]) == -1 &&
1004 !MIX_GetVal(mix, chnl, &val)) {
1005 WARN("invalid parameter\n");
1006 return MMSYSERR_INVALPARAM;
1009 switch (lpmcd->cChannels)
1013 /* mono... so R = L */
1014 mcdu->dwValue = (LOBYTE(LOWORD(val)) * 65536L) / 100;
1018 /* stereo, left is paDetails[0] */
1019 mcdu->dwValue = (LOBYTE(LOWORD(val)) * 65536L) / 100;
1021 mcdu->dwValue = (HIBYTE(LOWORD(val)) * 65536L) / 100;
1024 WARN("Unsupported cChannels (%ld)\n", lpmcd->cChannels);
1025 return MMSYSERR_INVALPARAM;
1027 TRACE("=> %08lx\n", mcdu->dwValue);
1030 case MIXERCONTROL_CONTROLTYPE_MUTE:
1031 case MIXERCONTROL_CONTROLTYPE_ONOFF:
1033 LPMIXERCONTROLDETAILS_BOOLEAN mcdb;
1035 if (lpmcd->cbDetails !=
1036 sizeof(MIXERCONTROLDETAILS_BOOLEAN)) {
1037 WARN("invalid parameter: cbDetails != %d\n",
1038 sizeof(MIXERCONTROLDETAILS_BOOLEAN));
1039 return MMSYSERR_INVALPARAM;
1042 TRACE("%s MIXERCONTROLDETAILS_BOOLEAN[%lu]\n",
1043 getControlType(mix->ctrl[c].ctrl.dwControlType),
1046 /* we mute both channels at the same time */
1047 mcdb = (LPMIXERCONTROLDETAILS_BOOLEAN)lpmcd->paDetails;
1048 mcdb->fValue = (mix->volume[chnl] != -1);
1049 TRACE("=> %s\n", mcdb->fValue ? "on" : "off");
1052 case MIXERCONTROL_CONTROLTYPE_MIXER:
1053 case MIXERCONTROL_CONTROLTYPE_MUX:
1057 if (lpmcd->cbDetails !=
1058 sizeof(MIXERCONTROLDETAILS_BOOLEAN)) {
1059 WARN("invalid parameter: cbDetails != %d\n",
1060 sizeof(MIXERCONTROLDETAILS_BOOLEAN));
1061 return MMSYSERR_INVALPARAM;
1064 TRACE("%s MIXERCONTROLDETAILS_BOOLEAN[%lu]\n",
1065 getControlType(mix->ctrl[c].ctrl.dwControlType),
1068 if (!MIX_GetRecSrc(mix, &mask))
1070 /* FIXME: ENXIO => no mixer installed */
1071 WARN("mixer device not available !\n");
1072 ret = MMSYSERR_ERROR;
1076 LPMIXERCONTROLDETAILS_BOOLEAN mcdb;
1079 /* we mute both channels at the same time */
1080 mcdb = (LPMIXERCONTROLDETAILS_BOOLEAN)lpmcd->paDetails;
1082 for (i = j = 0; j < SOUND_MIXER_NRDEVICES; j++)
1084 if (WINE_CHN_SUPPORTS(mix->recMask, j))
1086 if (i >= lpmcd->u.cMultipleItems)
1087 return MMSYSERR_INVALPARAM;
1088 mcdb[i++].fValue = WINE_CHN_SUPPORTS(mask, j);
1095 WARN("%s Unsupported\n",
1096 getControlType(mix->ctrl[c].ctrl.dwControlType));
1098 ret = MMSYSERR_NOERROR;
1102 WARN("invalid parameter\n");
1103 ret = MMSYSERR_INVALPARAM;
1106 case MIXER_GETCONTROLDETAILSF_LISTTEXT:
1107 TRACE("MIXER_GETCONTROLDETAILSF_LISTTEXT (%08lx)\n",
1108 lpmcd->dwControlID);
1110 ret = MMSYSERR_INVALPARAM;
1111 if (MIX_CheckControl(mix, lpmcd->dwControlID))
1113 int c = lpmcd->dwControlID - 1;
1115 if (mix->ctrl[c].ctrl.dwControlType == MIXERCONTROL_CONTROLTYPE_MUX ||
1116 mix->ctrl[c].ctrl.dwControlType == MIXERCONTROL_CONTROLTYPE_MIXER)
1118 LPMIXERCONTROLDETAILS_LISTTEXTA mcdlt;
1121 mcdlt = (LPMIXERCONTROLDETAILS_LISTTEXTA)lpmcd->paDetails;
1122 for (i = j = 0; j < SOUND_MIXER_NRDEVICES; j++)
1124 if (WINE_CHN_SUPPORTS(mix->recMask, j))
1126 mcdlt[i].dwParam1 = MAKELONG(LINEID_RECORD, j);
1127 mcdlt[i].dwParam2 = 0;
1128 strcpy(mcdlt[i].szName, MIX_Names[j]);
1132 if (i != lpmcd->u.cMultipleItems) FIXME("bad count\n");
1133 ret = MMSYSERR_NOERROR;
1138 WARN("Unknown flag (%08lx)\n",
1139 fdwDetails & MIXER_GETCONTROLDETAILSF_QUERYMASK);
1144 /**************************************************************************
1145 * MIX_SetControlDetails [internal]
1147 static DWORD MIX_SetControlDetails(WORD wDevID, LPMIXERCONTROLDETAILS lpmcd,
1150 DWORD ret = MMSYSERR_NOTSUPPORTED;
1155 TRACE("(%04X, %p, %lu);\n", wDevID, lpmcd, fdwDetails);
1157 if (lpmcd == NULL) {
1158 TRACE("invalid parameter: lpmcd == NULL\n");
1159 return MMSYSERR_INVALPARAM;
1162 if ((mix = MIX_Get(wDevID)) == NULL) {
1163 WARN("bad device ID\n");
1164 return MMSYSERR_BADDEVICEID;
1167 switch (fdwDetails & MIXER_GETCONTROLDETAILSF_QUERYMASK)
1169 case MIXER_GETCONTROLDETAILSF_VALUE:
1170 TRACE("MIXER_GETCONTROLDETAILSF_VALUE (%08lx)\n", lpmcd->dwControlID);
1171 if (MIX_CheckControl(mix, lpmcd->dwControlID))
1173 c = lpmcd->dwControlID - 1;
1175 TRACE("dwLineID=%08lx\n",mix->ctrl[c].dwLineID);
1177 chnl = HIWORD(mix->ctrl[c].dwLineID);
1178 if (chnl == LINEID_DST)
1179 chnl = LOWORD(mix->ctrl[c].dwLineID) ?
1180 SOUND_MIXER_RECLEV : SOUND_MIXER_VOLUME;
1182 switch (mix->ctrl[c].ctrl.dwControlType)
1184 case MIXERCONTROL_CONTROLTYPE_VOLUME:
1186 LPMIXERCONTROLDETAILS_UNSIGNED mcdu;
1188 if (lpmcd->cbDetails !=
1189 sizeof(MIXERCONTROLDETAILS_UNSIGNED)) {
1190 WARN("invalid parameter: cbDetails != %d\n",
1191 sizeof(MIXERCONTROLDETAILS_UNSIGNED));
1192 return MMSYSERR_INVALPARAM;
1195 TRACE("%s MIXERCONTROLDETAILS_UNSIGNED[%lu]\n",
1196 getControlType(mix->ctrl[c].ctrl.dwControlType),
1199 mcdu = (LPMIXERCONTROLDETAILS_UNSIGNED)lpmcd->paDetails;
1200 /* val should contain 00RL */
1201 switch (lpmcd->cChannels)
1204 /* mono... so R = L */
1205 TRACE("Setting RL to %ld\n", mcdu->dwValue);
1206 val = 0x101 * ((mcdu->dwValue * 100) >> 16);
1209 /* stereo, left is paDetails[0] */
1210 TRACE("Setting L to %ld\n", mcdu->dwValue);
1211 val = ((mcdu->dwValue * 100) >> 16);
1213 TRACE("Setting R to %ld\n", mcdu->dwValue);
1214 val += ((mcdu->dwValue * 100) >> 16) << 8;
1217 WARN("Unsupported cChannels (%ld)\n", lpmcd->cChannels);
1218 return MMSYSERR_INVALPARAM;
1221 if (mix->volume[chnl] == -1)
1223 if (!MIX_SetVal(mix, chnl, val)) {
1224 WARN("invalid parameter\n");
1225 return MMSYSERR_INVALPARAM;
1230 mix->volume[chnl] = val;
1233 ret = MMSYSERR_NOERROR;
1235 case MIXERCONTROL_CONTROLTYPE_MUTE:
1236 case MIXERCONTROL_CONTROLTYPE_ONOFF:
1238 LPMIXERCONTROLDETAILS_BOOLEAN mcdb;
1240 if (lpmcd->cbDetails !=
1241 sizeof(MIXERCONTROLDETAILS_BOOLEAN)) {
1242 WARN("invalid parameter: cbDetails != %d\n",
1243 sizeof(MIXERCONTROLDETAILS_BOOLEAN));
1244 return MMSYSERR_INVALPARAM;
1247 TRACE("%s MIXERCONTROLDETAILS_BOOLEAN[%lu]\n",
1248 getControlType(mix->ctrl[c].ctrl.dwControlType),
1251 mcdb = (LPMIXERCONTROLDETAILS_BOOLEAN)lpmcd->paDetails;
1254 /* save the volume and then set it to 0 */
1255 if (!MIX_GetVal(mix, chnl, &mix->volume[chnl]) ||
1256 !MIX_SetVal(mix, chnl, 0)) {
1257 WARN("invalid parameter\n");
1258 return MMSYSERR_INVALPARAM;
1263 if (mix->volume[chnl] == -1)
1265 ret = MMSYSERR_NOERROR;
1268 if (!MIX_SetVal(mix, chnl, mix->volume[chnl])) {
1269 WARN("invalid parameter\n");
1270 return MMSYSERR_INVALPARAM;
1272 mix->volume[chnl] = -1;
1275 ret = MMSYSERR_NOERROR;
1277 case MIXERCONTROL_CONTROLTYPE_MIXER:
1278 case MIXERCONTROL_CONTROLTYPE_MUX:
1280 LPMIXERCONTROLDETAILS_BOOLEAN mcdb;
1284 if (lpmcd->cbDetails !=
1285 sizeof(MIXERCONTROLDETAILS_BOOLEAN)) {
1286 WARN("invalid parameter: cbDetails != %d\n",
1287 sizeof(MIXERCONTROLDETAILS_BOOLEAN));
1288 return MMSYSERR_INVALPARAM;
1291 TRACE("%s MIXERCONTROLDETAILS_BOOLEAN[%lu]\n",
1292 getControlType(mix->ctrl[c].ctrl.dwControlType),
1295 /* we mute both channels at the same time */
1296 mcdb = (LPMIXERCONTROLDETAILS_BOOLEAN)lpmcd->paDetails;
1298 for (i = j = 0; j < SOUND_MIXER_NRDEVICES; j++)
1300 if (WINE_CHN_SUPPORTS(mix->recMask, j) &&
1303 /* a mux can only select one line at a time... */
1304 if (mix->singleRecChannel && mask != 0)
1307 return MMSYSERR_INVALPARAM;
1309 mask |= WINE_CHN_MASK(j);
1312 if (i != lpmcd->u.cMultipleItems)
1313 FIXME("bad count\n");
1314 TRACE("writing %04x as rec src\n", mask);
1315 if (!MIX_SetRecSrc(mix, mask))
1316 ERR("Can't write new mixer settings\n");
1318 ret = MMSYSERR_NOERROR;
1325 WARN("Unknown SetControlDetails flag (%08lx)\n",
1326 fdwDetails & MIXER_GETCONTROLDETAILSF_QUERYMASK);
1331 /**************************************************************************
1332 * MIX_Init [internal]
1334 static DWORD MIX_Init(void)
1340 #define MIXER_DEV "/dev/mixer"
1341 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0)
1343 if (errno == ENODEV || errno == ENXIO)
1345 /* no driver present */
1346 WARN("no driver\n");
1347 return MMSYSERR_NODRIVER;
1350 return MMSYSERR_ERROR;
1354 MIX_Mixers[0].name = MIXER_DEV;
1355 MIX_Open(0, NULL, 0); /* FIXME */
1357 return MMSYSERR_NOERROR;
1360 /**************************************************************************
1361 * MIX_GetNumDevs [internal]
1363 static DWORD MIX_GetNumDevs(void)
1367 return MIX_NumMixers;
1370 #endif /* HAVE_OSS */
1372 /**************************************************************************
1373 * mxdMessage (WINEOSS.3)
1375 DWORD WINAPI OSS_mxdMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
1376 DWORD dwParam1, DWORD dwParam2)
1378 TRACE("(%04X, %s, %08lX, %08lX, %08lX);\n", wDevID, getMessage(wMsg),
1379 dwUser, dwParam1, dwParam2);
1389 /* FIXME: Pretend this is supported */
1391 case MXDM_GETDEVCAPS:
1392 return MIX_GetDevCaps(wDevID, (LPMIXERCAPSA)dwParam1, dwParam2);
1393 case MXDM_GETLINEINFO:
1394 return MIX_GetLineInfo(wDevID, (LPMIXERLINEA)dwParam1, dwParam2);
1395 case MXDM_GETNUMDEVS:
1396 return MIX_GetNumDevs();
1398 return MMSYSERR_NOERROR;
1399 /* MIX_Open(wDevID, (LPMIXEROPENDESC)dwParam1, dwParam2); */
1401 return MMSYSERR_NOERROR;
1402 case MXDM_GETLINECONTROLS:
1403 return MIX_GetLineControls(wDevID, (LPMIXERLINECONTROLSA)dwParam1, dwParam2);
1404 case MXDM_GETCONTROLDETAILS:
1405 return MIX_GetControlDetails(wDevID, (LPMIXERCONTROLDETAILS)dwParam1, dwParam2);
1406 case MXDM_SETCONTROLDETAILS:
1407 return MIX_SetControlDetails(wDevID, (LPMIXERCONTROLDETAILS)dwParam1, dwParam2);
1409 WARN("unknown message %d!\n", wMsg);
1410 return MMSYSERR_NOTSUPPORTED;
1413 return MMSYSERR_NOTENABLED;