~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/wineoss.drv/mmaux.c

Version: ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Sample AUXILIARY Wine Driver
  3  *
  4  * Copyright 1994 Martin Ayotte
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include "config.h"
 22 #include "wine/port.h"
 23 
 24 #include <stdarg.h>
 25 #include <stdlib.h>
 26 #include <string.h>
 27 #ifdef HAVE_UNISTD_H
 28 # include <unistd.h>
 29 #endif
 30 #include <fcntl.h>
 31 #ifdef HAVE_SYS_IOCTL_H
 32 # include <sys/ioctl.h>
 33 #endif
 34 
 35 #include "windef.h"
 36 #include "winbase.h"
 37 #include "mmddk.h"
 38 #include "oss.h"
 39 #include "wine/unicode.h"
 40 #include "wine/debug.h"
 41 
 42 WINE_DEFAULT_DEBUG_CHANNEL(mmaux);
 43 
 44 #ifdef HAVE_OSS
 45 
 46 #define MIXER_DEV "/dev/mixer"
 47 
 48 static int      NumDev = 6;
 49 
 50 /*-----------------------------------------------------------------------*/
 51 
 52 LRESULT OSS_AuxInit(void)
 53 {
 54     int mixer;
 55     TRACE("()\n");
 56 
 57     if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
 58         WARN("mixer device not available !\n");
 59         NumDev = 0;
 60     } else {
 61         close(mixer);
 62         NumDev = 6;
 63     }
 64     return 0;
 65 }
 66 
 67 /*-----------------------------------------------------------------------*/
 68 
 69 LRESULT OSS_AuxExit(void)
 70 {
 71     TRACE("()\n");
 72     return 0;
 73 }
 74 
 75 /**************************************************************************
 76  *                              AUX_GetDevCaps                  [internal]
 77  */
 78 static DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPSW lpCaps, DWORD dwSize)
 79 {
 80     int         mixer, volume;
 81     static const WCHAR ini[] = {'O','S','S',' ','A','u','x',0};
 82 
 83     TRACE("(%04X, %p, %u);\n", wDevID, lpCaps, dwSize);
 84     if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
 85     if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
 86         WARN("mixer device not available !\n");
 87         return MMSYSERR_NOTENABLED;
 88     }
 89     if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
 90         close(mixer);
 91         WARN("unable to read mixer !\n");
 92         return MMSYSERR_NOTENABLED;
 93     }
 94     close(mixer);
 95     lpCaps->wMid = 0xAA;
 96     lpCaps->wPid = 0x55;
 97     lpCaps->vDriverVersion = 0x0100;
 98     strcpyW(lpCaps->szPname, ini);
 99     lpCaps->wTechnology = AUXCAPS_CDAUDIO;
