[AUDIO-BRINGUP]
[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 DeviceId,
24 IN UINT Message,
25 IN DWORD_PTR PrivateHandle,
26 IN DWORD_PTR Parameter1,
27 IN DWORD_PTR Parameter2)
28 {
29 MMRESULT Result;
30 PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
31 PSOUND_DEVICE SoundDevice;
32 PMMFUNCTION_TABLE FunctionTable;
33
34 //SND_TRACE(L"Getting mixer info %u\n", Message);
35
36 if ( PrivateHandle == 0 )
37 {
38 Result = GetSoundDevice(MIXER_DEVICE_TYPE, DeviceId, &SoundDevice);
39
40 if ( ! MMSUCCESS(Result) )
41 return TranslateInternalMmResult(Result);
42
43 Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
44 if ( ! MMSUCCESS(Result) )
45 return TranslateInternalMmResult(Result);
46
47 Result = FunctionTable->QueryMixerInfo(NULL, DeviceId, Message, (LPVOID)Parameter1, Parameter2);
48 return Result;
49 }
50
51 VALIDATE_MMSYS_PARAMETER( PrivateHandle );
52 SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE) PrivateHandle;
53
54 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
55 if ( ! MMSUCCESS(Result) )
56 return TranslateInternalMmResult(Result);
57
58 Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
59 if ( ! MMSUCCESS(Result) )
60 return TranslateInternalMmResult(Result);
61
62 if ( ! FunctionTable->QueryMixerInfo )
63 return MMSYSERR_NOTSUPPORTED;
64
65 Result = FunctionTable->QueryMixerInfo(SoundDeviceInstance, DeviceId, Message, (LPVOID)Parameter1, Parameter2);
66
67 return Result;
68 }
69
70
71 /*
72 Standard MME driver entry-point for messages relating to mixers.
73 */
74 DWORD
75 APIENTRY
76 mxdMessage(
77 UINT DeviceId,
78 UINT Message,
79 DWORD_PTR PrivateHandle,
80 DWORD_PTR Parameter1,
81 DWORD_PTR Parameter2)
82 {
83 MMRESULT Result = MMSYSERR_NOTSUPPORTED;
84
85 AcquireEntrypointMutex(MIXER_DEVICE_TYPE);
86
87 //SND_TRACE(L"mxdMessage - Message type %d\n", Message);
88
89 switch ( Message )
90 {
91 case MXDM_GETNUMDEVS :
92 {
93 Result = GetSoundDeviceCount(MIXER_DEVICE_TYPE);
94 break;
95 }
96
97 case MXDM_GETDEVCAPS :
98 {
99 Result = MmeGetSoundDeviceCapabilities(MIXER_DEVICE_TYPE,
100 DeviceId,
101 (PVOID) Parameter1,
102 Parameter2);
103 break;
104 }
105
106 case MXDM_INIT :
107 {
108 Result = MMSYSERR_NOERROR;
109 break;
110 }
111
112 case MXDM_OPEN :
113 {
114 Result = MmeOpenDevice(MIXER_DEVICE_TYPE,
115 DeviceId,
116 (LPWAVEOPENDESC) Parameter1, /* unused */
117 Parameter2,
118 (DWORD*) PrivateHandle);
119 VALIDATE_MMSYS_PARAMETER(*(DWORD_PTR*)PrivateHandle);
120 break;
121 }
122
123 case MXDM_CLOSE :
124 {
125 Result = MmeCloseDevice(PrivateHandle);
126
127 break;
128 }
129
130 case MXDM_GETCONTROLDETAILS :
131 {
132 Result = MmeGetLineInfo(DeviceId,
133 Message,
134 PrivateHandle,
135 Parameter1,
136 Parameter2);
137
138 break;
139 }
140
141 case MXDM_SETCONTROLDETAILS :
142 {
143 Result = MmeGetLineInfo(DeviceId,
144 Message,
145 PrivateHandle,
146 Parameter1,
147 Parameter2);
148
149 break;
150 }
151
152 case MXDM_GETLINECONTROLS :
153 {
154 Result = MmeGetLineInfo(DeviceId,
155 Message,
156 PrivateHandle,
157 Parameter1,
158 Parameter2);
159
160 break;
161 }
162
163 case MXDM_GETLINEINFO :
164 {
165 Result = MmeGetLineInfo(DeviceId,
166 Message,
167 PrivateHandle,
168 Parameter1,
169 Parameter2);
170
171 break;
172 }
173
174 case DRV_QUERYDEVICEINTERFACESIZE :
175 {
176 Result = MmeGetDeviceInterfaceString(MIXER_DEVICE_TYPE, DeviceId, NULL, 0, (DWORD*)Parameter1); //FIXME DWORD_PTR
177 break;
178 }
179
180 case DRV_QUERYDEVICEINTERFACE :
181 {
182 Result = MmeGetDeviceInterfaceString(MIXER_DEVICE_TYPE, DeviceId, (LPWSTR)Parameter1, Parameter2, NULL); //FIXME DWORD_PTR
183 break;
184 }
185
186 }
187
188 //SND_TRACE(L"mxdMessage returning MMRESULT %d\n", Result);
189
190 ReleaseEntrypointMutex(MIXER_DEVICE_TYPE);
191
192 return Result;
193 }