Release 941107
[wine/multimedia.git] / misc / mmaux.c
blob1c4cc063c2ac325fa09ae07ddd6399def1baf2ca
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 #define EMULATE_SB16
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <unistd.h>
19 #include <fcntl.h>
20 #include <sys/ioctl.h>
21 #include "win.h"
22 #include "user.h"
23 #include "driver.h"
24 #include "mmsystem.h"
26 #ifdef linux
27 #include <linux/soundcard.h>
28 #endif
30 #define SOUND_DEV "/dev/dsp"
31 #define MIXER_DEV "/dev/mixer"
33 #ifdef SOUND_VERSION
34 #define IOCTL(a,b,c) ioctl(a,b,&c)
35 #else
36 #define IOCTL(a,b,c) (c = ioctl(a,b,c) )
37 #endif
40 /*-----------------------------------------------------------------------*/
43 /**************************************************************************
44 * AUX_GetDevCaps [internal]
46 DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPS lpCaps, DWORD dwSize)
48 #ifdef linux
49 int mixer;
50 int volume;
51 printf("AUX_GetDevCaps(%u, %08X, %u);\n", wDevID, lpCaps, dwSize);
52 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
53 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
54 printf("AUX_GetDevCaps // mixer device not available !\n");
55 return MMSYSERR_NOTENABLED;
57 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
58 close(mixer);
59 printf("AUX_GetDevCaps // unable read mixer !\n");
60 return MMSYSERR_NOTENABLED;
62 close(mixer);
63 #ifdef EMULATE_SB16
64 lpCaps->wMid = 0x0002;
65 lpCaps->vDriverVersion = 0x0200;
66 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
67 switch (wDevID) {
68 case 0:
69 lpCaps->wPid = 0x0196;
70 strcpy(lpCaps->szPname, "SB16 Aux: Wave");
71 lpCaps->wTechnology = AUXCAPS_AUXIN;
72 break;
73 case 1:
74 lpCaps->wPid = 0x0197;
75 strcpy(lpCaps->szPname, "SB16 Aux: Midi Synth");
76 lpCaps->wTechnology = AUXCAPS_AUXIN;
77 break;
78 case 2:
79 lpCaps->wPid = 0x0191;
80 strcpy(lpCaps->szPname, "SB16 Aux: CD");
81 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
82 break;
83 case 3:
84 lpCaps->wPid = 0x0192;
85 strcpy(lpCaps->szPname, "SB16 Aux: Line-In");
86 lpCaps->wTechnology = AUXCAPS_AUXIN;
87 break;
88 case 4:
89 lpCaps->wPid = 0x0193;
90 strcpy(lpCaps->szPname, "SB16 Aux: Mic");
91 lpCaps->wTechnology = AUXCAPS_AUXIN;
92 break;
93 case 5:
94 lpCaps->wPid = 0x0194;
95 strcpy(lpCaps->szPname, "SB16 Aux: Master");
96 lpCaps->wTechnology = AUXCAPS_AUXIN;
97 break;
99 #else
100 lpCaps->wMid = 0xAA;
101 lpCaps->wPid = 0x55;
102 lpCaps->vDriverVersion = 0x0100;
103 strcpy(lpCaps->szPname, "Generic Linux Auxiliary Driver");
104 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
105 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
106 #endif
107 return MMSYSERR_NOERROR;
108 #else
109 return MMSYSERR_NOTENABLED;
110 #endif
114 /**************************************************************************
115 * AUX_GetVolume [internal]
117 DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol)
119 #ifdef linux
120 int mixer;
121 int volume;
122 printf("AUX_GetVolume(%u, %08X);\n", wDevID, lpdwVol);
123 if (lpdwVol == NULL) return MMSYSERR_NOTENABLED;
124 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
125 printf("Linux 'AUX_GetVolume' // mixer device not available !\n");
126 return MMSYSERR_NOTENABLED;
128 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
129 printf("Linux 'AUX_GetVolume' // unable read mixer !\n");
130 return MMSYSERR_NOTENABLED;
132 close(mixer);
133 *lpdwVol = MAKELONG(volume, volume);
134 return MMSYSERR_NOERROR;
135 #else
136 return MMSYSERR_NOTENABLED;
137 #endif
140 /**************************************************************************
141 * AUX_SetVolume [internal]
143 DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
145 #ifdef linux
146 int mixer;
147 int volume = 50;
148 printf("AUX_SetVolume(%u, %08X);\n", wDevID, dwParam);
149 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
150 printf("Linux 'AUX_SetVolume' // mixer device not available !\n");
151 return MMSYSERR_NOTENABLED;
153 if (ioctl(mixer, SOUND_MIXER_WRITE_LINE, &volume) == -1) {
154 printf("Linux 'AUX_SetVolume' // unable set mixer !\n");
155 return MMSYSERR_NOTENABLED;
157 close(mixer);
158 return MMSYSERR_NOERROR;
159 #else
160 return MMSYSERR_NOTENABLED;
161 #endif
165 /**************************************************************************
166 * auxMessage [sample driver]
168 DWORD auxMessage(WORD wDevID, WORD wMsg, DWORD dwUser,
169 DWORD dwParam1, DWORD dwParam2)
171 printf("auxMessage(%u, %04X, %08X, %08X, %08X);\n",
172 wDevID, wMsg, dwUser, dwParam1, dwParam2);
173 switch(wMsg) {
174 case AUXDM_GETDEVCAPS:
175 return AUX_GetDevCaps(wDevID, (LPAUXCAPS)dwParam1, dwParam2);
176 case AUXDM_GETNUMDEVS:
177 printf("AUX_GetNumDevs();\n");
178 return 1L;
179 case AUXDM_GETVOLUME:
180 return AUX_GetVolume(wDevID, (LPDWORD)dwParam1);
181 case AUXDM_SETVOLUME:
182 return AUX_SetVolume(wDevID, dwParam1);
184 return MMSYSERR_NOTSUPPORTED;
188 #endif /* #ifdef BUILTIN_MMSYSTEM */