Release 940804
[wine/gsoc-2012-control.git] / misc / mmaux.c
blob36a2d740b48b45a4085e5a49bad90dd31b588434
1 /*
2 * Sample AUXILARY Wine Driver for Linux
4 * Copyright 1994 Martin Ayotte
5 */
6 static char Copyright[] = "Copyright Martin Ayotte, 1994";
8 #ifndef WINELIB
9 #define BUILTIN_MMSYSTEM
10 #endif
12 #ifdef BUILTIN_MMSYSTEM
14 #include "stdio.h"
15 #include "win.h"
16 #include "user.h"
17 #include "driver.h"
18 #include "mmsystem.h"
20 #include <fcntl.h>
21 #include <sys/ioctl.h>
22 #ifdef linux
23 #include <linux/soundcard.h>
24 #endif
26 #define SOUND_DEV "/dev/dsp"
27 #define MIXER_DEV "/dev/mixer"
29 #ifdef SOUND_VERSION
30 #define IOCTL(a,b,c) ioctl(a,b,&c)
31 #else
32 #define IOCTL(a,b,c) (c = ioctl(a,b,c) )
33 #endif
36 /*-----------------------------------------------------------------------*/
39 /**************************************************************************
40 * AUX_GetDevCaps [internal]
42 DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPS lpCaps, DWORD dwSize)
44 #ifdef linux
45 int mixer;
46 int volume;
47 printf("AUX_GetDevCaps(%u, %08X, %u);\n", wDevID, lpCaps, dwSize);
48 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
49 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
50 printf("AUX_GetDevCaps // mixer device not available !\n");
51 return MMSYSERR_NOTENABLED;
53 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
54 printf("AUX_GetDevCaps // unable read mixer !\n");
55 return MMSYSERR_NOTENABLED;
57 close(mixer);
58 return MMSYSERR_NOERROR;
59 #else
60 return MMSYSERR_NOTENABLED;
61 #endif
65 /**************************************************************************
66 * AUX_GetVolume [internal]
68 DWORD AUX_GetVolume(WORD wDevID, DWORD dwParam)
70 #ifdef linux
71 int mixer;
72 int volume;
73 printf("AUX_GetVolume(%u, %08X);\n", wDevID, dwParam);
74 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
75 printf("Linux 'AUX_GetVolume' // mixer device not available !\n");
76 return MMSYSERR_NOTENABLED;
78 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
79 printf("Linux 'AUX_GetVolume' // unable read mixer !\n");
80 return MMSYSERR_NOTENABLED;
82 close(mixer);
83 return MMSYSERR_NOERROR;
84 #else
85 return MMSYSERR_NOTENABLED;
86 #endif
89 /**************************************************************************
90 * AUX_SetVolume [internal]
92 DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
94 #ifdef linux
95 int mixer;
96 int volume = 50;
97 printf("AUX_SetVolume(%u, %08X);\n", wDevID, dwParam);
98 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
99 printf("Linux 'AUX_SetVolume' // mixer device not available !\n");
100 return MMSYSERR_NOTENABLED;
102 if (ioctl(mixer, SOUND_MIXER_WRITE_LINE, &volume) == -1) {
103 printf("Linux 'AUX_SetVolume' // unable set mixer !\n");
104 return MMSYSERR_NOTENABLED;
106 close(mixer);
107 return MMSYSERR_NOERROR;
108 #else
109 return MMSYSERR_NOTENABLED;
110 #endif
114 /**************************************************************************
115 * auxMessage [sample driver]
117 DWORD auxMessage(WORD wDevID, WORD wMsg, DWORD dwUser,
118 DWORD dwParam1, DWORD dwParam2)
120 printf("auxMessage(%u, %04X, %08X, %08X, %08X);\n",
121 wDevID, wMsg, dwUser, dwParam1, dwParam2);
122 switch(wMsg) {
123 case AUXDM_GETDEVCAPS:
124 return AUX_GetDevCaps(wDevID, (LPAUXCAPS)dwParam1, dwParam2);
125 case AUXDM_GETNUMDEVS:
126 return 0L;
127 case AUXDM_GETVOLUME:
128 return AUX_GetVolume(wDevID, dwParam1);
129 case AUXDM_SETVOLUME:
130 return AUX_SetVolume(wDevID, dwParam1);
132 return MMSYSERR_NOTSUPPORTED;
136 #endif /* #ifdef BUILTIN_MMSYSTEM */