1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
4 * Sample MIXER Wine Driver for Linux
6 * Copyright 1997 Marcus Meissner
17 #include <sys/ioctl.h>
23 #include "debugtools.h"
25 DEFAULT_DEBUG_CHANNEL(mmaux);
29 #define MIXER_DEV "/dev/mixer"
31 #define WINE_MIXER_MANUF_ID 0xAA
32 #define WINE_MIXER_PRODUCT_ID 0x55
33 #define WINE_MIXER_VERSION 0x0100
34 #define WINE_MIXER_NAME "WINE OSS Mixer"
36 #define WINE_CHN_MASK(_x) (1L << (_x))
37 #define WINE_CHN_SUPPORTS(_c, _x) ((_c) & WINE_CHN_MASK(_x))
38 #define WINE_MIXER_MASK (WINE_CHN_MASK(SOUND_MIXER_VOLUME) | \
39 WINE_CHN_MASK(SOUND_MIXER_BASS) | \
40 WINE_CHN_MASK(SOUND_MIXER_TREBLE) | \
41 WINE_CHN_MASK(SOUND_MIXER_SYNTH) | \
42 WINE_CHN_MASK(SOUND_MIXER_PCM) | \
43 WINE_CHN_MASK(SOUND_MIXER_LINE) | \
44 WINE_CHN_MASK(SOUND_MIXER_MIC) | \
45 WINE_CHN_MASK(SOUND_MIXER_CD))
47 /* FIXME: the two following string arrays should be moved to a resource file in a string table */
48 /* if it's done, better use a struct to hold labels, name, and muted channel volume cache */
49 static char* MIX_Labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
50 static char* MIX_Names [SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
51 static int MIX_Volume[SOUND_MIXER_NRDEVICES];
52 static int MIX_DevMask = 0;
53 static int MIX_StereoMask = 0;
55 /**************************************************************************
56 * MIX_GetVal [internal]
58 static BOOL MIX_GetVal(int chn, int* val)
63 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
64 /* FIXME: ENXIO => no mixer installed */
65 WARN("mixer device not available !\n");
67 if (ioctl(mixer, MIXER_READ(chn), val) >= 0) {
68 TRACE("Reading %x on %d\n", *val, chn);
76 /**************************************************************************
77 * MIX_SetVal [internal]
79 static BOOL MIX_SetVal(int chn, int val)
84 TRACE("Writing %x on %d\n", val, chn);
86 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
87 /* FIXME: ENXIO => no mixer installed */
88 WARN("mixer device not available !\n");
90 if (ioctl(mixer, MIXER_WRITE(chn), &val) >= 0) {
98 /**************************************************************************
99 * MIX_GetDevCaps [internal]
101 static DWORD MIX_GetDevCaps(WORD wDevID, LPMIXERCAPSA lpCaps, DWORD dwSize)
103 TRACE("(%04X, %p, %lu);\n", wDevID, lpCaps, dwSize);
105 if (wDevID != 0) return MMSYSERR_BADDEVICEID;
106 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
107 if (!MIX_DevMask) return MMSYSERR_NOTENABLED;
109 lpCaps->wMid = WINE_MIXER_MANUF_ID;
110 lpCaps->wPid = WINE_MIXER_PRODUCT_ID;
111 lpCaps->vDriverVersion = WINE_MIXER_VERSION;
112 strcpy(lpCaps->szPname, WINE_MIXER_NAME);
114 lpCaps->cDestinations = 1;
115 lpCaps->fdwSupport = 0; /* No bits defined yet */
117 return MMSYSERR_NOERROR;
120 /**************************************************************************
121 * MIX_GetLineInfoFromIndex [internal]
123 static DWORD MIX_GetLineInfoFromIndex(LPMIXERLINEA lpMl, int devmask, DWORD idx)
125 strcpy(lpMl->szShortName, MIX_Labels[idx]);
126 strcpy(lpMl->szName, MIX_Names[idx]);
127 lpMl->dwLineID = idx;
128 lpMl->dwDestination = 0; /* index for speakers */
129 lpMl->cConnections = 1;
132 case SOUND_MIXER_SYNTH:
133 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER;
134 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
137 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC;
138 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
140 case SOUND_MIXER_LINE:
141 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_LINE;
142 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
144 case SOUND_MIXER_MIC:
145 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE;
146 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
148 case SOUND_MIXER_PCM:
149 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
150 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
152 case SOUND_MIXER_BASS:
153 case SOUND_MIXER_TREBLE:
154 WARN("BASS/TREBLE not handled correctly.\n");
155 return MMSYSERR_NOERROR;
157 WARN("Index %ld not handled.\n", idx);
158 return MIXERR_INVALLINE;
160 return MMSYSERR_NOERROR;
163 /**************************************************************************
164 * MIX_GetLineInfo [internal]
166 static DWORD MIX_GetLineInfo(WORD wDevID, LPMIXERLINEA lpMl, DWORD fdwInfo)
170 DWORD ret = MMSYSERR_NOERROR;
172 TRACE("(%04X, %p, %lu);\n", wDevID, lpMl, fdwInfo);
173 if (lpMl == NULL || lpMl->cbStruct != sizeof(*lpMl))
174 return MMSYSERR_INVALPARAM;
176 /* FIXME: set all the variables correctly... the lines below
179 lpMl->fdwLine = MIXERLINE_LINEF_ACTIVE;
184 switch (fdwInfo & MIXER_GETLINEINFOF_QUERYMASK) {
185 case MIXER_GETLINEINFOF_DESTINATION:
186 TRACE("DESTINATION (%08lx)\n", lpMl->dwDestination);
187 /* FIXME: Linux doesn't seem to support multiple outputs?
188 * So we have only one output type: Speaker.
190 lpMl->dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
191 lpMl->dwSource = 0xFFFFFFFF;
192 lpMl->dwLineID = SOUND_MIXER_VOLUME;
193 lstrcpynA(lpMl->szShortName, MIX_Labels[SOUND_MIXER_VOLUME], MIXER_SHORT_NAME_CHARS);
194 lstrcpynA(lpMl->szName, MIX_Names[SOUND_MIXER_VOLUME], MIXER_LONG_NAME_CHARS);
196 /* we have all connections found in the MIX_DevMask */
197 lpMl->cConnections = 0;
198 for (j = 1; j < SOUND_MIXER_NRDEVICES; j++)
199 if (WINE_CHN_SUPPORTS(MIX_DevMask, j))
200 lpMl->cConnections++;
201 if (WINE_CHN_SUPPORTS(MIX_StereoMask, SOUND_MIXER_VOLUME))
204 case MIXER_GETLINEINFOF_SOURCE:
205 TRACE("SOURCE (%08lx)\n", lpMl->dwSource);
207 for (j = 1; j < SOUND_MIXER_NRDEVICES; j++) {
208 if (WINE_CHN_SUPPORTS(MIX_DevMask, j) && (i-- == 0))
211 if (j >= SOUND_MIXER_NRDEVICES)
212 return MIXERR_INVALLINE;
213 if (WINE_CHN_SUPPORTS(MIX_StereoMask, j))
215 if ((ret = MIX_GetLineInfoFromIndex(lpMl, MIX_DevMask, j)) != MMSYSERR_NOERROR)
218 case MIXER_GETLINEINFOF_LINEID:
219 TRACE("LINEID (%08lx)\n", lpMl->dwLineID);
220 if (lpMl->dwLineID >= SOUND_MIXER_NRDEVICES)
221 return MIXERR_INVALLINE;
222 if (WINE_CHN_SUPPORTS(MIX_StereoMask, lpMl->dwLineID))
224 if ((ret = MIX_GetLineInfoFromIndex(lpMl, MIX_DevMask, lpMl->dwLineID)) != MMSYSERR_NOERROR)
227 case MIXER_GETLINEINFOF_COMPONENTTYPE:
228 TRACE("COMPONENT TYPE (%08lx)\n", lpMl->dwComponentType);
230 switch (lpMl->dwComponentType) {
231 case MIXERLINE_COMPONENTTYPE_DST_SPEAKERS:
232 i = SOUND_MIXER_VOLUME;
233 lpMl->dwDestination = 0;
234 lpMl->dwSource = 0xFFFFFFFF;
237 case MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER:
238 i = SOUND_MIXER_SYNTH;
239 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
241 case MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC:
243 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
245 case MIXERLINE_COMPONENTTYPE_SRC_LINE:
246 i = SOUND_MIXER_LINE;
247 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
249 case MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE:
251 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
253 case MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT:
255 lpMl->fdwLine |= MIXERLINE_LINEF_SOURCE;
258 FIXME("Unhandled component type (%08lx)\n", lpMl->dwComponentType);
259 return MMSYSERR_INVALPARAM;
262 if (WINE_CHN_SUPPORTS(MIX_DevMask, i)) {
263 strcpy(lpMl->szShortName, MIX_Labels[i]);
264 strcpy(lpMl->szName, MIX_Names[i]);
267 if (WINE_CHN_SUPPORTS(MIX_StereoMask, i))
269 lpMl->cConnections = 0;
271 for (j = 1; j < SOUND_MIXER_NRDEVICES; j++) {
272 if (WINE_CHN_SUPPORTS(MIX_DevMask, j)) {
273 lpMl->cConnections++;
278 case MIXER_GETLINEINFOF_TARGETTYPE:
279 FIXME("_TARGETTYPE not implemented yet.\n");
282 WARN("Unknown flag (%08lx)\n", fdwInfo & MIXER_GETLINEINFOF_QUERYMASK);
286 lpMl->Target.dwType = MIXERLINE_TARGETTYPE_AUX;
287 lpMl->Target.dwDeviceID = 0xFFFFFFFF;
288 lpMl->Target.wMid = WINE_MIXER_MANUF_ID;
289 lpMl->Target.wPid = WINE_MIXER_PRODUCT_ID;
290 lpMl->Target.vDriverVersion = WINE_MIXER_VERSION;
291 strcpy(lpMl->Target.szPname, WINE_MIXER_NAME);
296 /**************************************************************************
297 * MIX_GetLineInfo [internal]
299 static DWORD MIX_Open(WORD wDevID, LPMIXEROPENDESC lpMod, DWORD flags)
301 TRACE("(%04X, %p, %lu);\n", wDevID, lpMod, flags);
302 if (lpMod == NULL) return MMSYSERR_INVALPARAM;
304 return (MIX_DevMask == 0) ? MMSYSERR_NODRIVER : MMSYSERR_NOERROR;
307 /**************************************************************************
308 * MIX_MakeControlID [internal]
310 static DWORD MIX_MakeControlID(DWORD lineID, DWORD controlType)
312 switch (controlType) {
313 case MIXERCONTROL_CONTROLTYPE_VOLUME:
314 return 2 * lineID + 0;
315 case MIXERCONTROL_CONTROLTYPE_MUTE:
316 return 2 * lineID + 1;
318 FIXME("Internal error");
322 /**************************************************************************
323 * MIX_SplitControlID [internal]
325 static BOOL MIX_SplitControlID(DWORD controlID, LPDWORD lineID, LPDWORD controlType)
327 *lineID = controlID / 2;
328 *controlType = (controlID & 1) ?
329 MIXERCONTROL_CONTROLTYPE_MUTE : MIXERCONTROL_CONTROLTYPE_VOLUME;
331 return *lineID < SOUND_MIXER_NRDEVICES && WINE_CHN_SUPPORTS(MIX_DevMask, *lineID);
334 /**************************************************************************
335 * MIX_DoGetLineControls [internal]
337 static void MIX_DoGetLineControls(LPMIXERCONTROLA mc, DWORD lineID, DWORD dwType)
339 mc->cbStruct = sizeof(MIXERCONTROLA);
342 case MIXERCONTROL_CONTROLTYPE_VOLUME:
343 TRACE("Returning volume control\n");
344 mc->dwControlID = MIX_MakeControlID(lineID, dwType);
345 mc->dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
347 mc->cMultipleItems = 0;
348 lstrcpynA(mc->szShortName, "Vol", MIXER_SHORT_NAME_CHARS);
349 lstrcpynA(mc->szName, "Volume", MIXER_LONG_NAME_CHARS);
350 memset(&mc->Bounds, 0, sizeof(mc->Bounds));
351 /* CONTROLTYPE_VOLUME uses the MIXER_CONTROLDETAILS_UNSIGNED struct,
352 * [0, 100] is the range supported by OSS
353 * whatever the min and max values are they must match
354 * conversions done in (Get|Set)ControlDetails to stay in [0, 100] range
356 mc->Bounds.s1.dwMinimum = 0;
357 mc->Bounds.s1.dwMaximum = 65535;
358 memset(&mc->Metrics, 0, sizeof(mc->Metrics));
360 case MIXERCONTROL_CONTROLTYPE_MUTE:
361 TRACE("Returning mute control\n");
362 mc->dwControlID = MIX_MakeControlID(lineID, dwType);
363 mc->dwControlType = MIXERCONTROL_CONTROLTYPE_MUTE;
365 mc->cMultipleItems = 0;
366 lstrcpynA(mc->szShortName, "Mute", MIXER_SHORT_NAME_CHARS);
367 lstrcpynA(mc->szName, "Mute", MIXER_LONG_NAME_CHARS);
368 memset(&mc->Bounds, 0, sizeof(mc->Bounds));
369 memset(&mc->Metrics, 0, sizeof(mc->Metrics));
372 FIXME("Internal error: unknown type: %08lx\n", dwType);
376 /**************************************************************************
377 * MIX_GetLineControls [internal]
379 static DWORD MIX_GetLineControls(WORD wDevID, LPMIXERLINECONTROLSA lpMlc, DWORD flags)
381 DWORD dwRet = MMSYSERR_NOERROR;
382 DWORD lineID, controlType;
384 TRACE("(%04X, %p, %lu);\n", wDevID, lpMlc, flags);
386 if (lpMlc == NULL) return MMSYSERR_INVALPARAM;
387 if (lpMlc->cbStruct < sizeof(*lpMlc) ||
388 lpMlc->cbmxctrl < sizeof(MIXERCONTROLA))
389 return MMSYSERR_INVALPARAM;
391 switch (flags & MIXER_GETLINECONTROLSF_QUERYMASK) {
392 case MIXER_GETLINECONTROLSF_ALL:
393 TRACE("line=%08lx GLCF_ALL (%ld)\n", lpMlc->dwLineID, lpMlc->cControls);
394 if (lpMlc->cControls != 2) {
395 dwRet = MMSYSERR_INVALPARAM;
397 MIX_DoGetLineControls(&lpMlc->pamxctrl[0], lpMlc->dwLineID, MIXERCONTROL_CONTROLTYPE_VOLUME);
398 MIX_DoGetLineControls(&lpMlc->pamxctrl[1], lpMlc->dwLineID, MIXERCONTROL_CONTROLTYPE_MUTE);
401 case MIXER_GETLINECONTROLSF_ONEBYID:
402 TRACE("line=%08lx GLCF_ONEBYID (%lx)\n", lpMlc->dwLineID, lpMlc->u.dwControlID);
403 if (MIX_SplitControlID(lpMlc->u.dwControlID, &lineID, &controlType))
404 MIX_DoGetLineControls(&lpMlc->pamxctrl[0], lineID, controlType);
406 dwRet = MMSYSERR_INVALPARAM;
408 case MIXER_GETLINECONTROLSF_ONEBYTYPE:
409 TRACE("line=%08lx GLCF_ONEBYTYPE (%lx)\n", lpMlc->dwLineID, lpMlc->u.dwControlType);
410 switch (lpMlc->u.dwControlType & MIXERCONTROL_CT_CLASS_MASK) {
411 case MIXERCONTROL_CT_CLASS_FADER:
412 MIX_DoGetLineControls(&lpMlc->pamxctrl[0], lpMlc->dwLineID, MIXERCONTROL_CONTROLTYPE_VOLUME);
414 case MIXERCONTROL_CT_CLASS_SWITCH:
415 MIX_DoGetLineControls(&lpMlc->pamxctrl[0], lpMlc->dwLineID, MIXERCONTROL_CONTROLTYPE_MUTE);
418 dwRet = MMSYSERR_INVALPARAM;
422 ERR("Unknown flag %08lx\n", flags & MIXER_GETLINECONTROLSF_QUERYMASK);
423 dwRet = MMSYSERR_INVALPARAM;
429 /**************************************************************************
430 * MIX_GetControlDetails [internal]
432 static DWORD MIX_GetControlDetails(WORD wDevID, LPMIXERCONTROLDETAILS lpmcd, DWORD fdwDetails)
434 DWORD ret = MMSYSERR_NOTSUPPORTED;
435 DWORD lineID, controlType;
437 TRACE("(%04X, %p, %lu);\n", wDevID, lpmcd, fdwDetails);
439 if (lpmcd == NULL) return MMSYSERR_INVALPARAM;
441 switch (fdwDetails & MIXER_GETCONTROLDETAILSF_QUERYMASK) {
442 case MIXER_GETCONTROLDETAILSF_VALUE:
443 TRACE("GCD VALUE (%08lx)\n", lpmcd->dwControlID);
444 if (MIX_SplitControlID(lpmcd->dwControlID, &lineID, &controlType)) {
445 switch (controlType) {
446 case MIXERCONTROL_CONTROLTYPE_VOLUME:
448 LPMIXERCONTROLDETAILS_UNSIGNED mcdu;
451 /* return value is 00RL (4 bytes)... */
452 if ((val = MIX_Volume[lineID]) == -1 && !MIX_GetVal(lineID, &val))
453 return MMSYSERR_INVALPARAM;
455 switch (lpmcd->cChannels) {
457 /* mono... so R = L */
458 mcdu = (LPMIXERCONTROLDETAILS_UNSIGNED)lpmcd->paDetails;
459 mcdu->dwValue = (LOBYTE(LOWORD(val)) * 65536L) / 100;
462 /* stereo, left is paDetails[0] */
463 mcdu = (LPMIXERCONTROLDETAILS_UNSIGNED)((char*)lpmcd->paDetails + 0 * lpmcd->cbDetails);
464 mcdu->dwValue = (LOBYTE(LOWORD(val)) * 65536L) / 100;
465 mcdu = (LPMIXERCONTROLDETAILS_UNSIGNED)((char*)lpmcd->paDetails + 1 * lpmcd->cbDetails);
466 mcdu->dwValue = (HIBYTE(LOWORD(val)) * 65536L) / 100;
469 WARN("Unknown cChannels (%ld)\n", lpmcd->cChannels);
470 return MMSYSERR_INVALPARAM;
472 TRACE("=> %08lx\n", mcdu->dwValue);
475 case MIXERCONTROL_CONTROLTYPE_MUTE:
477 LPMIXERCONTROLDETAILS_BOOLEAN mcdb;
479 /* we mute both channels at the same time */
480 mcdb = (LPMIXERCONTROLDETAILS_BOOLEAN)lpmcd->paDetails;
481 mcdb->fValue = (MIX_Volume[lineID] != -1);
485 ret = MMSYSERR_NOERROR;
487 ret = MMSYSERR_INVALPARAM;
490 case MIXER_GETCONTROLDETAILSF_LISTTEXT:
494 WARN("Unknown flag (%08lx)\n", fdwDetails & MIXER_GETCONTROLDETAILSF_QUERYMASK);
499 /**************************************************************************
500 * MIX_SetControlDetails [internal]
502 static DWORD MIX_SetControlDetails(WORD wDevID, LPMIXERCONTROLDETAILS lpmcd, DWORD fdwDetails)
504 DWORD ret = MMSYSERR_NOTSUPPORTED;
505 DWORD lineID, controlType;
508 TRACE("(%04X, %p, %lu);\n", wDevID, lpmcd, fdwDetails);
510 if (lpmcd == NULL) return MMSYSERR_INVALPARAM;
512 switch (fdwDetails & MIXER_GETCONTROLDETAILSF_QUERYMASK) {
513 case MIXER_GETCONTROLDETAILSF_VALUE:
514 TRACE("GCD VALUE (%08lx)\n", lpmcd->dwControlID);
515 if (MIX_SplitControlID(lpmcd->dwControlID, &lineID, &controlType)) {
516 switch (controlType) {
517 case MIXERCONTROL_CONTROLTYPE_VOLUME:
519 LPMIXERCONTROLDETAILS_UNSIGNED mcdu;
521 /* val should contain 00RL */
522 switch (lpmcd->cChannels) {
524 /* mono... so R = L */
525 mcdu = (LPMIXERCONTROLDETAILS_UNSIGNED)lpmcd->paDetails;
526 TRACE("Setting RL to %08ld\n", mcdu->dwValue);
527 val = 0x101 * ((mcdu->dwValue * 100) >> 16);
530 /* stereo, left is paDetails[0] */
531 mcdu = (LPMIXERCONTROLDETAILS_UNSIGNED)((char*)lpmcd->paDetails + 0 * lpmcd->cbDetails);
532 TRACE("Setting L to %08ld\n", mcdu->dwValue);
533 val = ((mcdu->dwValue * 100) >> 16);
534 mcdu = (LPMIXERCONTROLDETAILS_UNSIGNED)((char*)lpmcd->paDetails + 1 * lpmcd->cbDetails);
535 TRACE("Setting R to %08ld\n", mcdu->dwValue);
536 val += ((mcdu->dwValue * 100) >> 16) << 8;
539 WARN("Unknown cChannels (%ld)\n", lpmcd->cChannels);
540 return MMSYSERR_INVALPARAM;
543 if (MIX_Volume[lineID] == -1) {
544 if (!MIX_SetVal(lineID, val))
545 return MMSYSERR_INVALPARAM;
547 MIX_Volume[lineID] = val;
550 ret = MMSYSERR_NOERROR;
552 case MIXERCONTROL_CONTROLTYPE_MUTE:
554 LPMIXERCONTROLDETAILS_BOOLEAN mcdb;
556 mcdb = (LPMIXERCONTROLDETAILS_BOOLEAN)lpmcd->paDetails;
558 if (!MIX_GetVal(lineID, &MIX_Volume[lineID]))
559 return MMSYSERR_INVALPARAM;
560 if (!MIX_SetVal(lineID, 0))
561 return MMSYSERR_INVALPARAM;
563 if (MIX_Volume[lineID] == -1) {
564 ret = MMSYSERR_NOERROR;
567 if (!MIX_SetVal(lineID, MIX_Volume[lineID]))
568 return MMSYSERR_INVALPARAM;
569 MIX_Volume[lineID] = -1;
572 ret = MMSYSERR_NOERROR;
577 case MIXER_GETCONTROLDETAILSF_LISTTEXT:
581 WARN("Unknown GetControlDetails flag (%08lx)\n", fdwDetails & MIXER_GETCONTROLDETAILSF_QUERYMASK);
583 return MMSYSERR_NOTSUPPORTED;
586 /**************************************************************************
587 * MIX_GetNumDevs [internal]
589 static DWORD MIX_GetNumDevs(UINT wDevID)
591 return (MIX_DevMask != 0) ? 1 : 0;
594 /**************************************************************************
595 * MIX_Init [internal]
597 static DWORD MIX_Init(void)
601 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
602 if (errno == ENODEV || errno == ENXIO) {
603 /* no driver present */
604 return MMSYSERR_NODRIVER;
606 return MMSYSERR_ERROR;
608 if (ioctl(mixer, SOUND_MIXER_READ_DEVMASK, &MIX_DevMask) == -1) {
610 perror("ioctl mixer SOUND_MIXER_DEVMASK");
611 return MMSYSERR_NOTENABLED;
613 MIX_DevMask &= WINE_MIXER_MASK;
614 if (ioctl(mixer, SOUND_MIXER_READ_STEREODEVS, &MIX_StereoMask) == -1) {
616 perror("ioctl mixer SOUND_MIXER_STEREODEVS");
617 return MMSYSERR_NOTENABLED;
619 MIX_StereoMask &= WINE_MIXER_MASK;
624 if (ioctl(mixer, SOUND_MIXER_READ_RECSRC, &recsrc) == -1) {
626 perror("ioctl mixer SOUND_MIXER_RECSRC");
627 return MMSYSERR_NOTENABLED;
630 if (ioctl(mixer, SOUND_MIXER_READ_RECMASK, &recmask) == -1) {
632 perror("ioctl mixer SOUND_MIXER_RECMASK");
633 return MMSYSERR_NOTENABLED;
636 for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
641 return MMSYSERR_NOERROR;
644 #endif /* HAVE_OSS */
646 /**************************************************************************
647 * OSS_mixMessage [sample driver]
649 DWORD WINAPI OSS_mixMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
650 DWORD dwParam1, DWORD dwParam2)
652 TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
653 wDevID, wMsg, dwUser, dwParam1, dwParam2);
663 /* FIXME: Pretend this is supported */
665 case MXDM_GETDEVCAPS:
666 return MIX_GetDevCaps(wDevID, (LPMIXERCAPSA)dwParam1, dwParam2);
667 case MXDM_GETLINEINFO:
668 return MIX_GetLineInfo(wDevID, (LPMIXERLINEA)dwParam1, dwParam2);
669 case MXDM_GETNUMDEVS:
670 return MIX_GetNumDevs(wDevID);
672 return MIX_Open(wDevID, (LPMIXEROPENDESC)dwParam1, dwParam2);
674 return MMSYSERR_NOERROR;
675 case MXDM_GETLINECONTROLS:
676 return MIX_GetLineControls(wDevID, (LPMIXERLINECONTROLSA)dwParam1, dwParam2);
677 case MXDM_GETCONTROLDETAILS:
678 return MIX_GetControlDetails(wDevID, (LPMIXERCONTROLDETAILS)dwParam1, dwParam2);
679 case MXDM_SETCONTROLDETAILS:
680 return MIX_SetControlDetails(wDevID, (LPMIXERCONTROLDETAILS)dwParam1, dwParam2);
682 WARN("unknown message %d!\n", wMsg);
684 return MMSYSERR_NOTSUPPORTED;
686 return MMSYSERR_NOTENABLED;