xref: /reactos/dll/win32/mmdrv/auxil.c (revision 9393fc32)
1*c2c66affSColin Finck /*
2*c2c66affSColin Finck  *
3*c2c66affSColin Finck  * COPYRIGHT:            See COPYING in the top level directory
4*c2c66affSColin Finck  * PROJECT:              ReactOS Multimedia
5*c2c66affSColin Finck  * FILE:                 lib/mmdrv/auxil.c
6*c2c66affSColin Finck  * PURPOSE:              Multimedia User Mode Driver
7*c2c66affSColin Finck  * PROGRAMMER:           Andrew Greenwood
8*c2c66affSColin Finck  *                       Aleksey Bragin
9*c2c66affSColin Finck  * UPDATE HISTORY:
10*c2c66affSColin Finck  *                       Mar 16, 2004: Created skeleton implementation
11*c2c66affSColin Finck  */
12*c2c66affSColin Finck 
13*c2c66affSColin Finck #include "mmdrv.h"
14*c2c66affSColin Finck 
15*c2c66affSColin Finck #define NDEBUG
16*c2c66affSColin Finck #include <debug.h>
17*c2c66affSColin Finck 
18*c2c66affSColin Finck #include "wave.h"
19*c2c66affSColin Finck 
auxMessage(UINT dwId,UINT uMessage,DWORD dwUser,DWORD dwParam1,DWORD dwParam2)20*c2c66affSColin Finck APIENTRY DWORD auxMessage(UINT dwId,
21*c2c66affSColin Finck                   UINT uMessage,
22*c2c66affSColin Finck                   DWORD dwUser,
23*c2c66affSColin Finck                   DWORD dwParam1,
24*c2c66affSColin Finck                   DWORD dwParam2)
25*c2c66affSColin Finck 
26*c2c66affSColin Finck {
27*c2c66affSColin Finck     MMRESULT Result;
28*c2c66affSColin Finck     AUX_DD_VOLUME Volume;
29*c2c66affSColin Finck 
30*c2c66affSColin Finck     DPRINT("auxMessage\n");
31*c2c66affSColin Finck 
32*c2c66affSColin Finck 
33*c2c66affSColin Finck 	// the following cases are documented by DDK
34*c2c66affSColin Finck 	switch (uMessage)
35*c2c66affSColin Finck 	{
36*c2c66affSColin Finck 	case AUXDM_GETDEVCAPS:
37*c2c66affSColin Finck 		DPRINT("AUXDM_GETDEVCAPS");
38*c2c66affSColin Finck 		return GetDeviceCapabilities(dwId, AuxDevice, (LPBYTE)dwParam1, (DWORD)dwParam2);
39*c2c66affSColin Finck 
40*c2c66affSColin Finck 	case AUXDM_GETNUMDEVS:
41*c2c66affSColin Finck 		DPRINT("AUXDM_GETNUMDEVS");
42*c2c66affSColin Finck 		return GetDeviceCount(AuxDevice);
43*c2c66affSColin Finck 
44*c2c66affSColin Finck 	case AUXDM_GETVOLUME:
45*c2c66affSColin Finck          DPRINT("AUXDM_GETVOLUME");
46*c2c66affSColin Finck          Result = AuxGetAudio(dwId, (PBYTE) &Volume, sizeof(Volume));
47*c2c66affSColin Finck 
48*c2c66affSColin Finck          if (Result == MMSYSERR_NOERROR)
49*c2c66affSColin Finck          {
50*c2c66affSColin Finck             *(LPDWORD)dwParam1 = (DWORD)MAKELONG(HIWORD(Volume.Left), HIWORD(Volume.Right));
51*c2c66affSColin Finck          }
52*c2c66affSColin Finck          return Result;
53*c2c66affSColin Finck 
54*c2c66affSColin Finck 
55*c2c66affSColin Finck 	case AUXDM_SETVOLUME:
56*c2c66affSColin Finck         DPRINT("AUXDM_SETVOLUME");
57*c2c66affSColin Finck 
58*c2c66affSColin Finck         Volume.Right = HIWORD(dwParam1) << 16;
59*c2c66affSColin Finck         Volume.Left = LOWORD(dwParam1) << 16;
60*c2c66affSColin Finck 
61*c2c66affSColin Finck         return AuxSetAudio(dwId, (PBYTE)&Volume, sizeof(Volume));
62*c2c66affSColin Finck 
63*c2c66affSColin Finck 	}
64*c2c66affSColin Finck 
65*c2c66affSColin Finck     return MMSYSERR_NOERROR;
66*c2c66affSColin Finck }
67*c2c66affSColin Finck 
68*c2c66affSColin Finck 
AuxGetAudio(DWORD dwID,PBYTE pVolume,DWORD sizeVolume)69*c2c66affSColin Finck DWORD AuxGetAudio(DWORD dwID, PBYTE pVolume, DWORD sizeVolume)
70*c2c66affSColin Finck {
71*c2c66affSColin Finck     HANDLE DeviceHandle;
72*c2c66affSColin Finck     MMRESULT Result;
73*c2c66affSColin Finck     DWORD BytesReturned;
74*c2c66affSColin Finck 
75*c2c66affSColin Finck     Result = OpenDevice(AuxDevice, dwID, &DeviceHandle, GENERIC_READ);
76*c2c66affSColin Finck     if (Result != MMSYSERR_NOERROR)
77*c2c66affSColin Finck          return Result;
78*c2c66affSColin Finck 
79*c2c66affSColin Finck 
80*c2c66affSColin Finck     Result = DeviceIoControl(DeviceHandle, IOCTL_AUX_GET_VOLUME, NULL, 0, (LPVOID)pVolume, sizeVolume,
81*c2c66affSColin Finck                            &BytesReturned, NULL) ? MMSYSERR_NOERROR : TranslateStatus();
82*c2c66affSColin Finck 
83*c2c66affSColin Finck 
84*c2c66affSColin Finck     CloseHandle(DeviceHandle);
85*c2c66affSColin Finck 
86*c2c66affSColin Finck     return Result;
87*c2c66affSColin Finck  }
88*c2c66affSColin Finck 
AuxSetAudio(DWORD dwID,PBYTE pVolume,DWORD sizeVolume)89*c2c66affSColin Finck DWORD AuxSetAudio(DWORD dwID, PBYTE pVolume, DWORD sizeVolume)
90*c2c66affSColin Finck {
91*c2c66affSColin Finck     HANDLE DeviceHandle;
92*c2c66affSColin Finck     MMRESULT Result;
93*c2c66affSColin Finck     DWORD BytesReturned;
94*c2c66affSColin Finck 
95*c2c66affSColin Finck     Result = OpenDevice(AuxDevice, dwID, &DeviceHandle, GENERIC_READ);
96*c2c66affSColin Finck     if (Result != MMSYSERR_NOERROR)
97*c2c66affSColin Finck          return Result;
98*c2c66affSColin Finck 
99*c2c66affSColin Finck     Result = DeviceIoControl(DeviceHandle, IOCTL_AUX_SET_VOLUME, (LPVOID)pVolume, sizeVolume, NULL, 0,
100*c2c66affSColin Finck                            &BytesReturned, NULL) ? MMSYSERR_NOERROR : TranslateStatus();
101*c2c66affSColin Finck 
102*c2c66affSColin Finck 
103*c2c66affSColin Finck     CloseHandle(DeviceHandle);
104*c2c66affSColin Finck 
105*c2c66affSColin Finck     return Result;
106*c2c66affSColin Finck  }
107*c2c66affSColin Finck 
108