Sync to trunk HEAD (r43416)
[reactos.git] / reactos / lib / drivers / sound / mmebuddy / wave / widMessage.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/wave/widMessage.c
5 *
6 * PURPOSE: Provides the widMessage exported function, as required by
7 * the MME API, for wave input 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
19 #include <mmebuddy.h>
20
21 /*
22 Standard MME driver entry-point for messages relating to wave audio
23 input.
24 */
25 DWORD
26 APIENTRY
27 widMessage(
28 UINT DeviceId,
29 UINT Message,
30 DWORD_PTR PrivateHandle,
31 DWORD_PTR Parameter1,
32 DWORD_PTR Parameter2)
33 {
34 MMRESULT Result = MMSYSERR_NOTSUPPORTED;
35
36 AcquireEntrypointMutex(WAVE_IN_DEVICE_TYPE);
37
38 SND_TRACE(L"widMessage - Message type %d\n", Message);
39
40 switch ( Message )
41 {
42 case WIDM_GETNUMDEVS :
43 {
44 Result = GetSoundDeviceCount(WAVE_IN_DEVICE_TYPE);
45 break;
46 }
47
48 case WIDM_GETDEVCAPS :
49 {
50
51 Result = MmeGetSoundDeviceCapabilities(WAVE_IN_DEVICE_TYPE,
52 DeviceId,
53 Parameter1,
54 Parameter2);
55 break;
56 }
57 case WIDM_OPEN :
58 {
59 Result = MmeOpenWaveDevice(WAVE_IN_DEVICE_TYPE,
60 DeviceId,
61 (LPWAVEOPENDESC) Parameter1,
62 Parameter2,
63 (DWORD*) PrivateHandle);
64 break;
65 }
66
67 case WIDM_CLOSE :
68 {
69 Result = MmeCloseDevice(PrivateHandle);
70
71 break;
72 }
73
74 case WIDM_PREPARE :
75 {
76 /* TODO: Do we need to pass 2nd parameter? */
77 Result = MmePrepareWaveHeader(PrivateHandle, Parameter1);
78 break;
79 }
80
81 case WIDM_UNPREPARE :
82 {
83 Result = MmeUnprepareWaveHeader(PrivateHandle, Parameter1);
84 break;
85 }
86
87 case WIDM_RESET :
88 {
89 /* Stop playback, reset position to zero */
90 Result = MmeResetWavePlayback(PrivateHandle);
91 break;
92 }
93
94 case WIDM_ADDBUFFER :
95 {
96 Result = MmeWriteWaveHeader(PrivateHandle, Parameter1);
97 break;
98 }
99
100 }
101
102 SND_TRACE(L"widMessage returning MMRESULT %d\n", Result);
103
104 ReleaseEntrypointMutex(WAVE_IN_DEVICE_TYPE);
105
106 return Result;
107 }