100     lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
101 
102     return MMSYSERR_NOERROR;
103 }
104 
105 
106 /**************************************************************************
107  *                              AUX_GetVolume                   [internal]
108  */
109 static DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol)
110 {
111     int         mixer, volume, left, right, cmd;
112 
113     TRACE("(%04X, %p);\n", wDevID, lpdwVol);
114     if (lpdwVol == NULL) return MMSYSERR_NOTENABLED;
115     if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
116         WARN("mixer device not available !\n");
117         return MMSYSERR_NOTENABLED;
118     }
119     switch(wDevID) {
120     case 0:
121         TRACE("SOUND_MIXER_READ_PCM !\n");
122         cmd = SOUND_MIXER_READ_PCM;
123         break;
124     case 1:
125         TRACE("SOUND_MIXER_READ_SYNTH !\n");
126         cmd = SOUND_MIXER_READ_SYNTH;
127         break;
128     case 2:
129         TRACE("SOUND_MIXER_READ_CD !\n");
130         cmd = SOUND_MIXER_READ_CD;
131         break;
132     case 3:
133         TRACE("SOUND_MIXER_READ_LINE !\n");
134         cmd = SOUND_MIXER_READ_LINE;
135         break;
136     case 4:
137         TRACE("SOUND_MIXER_READ_MIC !\n");
138         cmd = SOUND_MIXER_READ_MIC;
139         break;
140     case 5:
141         TRACE("SOUND_MIXER_READ_VOLUME !\n");
142         cmd = SOUND_MIXER_READ_VOLUME;
143         break;
144     default:
145         WARN("invalid device id=%04X !\n", wDevID);
146         return MMSYSERR_NOTENABLED;
147     }
148     if (ioctl(mixer, cmd, &volume) == -1) {
149         WARN("unable to read mixer !\n");
150         return MMSYSERR_NOTENABLED;
151     }
152     close(mixer);
153     left  = LOBYTE(LOWORD(volume));
154     right = HIBYTE(LOWORD(volume));
155     TRACE("left=%d right=%d !\n", left, right);
156     *lpdwVol = MAKELONG((left * 0xFFFFL) / 100, (right * 0xFFFFL) / 100);
157     return MMSYSERR_NOERROR;
158 }
159 
160 /**************************************************************************
161  *                              AUX_SetVolume                   [internal]
162  */
163 static DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
164 {
165     int         mixer;
166     int         volume, left, right;
167     int         cmd;
168 
169     TRACE("(%04X, %08X);\n", wDevID, dwParam);
170 
171     left   = (LOWORD(dwParam) * 100) >> 16;
172     right  = (HIWORD(dwParam) * 100) >> 16;
173     volume = (right << 8) | left;
174 
175     if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
176         WARN("mixer device not available !\n");
177         return MMSYSERR_NOTENABLED;
178     }
179 
180     switch(wDevID) {
181     case 0:
182         TRACE("SOUND_MIXER_WRITE_PCM !\n");
183         cmd = SOUND_MIXER_WRITE_PCM;
184         break;
185     case 1:
186         TRACE("SOUND_MIXER_WRITE_SYNTH !\n");
187         cmd = SOUND_MIXER_WRITE_SYNTH;
188         break;
189     case 2:
190         TRACE("SOUND_MIXER_WRITE_CD !\n");
191         cmd = SOUND_MIXER_WRITE_CD;
192         break;
193     case 3:
194         TRACE("SOUND_MIXER_WRITE_LINE !\n");
195         cmd = SOUND_MIXER_WRITE_LINE;
196         break;
197     case 4:
198         TRACE("SOUND_MIXER_WRITE_MIC !\n");
199         cmd = SOUND_MIXER_WRITE_MIC;
200         break;
201     case 5:
202         TRACE("SOUND_MIXER_WRITE_VOLUME !\n");
203         cmd = SOUND_MIXER_WRITE_VOLUME;
204         break;
205     default:
206         WARN("invalid device id=%04X !\n", wDevID);
207         return MMSYSERR_NOTENABLED;
208     }
209     if (ioctl(mixer, cmd, &volume) == -1) {
210         WARN("unable to set mixer !\n");
211         return MMSYSERR_NOTENABLED;
212     }
213     close(mixer);
214     return MMSYSERR_NOERROR;
215 }
216 
217 #endif
218 
219 /**************************************************************************
220  *              auxMessage (WINEOSS.2)
221  */
222 DWORD WINAPI OSS_auxMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
223                             DWORD dwParam1, DWORD dwParam2)
224 {
225     TRACE("(%04X, %04X, %08X, %08X, %08X);\n",
226           wDevID, wMsg, dwUser, dwParam1, dwParam2);
227 
228 #ifdef HAVE_OSS
229     switch (wMsg) {
230     case DRVM_INIT:
231     case DRVM_EXIT:
232     case DRVM_ENABLE:
233     case DRVM_DISABLE:
234         /* FIXME: Pretend this is supported */
235         return 0;
236     case AUXDM_GETDEVCAPS:
237         return AUX_GetDevCaps(wDevID, (LPAUXCAPSW)dwParam1, dwParam2);
238     case AUXDM_GETNUMDEVS:
239         TRACE("return %d;\n", NumDev);
240         return NumDev;
241     case AUXDM_GETVOLUME:
242         return AUX_GetVolume(wDevID, (LPDWORD)dwParam1);
243     case AUXDM_SETVOLUME:
244         return AUX_SetVolume(wDevID, dwParam1);
245     default:
246         WARN("unknown message !\n");
247     }
248     return MMSYSERR_NOTSUPPORTED;
249 #else
250     return MMSYSERR_NOTENABLED;
251 #endif
252 }
253 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.