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>
22 #include "debugtools.h"
24 DEFAULT_DEBUG_CHANNEL(mmaux
);
28 #define MIXER_DEV "/dev/mixer"
30 #define WINE_MIXER_MANUF_ID 0xAA
31 #define WINE_MIXER_PRODUCT_ID 0x55
32 #define WINE_MIXER_VERSION 0x0100
33 #define WINE_MIXER_NAME "WINE OSS Mixer"
35 #define WINE_CHN_MASK(_x) (1L << (_x))
36 #define WINE_CHN_SUPPORTS(_c, _x) ((_c) & WINE_CHN_MASK(_x))
37 /* Bass and Treble are no longer in the mask as Windows does not handle them */
38 #define WINE_MIXER_MASK (WINE_CHN_MASK(SOUND_MIXER_VOLUME) | \
39 WINE_CHN_MASK(SOUND_MIXER_SYNTH) | \
40 WINE_CHN_MASK(SOUND_MIXER_PCM) | \
41 WINE_CHN_MASK(SOUND_MIXER_LINE) | \
42 WINE_CHN_MASK(SOUND_MIXER_MIC) | \
43 WINE_CHN_MASK(SOUND_MIXER_CD))
45 /* FIXME: the two following string arrays should be moved to a resource file in a string table */
46 /* if it's done, better use a struct to hold labels, name, and muted channel volume cache */
47 static char* MIX_Labels
[SOUND_MIXER_NRDEVICES
] = SOUND_DEVICE_LABELS
;
48 static char* MIX_Names
[SOUND_MIXER_NRDEVICES
] = SOUND_DEVICE_NAMES
;
49 static int MIX_Volume
[SOUND_MIXER_NRDEVICES
];
50 static int MIX_DevMask
= 0;
51 static int MIX_StereoMask
= 0;
53 /**************************************************************************
54 * MIX_GetVal [internal]
56 static BOOL
MIX_GetVal(int chn
, int* val
)
61 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
62 /* FIXME: ENXIO => no mixer installed */
63 WARN("mixer device not available !\n");
65 if (ioctl(mixer
, MIXER_READ(chn
), val
) >= 0) {
66 TRACE("Reading %x on %d\n", *val
, chn
);
74 /**************************************************************************
75 * MIX_SetVal [internal]
77 static BOOL
MIX_SetVal(int chn
, int val
)
82 TRACE("Writing %x on %d\n", val
, chn
);
84 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
85 /* FIXME: ENXIO => no mixer installed */
86 WARN("mixer device not available !\n");
88 if (ioctl(mixer
, MIXER_WRITE(chn
), &val
) >= 0) {
96 /**************************************************************************
97 * MIX_GetDevCaps [internal]
99 static DWORD
MIX_GetDevCaps(WORD wDevID
, LPMIXERCAPSA lpCaps
, DWORD dwSize
)
101 TRACE("(%04X, %p, %lu);\n", wDevID
, lpCaps
, dwSize
);
103 if (wDevID
!= 0) return MMSYSERR_BADDEVICEID
;
104 if (lpCaps
== NULL
) return MMSYSERR_INVALPARAM
;
105 if (!MIX_DevMask
) return MMSYSERR_NOTENABLED
;
107 lpCaps
->wMid
= WINE_MIXER_MANUF_ID
;
108 lpCaps
->wPid
= WINE_MIXER_PRODUCT_ID
;
109 lpCaps
->vDriverVersion
= WINE_MIXER_VERSION
;
110 strcpy(lpCaps
->szPname
, WINE_MIXER_NAME
);
112 lpCaps
->cDestinations
= 1;
113 lpCaps
->fdwSupport
= 0; /* No bits defined yet */
115 return MMSYSERR_NOERROR
;
118 /**************************************************************************
119 * MIX_GetLineInfoFromIndex [internal]
121 static DWORD
MIX_GetLineInfoFromIndex(LPMIXERLINEA lpMl
, int devmask
, DWORD idx
)
123 strcpy(lpMl
->szShortName
, MIX_Labels
[idx
]);
124 strcpy(lpMl
->szName
, MIX_Names
[idx
]);
125 lpMl
->dwLineID
= idx
;
126 lpMl
->dwDestination
= 0; /* index for speakers */
127 lpMl
->cConnections
= 1;
130 case SOUND_MIXER_SYNTH
:
131 lpMl
->dwComponentType
= MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER
;
132 lpMl
->fdwLine
|= MIXERLINE_LINEF_SOURCE
;
135 lpMl
->dwComponentType
= MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
;
136 lpMl
->fdwLine
|= MIXERLINE_LINEF_SOURCE
;
138 case SOUND_MIXER_LINE
:
139 lpMl
->dwComponentType
= MIXERLINE_COMPONENTTYPE_SRC_LINE
;
140 lpMl
->fdwLine
|= MIXERLINE_LINEF_SOURCE
;
142 case SOUND_MIXER_MIC
:
143 lpMl
->dwComponentType
= MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
;
144 lpMl
->fdwLine
|= MIXERLINE_LINEF_SOURCE
;
146 case SOUND_MIXER_PCM
:
147 lpMl
->dwComponentType
= MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
;
148 lpMl
->fdwLine
|= MIXERLINE_LINEF_SOURCE
;
151 WARN("Index %ld not handled.\n", idx
);
152 return MIXERR_INVALLINE
;
154 return MMSYSERR_NOERROR
;
157 /**************************************************************************
158 * MIX_GetLineInfo [internal]
160 static DWORD
MIX_GetLineInfo(WORD wDevID
, LPMIXERLINEA lpMl
, DWORD fdwInfo
)
164 DWORD ret
= MMSYSERR_NOERROR
;
166 TRACE("(%04X, %p, %lu);\n", wDevID
, lpMl
, fdwInfo
);
167 if (lpMl
== NULL
|| lpMl
->cbStruct
!= sizeof(*lpMl
))
168 return MMSYSERR_INVALPARAM
;
170 /* FIXME: set all the variables correctly... the lines below
173 lpMl
->fdwLine
= MIXERLINE_LINEF_ACTIVE
;
178 switch (fdwInfo
& MIXER_GETLINEINFOF_QUERYMASK
) {
179 case MIXER_GETLINEINFOF_DESTINATION
:
180 TRACE("DESTINATION (%08lx)\n", lpMl
->dwDestination
);
181 /* FIXME: Linux doesn't seem to support multiple outputs?
182 * So we have only one output type: Speaker.
184 lpMl
->dwComponentType
= MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
;
185 lpMl
->dwSource
= 0xFFFFFFFF;
186 lpMl
->dwLineID
= SOUND_MIXER_VOLUME
;
187 lstrcpynA(lpMl
->szShortName
, MIX_Labels
[SOUND_MIXER_VOLUME
], MIXER_SHORT_NAME_CHARS
);
188 lstrcpynA(lpMl
->szName
, MIX_Names
[SOUND_MIXER_VOLUME
], MIXER_LONG_NAME_CHARS
);
190 /* we have all connections found in the MIX_DevMask */
191 lpMl
->cConnections
= 0;
192 for (j
= 1; j
< SOUND_MIXER_NRDEVICES
; j
++)
193 if (WINE_CHN_SUPPORTS(MIX_DevMask
, j
))
194 lpMl
->cConnections
++;
195 if (WINE_CHN_SUPPORTS(MIX_StereoMask
, SOUND_MIXER_VOLUME
))
198 case MIXER_GETLINEINFOF_SOURCE
:
199 TRACE("SOURCE (%08lx)\n", lpMl
->dwSource
);
201 for (j
= 1; j
< SOUND_MIXER_NRDEVICES
; j
++) {
202 if (WINE_CHN_SUPPORTS(MIX_DevMask
, j
) && (i
-- == 0))
205 if (j
>= SOUND_MIXER_NRDEVICES
)
206 return MIXERR_INVALLINE
;
207 if (WINE_CHN_SUPPORTS(MIX_StereoMask
, j
))
209 if ((ret
= MIX_GetLineInfoFromIndex(lpMl
, MIX_DevMask
, j
)) != MMSYSERR_NOERROR
)
212 case MIXER_GETLINEINFOF_LINEID
:
213 TRACE("LINEID (%08lx)\n", lpMl
->dwLineID
);
214 if (lpMl
->dwLineID
>= SOUND_MIXER_NRDEVICES
)
215 return MIXERR_INVALLINE
;
216 if (WINE_CHN_SUPPORTS(MIX_StereoMask
, lpMl
->dwLineID
))
218 if ((ret
= MIX_GetLineInfoFromIndex(lpMl
, MIX_DevMask
, lpMl
->dwLineID
)) != MMSYSERR_NOERROR
)
221 case MIXER_GETLINEINFOF_COMPONENTTYPE
:
222 TRACE("COMPONENT TYPE (%08lx)\n", lpMl
->dwComponentType
);
224 switch (lpMl
->dwComponentType
) {
225 case MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
:
226 i
= SOUND_MIXER_VOLUME
;
227 lpMl
->dwDestination
= 0;
228 lpMl
->dwSource
= 0xFFFFFFFF;
231 case MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER
:
232 i
= SOUND_MIXER_SYNTH
;
233 lpMl
->fdwLine
|= MIXERLINE_LINEF_SOURCE
;
235 case MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
:
237 lpMl
->fdwLine
|= MIXERLINE_LINEF_SOURCE
;
239 case MIXERLINE_COMPONENTTYPE_SRC_LINE
:
240 i
= SOUND_MIXER_LINE
;
241 lpMl
->fdwLine
|= MIXERLINE_LINEF_SOURCE
;
243 case MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
:
245 lpMl
->fdwLine
|= MIXERLINE_LINEF_SOURCE
;
247 case MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
:
249 lpMl
->fdwLine
|= MIXERLINE_LINEF_SOURCE
;
252 FIXME("Unhandled component type (%08lx)\n", lpMl
->dwComponentType
);
253 return MMSYSERR_INVALPARAM
;
256 if (WINE_CHN_SUPPORTS(MIX_DevMask
, i
)) {
257 strcpy(lpMl
->szShortName
, MIX_Labels
[i
]);
258 strcpy(lpMl
->szName
, MIX_Names
[i
]);
261 if (WINE_CHN_SUPPORTS(MIX_StereoMask
, i
))
263 lpMl
->cConnections
= 0;
265 for (j
= 1; j
< SOUND_MIXER_NRDEVICES
; j
++) {
266 if (WINE_CHN_SUPPORTS(MIX_DevMask
, j
)) {
267 lpMl
->cConnections
++;
272 case MIXER_GETLINEINFOF_TARGETTYPE
:
273 FIXME("_TARGETTYPE not implemented yet.\n");
276 WARN("Unknown flag (%08lx)\n", fdwInfo
& MIXER_GETLINEINFOF_QUERYMASK
);
280 lpMl
->Target
.dwType
= MIXERLINE_TARGETTYPE_AUX
;
281 lpMl
->Target
.dwDeviceID
= 0xFFFFFFFF;
282 lpMl
->Target
.wMid
= WINE_MIXER_MANUF_ID
;
283 lpMl
->Target
.wPid
= WINE_MIXER_PRODUCT_ID
;
284 lpMl
->Target
.vDriverVersion
= WINE_MIXER_VERSION
;
285 strcpy(lpMl
->Target
.szPname
, WINE_MIXER_NAME
);
290 /**************************************************************************
291 * MIX_GetLineInfo [internal]
293 static DWORD
MIX_Open(WORD wDevID
, LPMIXEROPENDESC lpMod
, DWORD flags
)
295 TRACE("(%04X, %p, %lu);\n", wDevID
, lpMod
, flags
);
296 if (lpMod
== NULL
) return MMSYSERR_INVALPARAM
;
298 return (MIX_DevMask
== 0) ? MMSYSERR_NODRIVER
: MMSYSERR_NOERROR
;
301 /**************************************************************************
302 * MIX_MakeControlID [internal]
304 static DWORD
MIX_MakeControlID(DWORD lineID
, DWORD controlType
)
306 switch (controlType
) {
307 case MIXERCONTROL_CONTROLTYPE_VOLUME
:
308 return 2 * lineID
+ 0;
309 case MIXERCONTROL_CONTROLTYPE_MUTE
:
310 return 2 * lineID
+ 1;
312 FIXME("Internal error");
316 /**************************************************************************
317 * MIX_SplitControlID [internal]
319 static BOOL
MIX_SplitControlID(DWORD controlID
, LPDWORD lineID
, LPDWORD controlType
)
321 *lineID
= controlID
/ 2;
322 *controlType
= (controlID
& 1) ?
323 MIXERCONTROL_CONTROLTYPE_MUTE
: MIXERCONTROL_CONTROLTYPE_VOLUME
;
325 return *lineID
< SOUND_MIXER_NRDEVICES
&& WINE_CHN_SUPPORTS(MIX_DevMask
, *lineID
);
328 /**************************************************************************
329 * MIX_DoGetLineControls [internal]
331 static void MIX_DoGetLineControls(LPMIXERCONTROLA mc
, DWORD lineID
, DWORD dwType
)
333 mc
->cbStruct
= sizeof(MIXERCONTROLA
);
336 case MIXERCONTROL_CONTROLTYPE_VOLUME
:
337 TRACE("Returning volume control\n");
338 mc
->dwControlID
= MIX_MakeControlID(lineID
, dwType
);
339 mc
->dwControlType
= MIXERCONTROL_CONTROLTYPE_VOLUME
;
341 mc
->cMultipleItems
= 0;
342 lstrcpynA(mc
->szShortName
, "Vol", MIXER_SHORT_NAME_CHARS
);
343 lstrcpynA(mc
->szName
, "Volume", MIXER_LONG_NAME_CHARS
);
344 memset(&mc
->Bounds
, 0, sizeof(mc
->Bounds
));
345 /* CONTROLTYPE_VOLUME uses the MIXER_CONTROLDETAILS_UNSIGNED struct,
346 * [0, 100] is the range supported by OSS
347 * whatever the min and max values are they must match
348 * conversions done in (Get|Set)ControlDetails to stay in [0, 100] range
350 mc
->Bounds
.s1
.dwMinimum
= 0;
351 mc
->Bounds
.s1
.dwMaximum
= 65535;
352 memset(&mc
->Metrics
, 0, sizeof(mc
->Metrics
));
354 case MIXERCONTROL_CONTROLTYPE_MUTE
:
355 TRACE("Returning mute control\n");
356 mc
->dwControlID
= MIX_MakeControlID(lineID
, dwType
);
357 mc
->dwControlType
= MIXERCONTROL_CONTROLTYPE_MUTE
;
359 mc
->cMultipleItems
= 0;
360 lstrcpynA(mc
->szShortName
, "Mute", MIXER_SHORT_NAME_CHARS
);
361 lstrcpynA(mc
->szName
, "Mute", MIXER_LONG_NAME_CHARS
);
362 memset(&mc
->Bounds
, 0, sizeof(mc
->Bounds
));
363 memset(&mc
->Metrics
, 0, sizeof(mc
->Metrics
));
366 FIXME("Internal error: unknown type: %08lx\n", dwType
);
370 /**************************************************************************
371 * MIX_GetLineControls [internal]
373 static DWORD
MIX_GetLineControls(WORD wDevID
, LPMIXERLINECONTROLSA lpMlc
, DWORD flags
)
375 DWORD dwRet
= MMSYSERR_NOERROR
;
376 DWORD lineID
, controlType
;
378 TRACE("(%04X, %p, %lu);\n", wDevID
, lpMlc
, flags
);
380 if (lpMlc
== NULL
) return MMSYSERR_INVALPARAM
;
381 if (lpMlc
->cbStruct
< sizeof(*lpMlc
) ||
382 lpMlc
->cbmxctrl
< sizeof(MIXERCONTROLA
))
383 return MMSYSERR_INVALPARAM
;
385 switch (flags
& MIXER_GETLINECONTROLSF_QUERYMASK
) {
386 case MIXER_GETLINECONTROLSF_ALL
:
387 TRACE("line=%08lx GLCF_ALL (%ld)\n", lpMlc
->dwLineID
, lpMlc
->cControls
);
388 if (lpMlc
->cControls
!= 2) {
389 dwRet
= MMSYSERR_INVALPARAM
;
391 MIX_DoGetLineControls(&lpMlc
->pamxctrl
[0], lpMlc
->dwLineID
, MIXERCONTROL_CONTROLTYPE_VOLUME
);
392 MIX_DoGetLineControls(&lpMlc
->pamxctrl
[1], lpMlc
->dwLineID
, MIXERCONTROL_CONTROLTYPE_MUTE
);
395 case MIXER_GETLINECONTROLSF_ONEBYID
:
396 TRACE("line=%08lx GLCF_ONEBYID (%lx)\n", lpMlc
->dwLineID
, lpMlc
->u
.dwControlID
);
397 if (MIX_SplitControlID(lpMlc
->u
.dwControlID
, &lineID
, &controlType
))
398 MIX_DoGetLineControls(&lpMlc
->pamxctrl
[0], lineID
, controlType
);
400 dwRet
= MMSYSERR_INVALPARAM
;
402 case MIXER_GETLINECONTROLSF_ONEBYTYPE
:
403 TRACE("line=%08lx GLCF_ONEBYTYPE (%lx)\n", lpMlc
->dwLineID
, lpMlc
->u
.dwControlType
);
404 switch (lpMlc
->u
.dwControlType
& MIXERCONTROL_CT_CLASS_MASK
) {
405 case MIXERCONTROL_CT_CLASS_FADER
:
406 MIX_DoGetLineControls(&lpMlc
->pamxctrl
[0], lpMlc
->dwLineID
, MIXERCONTROL_CONTROLTYPE_VOLUME
);
408 case MIXERCONTROL_CT_CLASS_SWITCH
:
409 MIX_DoGetLineControls(&lpMlc
->pamxctrl
[0], lpMlc
->dwLineID
, MIXERCONTROL_CONTROLTYPE_MUTE
);
412 dwRet
= MMSYSERR_INVALPARAM
;
416 ERR("Unknown flag %08lx\n", flags
& MIXER_GETLINECONTROLSF_QUERYMASK
);
417 dwRet
= MMSYSERR_INVALPARAM
;
423 /**************************************************************************
424 * MIX_GetControlDetails [internal]
426 static DWORD
MIX_GetControlDetails(WORD wDevID
, LPMIXERCONTROLDETAILS lpmcd
, DWORD fdwDetails
)
428 DWORD ret
= MMSYSERR_NOTSUPPORTED
;
429 DWORD lineID
, controlType
;
431 TRACE("(%04X, %p, %lu);\n", wDevID
, lpmcd
, fdwDetails
);
433 if (lpmcd
== NULL
) return MMSYSERR_INVALPARAM
;
435 switch (fdwDetails
& MIXER_GETCONTROLDETAILSF_QUERYMASK
) {
436 case MIXER_GETCONTROLDETAILSF_VALUE
:
437 TRACE("GCD VALUE (%08lx)\n", lpmcd
->dwControlID
);
438 if (MIX_SplitControlID(lpmcd
->dwControlID
, &lineID
, &controlType
)) {
439 switch (controlType
) {
440 case MIXERCONTROL_CONTROLTYPE_VOLUME
:
442 LPMIXERCONTROLDETAILS_UNSIGNED mcdu
;
445 /* return value is 00RL (4 bytes)... */
446 if ((val
= MIX_Volume
[lineID
]) == -1 && !MIX_GetVal(lineID
, &val
))
447 return MMSYSERR_INVALPARAM
;
449 switch (lpmcd
->cChannels
) {
451 /* mono... so R = L */
452 mcdu
= (LPMIXERCONTROLDETAILS_UNSIGNED
)lpmcd
->paDetails
;
453 mcdu
->dwValue
= (LOBYTE(LOWORD(val
)) * 65536L) / 100;
456 /* stereo, left is paDetails[0] */
457 mcdu
= (LPMIXERCONTROLDETAILS_UNSIGNED
)((char*)lpmcd
->paDetails
+ 0 * lpmcd
->cbDetails
);
458 mcdu
->dwValue
= (LOBYTE(LOWORD(val
)) * 65536L) / 100;
459 mcdu
= (LPMIXERCONTROLDETAILS_UNSIGNED
)((char*)lpmcd
->paDetails
+ 1 * lpmcd
->cbDetails
);
460 mcdu
->dwValue
= (HIBYTE(LOWORD(val
)) * 65536L) / 100;
463 WARN("Unknown cChannels (%ld)\n", lpmcd
->cChannels
);
464 return MMSYSERR_INVALPARAM
;
466 TRACE("=> %08lx\n", mcdu
->dwValue
);
469 case MIXERCONTROL_CONTROLTYPE_MUTE
:
471 LPMIXERCONTROLDETAILS_BOOLEAN mcdb
;
473 /* we mute both channels at the same time */
474 mcdb
= (LPMIXERCONTROLDETAILS_BOOLEAN
)lpmcd
->paDetails
;
475 mcdb
->fValue
= (MIX_Volume
[lineID
] != -1);
479 ret
= MMSYSERR_NOERROR
;
481 ret
= MMSYSERR_INVALPARAM
;
484 case MIXER_GETCONTROLDETAILSF_LISTTEXT
:
488 WARN("Unknown flag (%08lx)\n", fdwDetails
& MIXER_GETCONTROLDETAILSF_QUERYMASK
);
493 /**************************************************************************
494 * MIX_SetControlDetails [internal]
496 static DWORD
MIX_SetControlDetails(WORD wDevID
, LPMIXERCONTROLDETAILS lpmcd
, DWORD fdwDetails
)
498 DWORD ret
= MMSYSERR_NOTSUPPORTED
;
499 DWORD lineID
, controlType
;
502 TRACE("(%04X, %p, %lu);\n", wDevID
, lpmcd
, fdwDetails
);
504 if (lpmcd
== NULL
) return MMSYSERR_INVALPARAM
;
506 switch (fdwDetails
& MIXER_GETCONTROLDETAILSF_QUERYMASK
) {
507 case MIXER_GETCONTROLDETAILSF_VALUE
:
508 TRACE("GCD VALUE (%08lx)\n", lpmcd
->dwControlID
);
509 if (MIX_SplitControlID(lpmcd
->dwControlID
, &lineID
, &controlType
)) {
510 switch (controlType
) {
511 case MIXERCONTROL_CONTROLTYPE_VOLUME
:
513 LPMIXERCONTROLDETAILS_UNSIGNED mcdu
;
515 /* val should contain 00RL */
516 switch (lpmcd
->cChannels
) {
518 /* mono... so R = L */
519 mcdu
= (LPMIXERCONTROLDETAILS_UNSIGNED
)lpmcd
->paDetails
;
520 TRACE("Setting RL to %08ld\n", mcdu
->dwValue
);
521 val
= 0x101 * ((mcdu
->dwValue
* 100) >> 16);
524 /* stereo, left is paDetails[0] */
525 mcdu
= (LPMIXERCONTROLDETAILS_UNSIGNED
)((char*)lpmcd
->paDetails
+ 0 * lpmcd
->cbDetails
);
526 TRACE("Setting L to %08ld\n", mcdu
->dwValue
);
527 val
= ((mcdu
->dwValue
* 100) >> 16);
528 mcdu
= (LPMIXERCONTROLDETAILS_UNSIGNED
)((char*)lpmcd
->paDetails
+ 1 * lpmcd
->cbDetails
);
529 TRACE("Setting R to %08ld\n", mcdu
->dwValue
);
530 val
+= ((mcdu
->dwValue
* 100) >> 16) << 8;
533 WARN("Unknown cChannels (%ld)\n", lpmcd
->cChannels
);
534 return MMSYSERR_INVALPARAM
;
537 if (MIX_Volume
[lineID
] == -1) {
538 if (!MIX_SetVal(lineID
, val
))
539 return MMSYSERR_INVALPARAM
;
541 MIX_Volume
[lineID
] = val
;
544 ret
= MMSYSERR_NOERROR
;
546 case MIXERCONTROL_CONTROLTYPE_MUTE
:
548 LPMIXERCONTROLDETAILS_BOOLEAN mcdb
;
550 mcdb
= (LPMIXERCONTROLDETAILS_BOOLEAN
)lpmcd
->paDetails
;
552 if (!MIX_GetVal(lineID
, &MIX_Volume
[lineID
]))
553 return MMSYSERR_INVALPARAM
;
554 if (!MIX_SetVal(lineID
, 0))
555 return MMSYSERR_INVALPARAM
;
557 if (MIX_Volume
[lineID
] == -1) {
558 ret
= MMSYSERR_NOERROR
;
561 if (!MIX_SetVal(lineID
, MIX_Volume
[lineID
]))
562 return MMSYSERR_INVALPARAM
;
563 MIX_Volume
[lineID
] = -1;
566 ret
= MMSYSERR_NOERROR
;
571 case MIXER_GETCONTROLDETAILSF_LISTTEXT
:
575 WARN("Unknown GetControlDetails flag (%08lx)\n", fdwDetails
& MIXER_GETCONTROLDETAILSF_QUERYMASK
);
577 return MMSYSERR_NOTSUPPORTED
;
580 /**************************************************************************
581 * MIX_GetNumDevs [internal]
583 static DWORD
MIX_GetNumDevs(UINT wDevID
)
585 return (MIX_DevMask
!= 0) ? 1 : 0;
588 /**************************************************************************
589 * MIX_Init [internal]
591 static DWORD
MIX_Init(void)
595 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
596 if (errno
== ENODEV
|| errno
== ENXIO
) {
597 /* no driver present */
598 return MMSYSERR_NODRIVER
;
600 return MMSYSERR_ERROR
;
602 if (ioctl(mixer
, SOUND_MIXER_READ_DEVMASK
, &MIX_DevMask
) == -1) {
604 perror("ioctl mixer SOUND_MIXER_DEVMASK");
605 return MMSYSERR_NOTENABLED
;
607 MIX_DevMask
&= WINE_MIXER_MASK
;
608 if (ioctl(mixer
, SOUND_MIXER_READ_STEREODEVS
, &MIX_StereoMask
) == -1) {
610 perror("ioctl mixer SOUND_MIXER_STEREODEVS");
611 return MMSYSERR_NOTENABLED
;
613 MIX_StereoMask
&= WINE_MIXER_MASK
;
618 if (ioctl(mixer
, SOUND_MIXER_READ_RECSRC
, &recsrc
) == -1) {
620 perror("ioctl mixer SOUND_MIXER_RECSRC");
621 return MMSYSERR_NOTENABLED
;
624 if (ioctl(mixer
, SOUND_MIXER_READ_RECMASK
, &recmask
) == -1) {
626 perror("ioctl mixer SOUND_MIXER_RECMASK");
627 return MMSYSERR_NOTENABLED
;
630 for (i
= 0; i
< SOUND_MIXER_NRDEVICES
; i
++) {
635 return MMSYSERR_NOERROR
;
638 #endif /* HAVE_OSS */
640 /**************************************************************************
641 * OSS_mixMessage [sample driver]
643 DWORD WINAPI
OSS_mixMessage(UINT wDevID
, UINT wMsg
, DWORD dwUser
,
644 DWORD dwParam1
, DWORD dwParam2
)
646 TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
647 wDevID
, wMsg
, dwUser
, dwParam1
, dwParam2
);
657 /* FIXME: Pretend this is supported */
659 case MXDM_GETDEVCAPS
:
660 return MIX_GetDevCaps(wDevID
, (LPMIXERCAPSA
)dwParam1
, dwParam2
);
661 case MXDM_GETLINEINFO
:
662 return MIX_GetLineInfo(wDevID
, (LPMIXERLINEA
)dwParam1
, dwParam2
);
663 case MXDM_GETNUMDEVS
:
664 return MIX_GetNumDevs(wDevID
);
666 return MIX_Open(wDevID
, (LPMIXEROPENDESC
)dwParam1
, dwParam2
);
668 return MMSYSERR_NOERROR
;
669 case MXDM_GETLINECONTROLS
:
670 return MIX_GetLineControls(wDevID
, (LPMIXERLINECONTROLSA
)dwParam1
, dwParam2
);
671 case MXDM_GETCONTROLDETAILS
:
672 return MIX_GetControlDetails(wDevID
, (LPMIXERCONTROLDETAILS
)dwParam1
, dwParam2
);
673 case MXDM_SETCONTROLDETAILS
:
674 return MIX_SetControlDetails(wDevID
, (LPMIXERCONTROLDETAILS
)dwParam1
, dwParam2
);
676 WARN("unknown message %d!\n", wMsg
);
678 return MMSYSERR_NOTSUPPORTED
;
680 return MMSYSERR_NOTENABLED
;