- merge audio headers
[reactos.git] / lib / drivers / sound / mmebuddy / mixer / mxdMessage.c
1 /*
2 * PROJECT: ReactOS Sound System "MME Buddy" Library
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: lib/sound/mmebuddy/mixer/mxdMessage.c
5 *
6 * PURPOSE: Provides the mxdMessage exported function, as required by
7 * the MME API, for mixer device support.
8 *
9 * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
10 */
11
12 #include <windows.h>
13 #include <mmsystem.h>
14 #include <mmddk.h>
15
16 #include <ntddsnd.h>
17 #include <sndtypes.h>
18 #undef NDEBUG
19 #include <mmebuddy.h>
20
21 MMRESULT
22 MmeGetLineInfo(
23 IN UINT Message,
24 IN DWORD_PTR PrivateHandle,
25 IN DWORD_PTR Parameter1,
26 IN DWORD_PTR Parameter2)
27 {
28 MMRESULT Result;
29 PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
30 PSOUND_DEVICE SoundDevice;
31 PMMFUNCTION_TABLE FunctionTable;
32
33 //SND_TRACE(L"Getting mixer info %u\n", Message);
34
35 VALIDATE_MMSYS_PARAMETER( PrivateHandle );
36 SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE) PrivateHandle;
37
38 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
39 if ( ! MMSUCCESS(Result) )
40 return TranslateInternalMmResult(Result);
41
42 Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
43 if ( ! MMSUCCESS(Result) )
44 return TranslateInternalMmResult(Result);
45
46 if ( ! FunctionTable->QueryMixerInfo )
47 return MMSYSERR_NOTSUPPORTED;
48
49 Result = FunctionTable->QueryMixerInfo(SoundDeviceInstance, Message, (LPVOID)Parameter1, Parameter2);
50
51 return Result;
52 }
53
54
55 /*
56 Standard MME driver entry-point for messages relating to mixers.
57 */
58 DWORD
59 APIENTRY
60 mxdMessage(
61 UINT DeviceId,
62 UINT Message,
63 DWORD_PTR PrivateHandle,
64 DWORD_PTR Parameter1,
65 DWORD_PTR Parameter2)
66 {
67 MMRESULT Result = MMSYSERR_NOTSUPPORTED;
68
69 AcquireEntrypointMutex(MIXER_DEVICE_TYPE);
70
71 //SND_TRACE(L"mxdMessage - Message type %d\n", Message);
72
73 switch ( Message )
74 {
75 case MXDM_GETNUMDEVS :
76 {
77 Result = GetSoundDeviceCount(MIXER_DEVICE_TYPE);
78 break;
79 }
80
81 case MXDM_GETDEVCAPS :
82 {
83 Result = MmeGetSoundDeviceCapabilities(MIXER_DEVICE_TYPE,
84 DeviceId,
85 (PVOID) Parameter1,
86 Parameter2);
87 break;
88 }
89
90 case MXDM_INIT :
91 {
92 Result = MMSYSERR_NOERROR;
93 break;
94 }
95
96 case MXDM_OPEN :
97 {
98 Result = MmeOpenDevice(MIXER_DEVICE_TYPE,
99 DeviceId,
100 (LPWAVEOPENDESC) Parameter1, /* unused */
101 Parameter2,
102 (DWORD*) PrivateHandle);
103
104 break;
105 }
106
107 case MXDM_CLOSE :
108 {
109 Result = MmeCloseDevice(PrivateHandle);
110
111 break;
112 }
113
114 case MXDM_GETCONTROLDETAILS :
115 {
116 Result = MmeGetLineInfo(Message,
117 PrivateHandle,
118 Parameter1,
119 Parameter2);
120
121 break;
122 }
123
124 case MXDM_SETCONTROLDETAILS :
125 {
126 Result = MmeGetLineInfo(Message,
127 PrivateHandle,
128 Parameter1,
129 Parameter2);
130
131 break;
132 }
133
134 case MXDM_GETLINECONTROLS :
135 {
136 Result = MmeGetLineInfo(Message,
137 PrivateHandle,
138 Parameter1,
139 Parameter2);
140
141 break;
142 }
143
144 case MXDM_GETLINEINFO :
145 {
146 Result = MmeGetLineInfo(Message,
147 PrivateHandle,
148 Parameter1,
149 Parameter2);
150
151 break;
152 }
153
154 case DRV_QUERYDEVICEINTERFACESIZE :
155 {
156 Result = MmeGetDeviceInterfaceString(MIXER_DEVICE_TYPE, DeviceId, NULL, 0, (DWORD*)Parameter1); //FIXME DWORD_PTR
157 break;
158 }
159
160 case DRV_QUERYDEVICEINTERFACE :
161 {
162 Result = MmeGetDeviceInterfaceString(MIXER_DEVICE_TYPE, DeviceId, (LPWSTR)Parameter1, Parameter2, NULL); //FIXME DWORD_PTR
163 break;
164 }
165
166 }
167
168 //SND_TRACE(L"mxdMessage returning MMRESULT %d\n", Result);
169
170 ReleaseEntrypointMutex(MIXER_DEVICE_TYPE);
171
172 return Result;
173 }